|
| Metadata () |
|
| Metadata (std::ifstream &ifs, const std::string form=std::string("pf")) |
|
| Metadata (const Metadata &mdold) |
|
virtual | ~Metadata () |
|
Metadata & | operator= (const Metadata &mdold) |
|
Metadata & | operator+= (const Metadata &rhs) noexcept |
|
const Metadata | operator+ (const Metadata &other) const |
|
double | get_double (const std::string key) const override |
|
int | get_int (const std::string key) const override |
|
long | get_long (const std::string key) const |
|
std::string | get_string (const std::string key) const override |
|
bool | get_bool (const std::string key) const override |
|
template<typename T > |
T | get (const std::string key) const |
|
template<typename T > |
T | get (const char *key) const |
| Generic get interface for C char array. More...
|
|
boost::any | get_any (const std::string key) const |
|
std::string | type (const std::string key) const |
|
template<typename T > |
void | put (const std::string key, T val) noexcept |
|
template<typename T > |
void | put (const char *key, T val) noexcept |
|
void | put (const std::string key, const double val) override |
|
void | put (const std::string key, const int val) override |
|
void | put (const std::string key, const bool val) override |
|
void | put (const std::string key, const std::string val) override |
|
void | put (const char *key, const char *val) |
|
void | put (std::string key, const char *val) |
|
void | put_object (const std::string key, const pybind11::object val) |
|
void | put_int (const std::string key, const int val) |
|
void | put_string (const std::string key, const std::string val) |
|
void | put_bool (const std::string key, const bool val) |
|
void | put_double (const std::string key, const double val) |
|
void | put_long (const std::string key, const long val) |
|
void | append_chain (const std::string key, const std::string val, const std::string separator=std::string(":")) |
|
std::set< std::string > | modified () const |
|
void | clear_modified () |
| Mark all data as unmodified. More...
|
|
std::set< std::string > | keys () const noexcept |
|
bool | is_defined (const std::string key) const noexcept |
|
void | erase (const std::string key) |
|
std::size_t | size () const noexcept |
|
std::map< std::string, boost::any >::const_iterator | begin () const noexcept |
|
std::map< std::string, boost::any >::const_iterator | end () const noexcept |
|
void | change_key (const std::string oldkey, const std::string newkey) |
| Change the keyword to access an attribute. More...
|
|
void mspass::utility::Metadata::append_chain |
( |
const std::string |
key, |
|
|
const std::string |
val, |
|
|
const std::string |
separator = std::string(":") |
|
) |
| |
Create or append to a chained string.
A chain conceptually is identical to a list of string data. We implement it in Metadata because sometimes (e.g. MongoDB interaction and some constructs like the unix shell PATH variable) handling a full scale container like list<std::string> would be awkward. If more extensive capability like that is needed it would be better to add a class that inherits Metadata and does so. AntelopePf more or less does this, for example, handling Tbl sections. In any case, this usage is more for one word strings separated by a common separator: e.g. path=/usr/local/bin:/bin uses : as the separator. /usr/local/bin and /bin are the chain.
If the key related to the chain does not yet exist it is silently created. If it already exists and we append to it.
- Parameters
-
key | is the key that defines the string. |
val | is the the new string to append to the chain |
separator | is the string used for a separator (default ":") |
- Exceptions
-
MsPASSError | will be thrown if data is found in key and it is not of type string. |
91 string typ=this->type(key);
92 if(typ.find(
"string")==string::npos)
93 throw MsPASSError(
"Metadata::append_chain: data for key="
94 + key +
" is not string type but "+typ
95 +
"\nMust be string type to define a valid chain",
96 ErrorSeverity::Invalid);
106 changed_or_set.insert(key);
References is_defined().
void mspass::utility::Metadata::change_key |
( |
const std::string |
oldkey, |
|
|
const std::string |
newkey |
|
) |
| |
Change the keyword to access an attribute.
Sometimes it is useful to change the key used to access a particular piece of data. Doing so, for example, is one way to implement an alias (alternative name) for something. The entry for the old key is copied to a entry accessible by the new key. The entry for old is then deleted. This avoids downstream inconsistencies a the cost of possible failures from the translation. This method always returns and will silently do nothing if old is not defined. If the new key is already defined, its content will be replaced by the old's.
- Parameters
-
oldkey | is the key to search for to be changed |
newkey | is the new key to use for the replacement. |
326 map<string,boost::any>::iterator mdptr;
327 mdptr=md.find(oldkey);
331 md.insert_or_assign(newkey, mdptr->second);
template<typename T >
T mspass::utility::Metadata::get |
( |
const char * |
key | ) |
const |
|
inline |
Generic get interface for C char array.
This is a generic interface most useful for template procedures
that need to get a Metadata component. Since this object only
can contain simple types the type requested must be simple.
Currently supports only int, long, short, double, float, and string.
C char* is intentionally not supported. This is largely a wrapper
on the string key version of this same generic function.
\param key is the name tag of desired component.
\exception - will throw a MetadataGetError (child of MsPASSError) for
type mismatch or in an overflow or underflow condition.
269 val=get<T>(std::string(key));