3#include "mspass/utility/BasicMetadata.h"
4#include "mspass/utility/MsPASSError.h"
5#include <boost/any.hpp>
10#include <pybind11/pybind11.h>
31 std::string pretty_name(boost::core::demangle(Texpected));
32 ss <<
"Error trying to extract Metadata with key=" << key << std::endl
33 <<
"No value associated with this key is set in Metadata object"
35 <<
"Expected an entry of type=" << pretty_name << std::endl;
37 badness = ErrorSeverity::Suspect;
46 const char *Texpected,
const char *Tactual) {
47 ss <<
"Error in Metadata get method. Type mismatch in attem to get "
48 <<
"data with key=" << key << std::endl
49 <<
"boost::any bad_any_cast wrote this message: " << std::endl
50 << boostmessage << std::endl;
51 std::string name_e(boost::core::demangle(Texpected));
52 ss <<
"Trying to convert to data of type=" << name_e << std::endl;
53 std::string name_a(boost::core::demangle(Tactual));
54 ss <<
"Actual entry has type=" << name_a << std::endl;
56 badness = ErrorSeverity::Suspect;
62 MetadataGetError operator=(
const MetadataGetError &parent) {
63 if (
this != &parent) {
89 Metadata(std::ifstream &ifs,
const std::string form = std::string(
"pf"));
163 return static_cast<int>(
lval);
185 return static_cast<long>(
ival);
243 template <
typename T>
T get(
const std::string
key)
const;
258 template <
typename T>
T get(
const char *
key)
const {
278 std::map<std::string, boost::any>::const_iterator
iptr;
280 if (
iptr == md.end()) {
285 std::string type(
const std::string
key)
const;
286 template <
typename T>
void put(
const std::string
key,
T val)
noexcept {
289 changed_or_set.insert(
key);
291 template <
typename T>
void put(
const char *
key,
T val)
noexcept {
297 changed_or_set.insert(std::string(
key));
299 void put(
const std::string
key,
const double val)
override {
302 void put(
const std::string
key,
const int val)
override {
305 void put(
const std::string
key,
const bool val)
override {
308 void put(
const std::string
key,
const std::string
val)
override {
319 void put(std::string
key,
const char *
val) { this->put(
key.c_str(),
val); }
320 void put_object(
const std::string
key,
const pybind11::object
val) {
323 void put_int(
const std::string
key,
const int val) {
326 void put_string(
const std::string
key,
const std::string
val) {
329 void put_bool(
const std::string
key,
const bool val) {
332 void put_double(
const std::string
key,
const double val) {
335 void put_long(
const std::string
key,
const long val) {
362 const std::string
separator = std::string(
":"));
365 std::set<std::string>
modified()
const {
return changed_or_set; };
443 std::
set<std::
string> changed_or_set;
447 std::map<std::string, boost::any>::const_iterator
iptr;
449 if (
iptr == md.end()) {
454 result = boost::any_cast<T>(
aval);
455 }
catch (boost::bad_any_cast &
err) {
456 const std::type_info &
ti =
aval.type();
470std::string demangled_name(
const boost::any
val);
506typedef std::list<Metadata_typedef> MetadataList;
533 const MetadataList &
mdlist);
555std::string serialize_metadata(
const Metadata &md);
567Metadata restore_serialized_metadata(
const std::string);
Base class for error object thrown by MsPASS library routines.
Definition MsPASSError.h:38
MsPASSError()
Definition MsPASSError.h:43
std::string message
Definition MsPASSError.h:108
ErrorSeverity badness
Definition MsPASSError.h:110