1 | // ================================================================ // |
---|
2 | // // |
---|
3 | // File : MetaTag.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 METATAG_H |
---|
12 | #define METATAG_H |
---|
13 | |
---|
14 | #ifndef TYPES_H |
---|
15 | #include "types.h" |
---|
16 | #endif |
---|
17 | |
---|
18 | enum MetaTagType { |
---|
19 | MT_HEADER, // Header tag (ID or LOCUS) |
---|
20 | MT_BASIC, // Basic tag -> gets written to DB (into 'field') |
---|
21 | MT_REF_START, // Start of (new) reference |
---|
22 | MT_REF, // Reference data, 'field' describes type of reference |
---|
23 | MT_REF_DBID, // Database reference (PUBMED, MEDLINE, DOI, ...) |
---|
24 | MT_FEATURE_START, // Start of feature table |
---|
25 | MT_FEATURE, // Feature table |
---|
26 | MT_SEQUENCE_START, // Start of sequence |
---|
27 | MT_CONTIG, // contig entry |
---|
28 | MT_END, // End of file (or section, if multiple entries) |
---|
29 | MT_IGNORE, // is ignored |
---|
30 | }; |
---|
31 | |
---|
32 | struct MetaTag { |
---|
33 | std::string tag; // tag name (in flatfile) |
---|
34 | std::string field; // field name |
---|
35 | MetaTagType type; |
---|
36 | }; |
---|
37 | |
---|
38 | typedef std::map<std::string, const MetaTag *> MetaTagMap; |
---|
39 | |
---|
40 | class MetaTagTranslator : virtual Noncopyable { |
---|
41 | MetaTagMap translate; |
---|
42 | |
---|
43 | public: |
---|
44 | MetaTagTranslator(const struct MetaTag *meta_description) { |
---|
45 | for (int idx = 0; !meta_description[idx].tag.empty(); ++idx) { |
---|
46 | const MetaTag& mt = meta_description[idx]; |
---|
47 | translate[mt.tag] = &mt; |
---|
48 | } |
---|
49 | } |
---|
50 | |
---|
51 | const MetaTag *get(const std::string& tag) const { |
---|
52 | MetaTagMap::const_iterator found = translate.find(tag); |
---|
53 | if (found != translate.end()) return found->second; |
---|
54 | return NULp; |
---|
55 | } |
---|
56 | }; |
---|
57 | |
---|
58 | |
---|
59 | |
---|
60 | #else |
---|
61 | #error MetaTag.h included twice |
---|
62 | #endif // METATAG_H |
---|
63 | |
---|