22 stringMapIter existing = entries.find(field);
23 if (existing != entries.end()) {
26 entries[field] = content;
30 stringMapCIter existing = entries.find(field);
31 return (existing != entries.end()) ? &existing->second :
NULp;
35 stringMapCIter e = entries.end();
36 for (stringMapCIter i = entries.begin(); i != e; ++i) {
37 keys.insert(i->first);
48 latest = &refs.back();
55 RefVectorCIter e = refs.end();
56 for (RefVectorCIter i = refs.begin(); i != e; ++i) {
65 RefVectorCIter i = refs.begin();
66 const string *ref_content = i->get(refkey);
69 content = *ref_content;
73 RefVectorCIter e = refs.end();
75 for (RefVectorCIter i = refs.begin(); i != e; ++i, ++count) {
76 const string *ref_content = i->get(refkey);
78 if (!content.empty()) content.append(1,
' ');
80 content.append(*ref_content);
88 void References::dump()
const {
91 stringSetIter e = keys.end();
93 for (stringSetIter i = keys.begin(); i != e; ++i) {
94 string tagged = tagged_content(*i);
95 printf(
"%s='%s'\n", i->c_str(), tagged.c_str());
130 RegExpr reg_dbid(
"^([A-Z]+);\\s+|\n([A-Z]+);\\s+",
false);
135 throw GBS_global_string(
"Expected database reference id (e.g. 'DOI; ' or 'PUBMED; ')");
144 string dbid = sub->
extract(content);
147 dbid_start = reg_dbid.
match(content, id_start);
150 const char *arb_field =
NULp;
151 for (
int m = 0; ; m++) {
152 const char *name = dbid_definition[m].
id;
155 type = dbid_definition[m].
type;
156 arb_field = dbid_definition[m].
arb_field;
162 string id = content.substr(id_start, dbid_start ? dbid_start->
pos()-id_start : string::npos);
163 if (
id.empty())
throw GBS_global_string(
"Empty database reference for '%s'", dbid.c_str());
174 stringMapIter existing = entries.find(meta->
field);
175 if (existing != entries.end()) {
176 if (!allow_multiple_entries) {
179 existing->second +=
'\n'+content;
182 entries[meta->
field] = content;
187 stringMapCIter found = entries.find(
"acc");
188 if (found == entries.end()) {
189 static string no_acc(
"<Missing accession number>");
192 return found->second;
196 void MetaInfo::dump()
const {
197 stringMapCIter e = entries.end();
199 printf(
"MetaInfo:\n");
200 for (stringMapCIter i = entries.begin(); i != e; ++i) {
201 printf(
"%s='%s'\n", i->first.c_str(), i->second.c_str());
const RegMatch * subexpr_match(size_t subnr) const
void getKeys(stringSet &keys) const
size_t posBehindMatch() const
void add_dbid(const std::string &content)
GB_ERROR get_error() const
const char * GBS_global_string(const char *templat,...)
void add(const std::string &field, const std::string &content)
const RegMatch * match(const std::string &versus, size_t offset=0) const
const std::string * has_failed() const
const std::string * get(const std::string &field) const
void getKeys(stringSet &keys) const
std::set< std::string > stringSet
std::string extract(const std::string &s) const
size_t subexpr_count() const
std::string tagged_content(const std::string &refkey) const