to_indented_string_annotated_test.cc
Go to the documentation of this file.
1 // ======================================================================
2 //
3 // test of to_indented_string with annotations
4 //
5 // ======================================================================
6 
10 #include "fhiclcpp/parse.h"
11 
12 #include <cstdlib>
13 #include <iostream>
14 #include <string>
15 
16 int
18 {
19 
20  // Configuration file lookup policy.
21  char const* fhicl_env = getenv("FHICL_FILE_PATH");
22  std::string search_path;
23  if (fhicl_env == nullptr) {
24  std::cerr << "Expected environment variable FHICL_FILE_PATH is "
25  << "missing or empty: using \".\"\n";
26  search_path = ".:";
27  } else {
28  search_path = std::string(fhicl_env) + ":";
29  }
30 
31  cet::filepath_lookup policy(search_path);
32  std::string const in{"to_indented_string_annotated_test.fcl"};
33 
34  auto const tbl = fhicl::parse_document(in, policy);
35  auto pset = fhicl::ParameterSet::make(tbl);
36 
37  pset.put<int>("another_number", 4);
38  pset.put_or_replace<int>("some_number", 8);
39  pset.put_or_replace<double>("double", 234.6);
40 
41  std::cout << pset.to_indented_string(0, true) << std::endl;
42 }
std::string string
Definition: nybbler.cc:12
static ParameterSet make(intermediate_table const &tbl)
Definition: ParameterSet.cc:68
std::string getenv(std::string const &name)
Definition: getenv.cc:15
intermediate_table parse_document(std::string const &filename, cet::filepath_maker &maker)
Definition: parse.cc:720
QTextStream & endl(QTextStream &s)