ARB
MetaInfo.h
Go to the documentation of this file.
1 // ================================================================ //
2 // //
3 // File : MetaInfo.h //
4 // Purpose : //
5 // //
6 // Coded by Ralf Westram (coder@reallysoft.de) in November 2006 //
7 // Institute of Microbiology (Technical University Munich) //
8 // http://www.arb-home.de/ //
9 // //
10 // ================================================================ //
11 #ifndef METAINFO_H
12 #define METAINFO_H
13 
14 #ifndef METATAG_H
15 #include "MetaTag.h"
16 #endif
17 
18 class Reference { // holds information of one reference section
19  stringMap entries; // reference entries mapped to ARBDB field names
20 
21 public:
22  Reference() {}
23 
24  void add(const std::string& field, const std::string& content);
25  const std::string *get(const std::string& field) const;
26 
27  void getKeys(stringSet& keys) const; // get reference keys
28 };
29 
30 
31 class References : virtual Noncopyable { // holds information of all reference sections
32  std::vector<Reference> refs;
33  Reference *latest;
34  int ref_count;
35 
36 public:
38  latest(NULp),
39  ref_count(0)
40  {}
41 
42  void start(); // start a new reference
43  void add(const std::string& field, const std::string& content) {
44  gi_assert(latest);
45  latest->add(field, content);
46  }
47 
48  void add_dbid(const std::string& content); // special handling for 'RX' field
49 
50  void getKeys(stringSet& keys) const; // get reference keys
51  std::string tagged_content(const std::string& refkey) const;
52 
53 #if defined(DEBUG)
54  void dump() const;
55 #endif // DEBUG
56 };
57 
58 class MetaInfo : virtual Noncopyable {
59  stringMap entries; // key = arb_field, value = content
60 
61 public:
62  MetaInfo() {}
63 
64  void add(const MetaTag *meta, const std::string& content, bool allow_multiple_entries);
65 
66 #if defined(DEBUG)
67  void dump() const;
68 #endif // DEBUG
69 
70  const stringMap& getEntries() const { return entries; }
71 
72  const std::string& getAccessionNumber() const;
73 };
74 
75 #else
76 #error MetaInfo.h included twice
77 #endif // METAINFO_H
78 
79 
80 
void getKeys(stringSet &keys) const
Definition: MetaInfo.cxx:53
Reference()
Definition: MetaInfo.h:22
return string(buffer, length)
void add(const MetaTag *meta, const std::string &content, bool allow_multiple_entries)
Definition: MetaInfo.cxx:173
#define gi_assert(cond)
Definition: defs.h:26
References()
Definition: MetaInfo.h:37
void add_dbid(const std::string &content)
Definition: MetaInfo.cxx:122
MetaInfo()
Definition: MetaInfo.h:62
const std::string & getAccessionNumber() const
Definition: MetaInfo.cxx:186
void add(const std::string &field, const std::string &content)
Definition: MetaInfo.cxx:18
void add(const std::string &field, const std::string &content)
Definition: MetaInfo.h:43
std::map< std::string, std::string > stringMap
Definition: types.h:29
void getKeys(stringSet &keys) const
Definition: MetaInfo.cxx:34
#define NULp
Definition: cxxforward.h:97
std::set< std::string > stringSet
Definition: types.h:28
void start()
Definition: MetaInfo.cxx:46
const stringMap & getEntries() const
Definition: MetaInfo.h:70
std::string tagged_content(const std::string &refkey) const
Definition: MetaInfo.cxx:61