version  0.0.1
Defines the C++ API for MsPASS
AntelopePf.h
1 #ifndef _ANTELOPE_PF_H_
2 #define _ANTELOPE_PF_H_
3 
4 #include <list>
5 #include <string>
6 #include "mspass/utility/Metadata.h"
7 namespace mspass{
8 namespace utility{
18 const std::string pftbl_key("AntelopePfTbl");
19 const std::string pfarr_key("AntelopePfArr");
61 class AntelopePf : public Metadata
62 {
63 public:
82  AntelopePf(std::string pfbase);
91  AntelopePf(std::list<std::string> lines);
93  AntelopePf(const AntelopePf& parent);
103  std::list<std::string> get_tbl(const std::string key) const;
116  AntelopePf get_branch(const std::string key) const;
118  std::list<std::string> arr_keys() const;
120  std::list<std::string> tbl_keys() const;
135  AntelopePf& operator=(const AntelopePf& parent);
149  void pfwrite(std::ostream& ofs);
150 private:
151  std::map<std::string,std::list<std::string> > pftbls;
152  /* This is used for nested Arrs */
153  std::map<std::string, AntelopePf> pfbranches;
154  /* This method is used to implemetn PFPATH - it is called for
155  each secondary file in the PFPATH chain. Returns the number of
156  items changed */
157  int merge_pfmf(AntelopePf& m);
158 };
167 {
168  public:
169  AntelopePfError(){
170  message=std::string("AntelopePfError->undefined error");
171  };
172  AntelopePfError(std::string mess)
173  {
174  message="AntelopePfError object message="+mess;
175  };
176  AntelopePfError(const char *mess)
177  {
178  message=std::string("AntelopePfError object message=")+mess;
179  };
180  void log_error(){
181  std::cerr << message<<std::endl;
182  };
183 };
184 /* Procedural functions using AntelopePf object */
185 
198 MetadataList get_mdlist(const mspass::utility::AntelopePf& m, const std::string tag);
200 AntelopePf pfread(const std::string fname);
201 
202 } // End utility namespace
203 } // End mspass namespace declaration
204 #endif
Error class for AntelopePf object.
Definition: AntelopePf.h:167
C++ object version of a parameter file.
Definition: AntelopePf.h:62
std::list< std::string > arr_keys() const
Definition: AntelopePf.cc:417
AntelopePf(std::string pfbase)
Construct from a base pf name.
std::list< std::string > get_tbl(const std::string key) const
get a Tbl component by key.
Definition: AntelopePf.cc:401
AntelopePf(std::list< std::string > lines)
Construct from a set of text lines.
AntelopePf get_branch(const std::string key) const
used for subtrees (nested Arrs in antelope)
Definition: AntelopePf.cc:409
AntelopePf & operator=(const AntelopePf &parent)
Definition: AntelopePf.cc:433
std::list< std::string > tbl_keys() const
Definition: AntelopePf.cc:425
Metadata ConvertToMetadata()
Return an object with only simple name:value pairs.
Definition: AntelopePf.cc:444
AntelopePf()
Definition: AntelopePf.h:65
void pfwrite(std::ostream &ofs)
save result in a pf format.
Definition: Metadata.h:76
Base class for error object thrown by MsPASS library routines.
Definition: MsPASSError.h:40
std::string message
Definition: MsPASSError.h:109