X-Git-Url: http://woldlab.caltech.edu/gitweb/?p=mussa.git;a=blobdiff_plain;f=alg%2Fannotations.cpp;h=996e314b4eecb6378f4cbf31773bf9e044a75e67;hp=ff84ffe4f06a2c4f881019df30dcfd6259facd87;hb=5c3dc8c42679629c19ece07c0e63a53b1c69663f;hpb=6317e56b965b35eb20abbd3c383cba487908bf39 diff --git a/alg/annotations.cpp b/alg/annotations.cpp index ff84ffe..996e314 100644 --- a/alg/annotations.cpp +++ b/alg/annotations.cpp @@ -7,7 +7,7 @@ Annotations::Annotations() metadata[name_str] = ""; } -Annotations::Annotations(const std::string &n) +Annotations::Annotations(const std::string n) { metadata[name_str] = n; } @@ -38,12 +38,12 @@ void Annotations::erase(const std::string& key) } } -void Annotations::set(const std::string& key, const std::string &value ) +void Annotations::set(const std::string key, const std::string value ) { metadata[key] = value; } -std::string Annotations::get(const std::string& key) const +std::string Annotations::get(const std::string key) const { metadata_map::const_iterator map_i(metadata.find(key)); if (map_i == metadata.end()) { @@ -53,7 +53,16 @@ std::string Annotations::get(const std::string& key) const } } -bool Annotations::has_key(const std::string& key) const +std::string Annotations::getdefault(const std::string key, std::string default_value) const +{ + try { + return get(key); + } catch(annotations_key_error e) { + return default_value; + } +} + +bool Annotations::has_key(const std::string key) const { metadata_map::const_iterator map_i(metadata.find(key)); return map_i != metadata.end();