| 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: |
|---|
| 37 | References() : |
|---|
| 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 | |
|---|