version
0.0.1
Defines the C++ API for MsPASS
|
Cross reference between external and internal names. More...
#include <AttributeCrossReference.h>
Public Member Functions | |
AttributeCrossReference () | |
AttributeCrossReference (const std::string lines_to_parse) | |
AttributeCrossReference (const std::list< std::string > &lines) | |
AttributeCrossReference (const std::map< std::string, std::string > internal2external, const mspass::utility::MetadataList &mdlist) | |
AttributeCrossReference (const AttributeCrossReference &parent) | |
std::string | internal (const std::string key) const |
std::string | external (const std::string key) const |
MDtype | type (const std::string key) const |
AttributeCrossReference & | operator= (const AttributeCrossReference &parent) |
int | size () const |
void | put (const std::string intern, const std::string ext) |
std::set< std::string > | internal_names () const |
std::set< std::string > | external_names () const |
Cross reference between external and internal names.
Data formats commonly have a frozen namespace with which people are very familiar. An example is SAC where scripts commonly manipulate header attribute by a fixed set of names. For good reasons one may want to use a different naming convention internally in a piece of software that loads data using an external format but wishes to use a different set of names internally. This object simplifies the task of managing the differences in internal and external names
|
inline |
mspass::utility::AttributeCrossReference::AttributeCrossReference | ( | const std::string | lines_to_parse | ) |
Construct from a string.
This constructor assumes the string variable passed is a complete image of a set of (newline separated) lines defining the mapping. The format of each line is assumed to be: internal_name external_name type. As the names imply "internal_name" is the name to use internally and "external_name" is the foramt specific external name. The "type" variable is generic and should be one of the simple keywords real, int, string, or boolean.
lines_to_parse | is the (multiline) string in the format described above. |
MsPASSError | will be thrown for parsing errors. |
mspass::utility::AttributeCrossReference::AttributeCrossReference | ( | const std::list< std::string > & | lines | ) |
Construct from a list container.
This constructor is nearly identical to the single string with newline constructor. The list elements are expected to be the contents of each line (newline break) for the string version.
\lines list container with input lines in same format as that described above for single string constructor.
MsPASSError | will be thrown if there are parsing errors. |
mspass::utility::AttributeCrossReference::AttributeCrossReference | ( | const std::map< std::string, std::string > | internal2external, |
const mspass::utility::MetadataList & | mdlist | ||
) |
Build for a set of STL containers.
This is lower level constructor that effectively builds this object from a set of components that are used to actually implement the concept.
internal2external | is an associative array keyed by the internal name that defines external names linked to each internal name. |
mdlist | is a MsPASS::MetadataList object defining the complete internal namespace. |
mspass::utility::AttributeCrossReference::AttributeCrossReference | ( | const AttributeCrossReference & | parent | ) |
string mspass::utility::AttributeCrossReference::external | ( | const std::string | key | ) | const |
Get external name for attribute with internal name key.
set< string > mspass::utility::AttributeCrossReference::external_names | ( | ) | const |
Return the set of external names defined by this object.
Returns an std::set container of strings that are the external names defined by this object.
string mspass::utility::AttributeCrossReference::internal | ( | const std::string | key | ) | const |
Get internal name for attribute with external name key.
set< string > mspass::utility::AttributeCrossReference::internal_names | ( | ) | const |
Return the set of internal names defined by this object.
Returns an std::set container of strings that are the internal names defined by this object.
AttributeCrossReference & mspass::utility::AttributeCrossReference::operator= | ( | const AttributeCrossReference & | parent | ) |
void mspass::utility::AttributeCrossReference::put | ( | const std::string | intern, |
const std::string | ext | ||
) |
int mspass::utility::AttributeCrossReference::size | ( | ) | const |
MDtype mspass::utility::AttributeCrossReference::type | ( | const std::string | key | ) | const |
Get type information for attribute with internal name key.