Runtime

The rsc::runtime namespace contains some utility classes and functions that augment the C++ runtime towards interactive and less strict handling of data and types.

Properties

The Properties class is basically a glorified std::map<std::string, boost::any>. It therefore allows associating all kinds of objects to string keys. In addition, Properties supports printing to streams, merging property maps and some slightly more convenient handling of types. Example:

rsc::runtime::Properties props;
std::cout << "empty       " << props << std::endl;

props["key1"] = 1;
props["key2"] = 2u;
props["key3"] = 3.0;
props["key4"] = std::string("four");
std::cout << "some values " << props << std::endl;

prints
empty       p{  }
some values p{ key1: 1, key2: 2, key3: 3, key4: "four" }

Container IO

The basic idea is to provide the missing operator<< for STL containers. Example:

std::map<std::string, double> map;
map.insert(std::make_pair("a", 1.0));
map.insert(std::make_pair("b", 2.0));
map.insert(std::make_pair("c", 3.0));
std::cout << map << std::endl;

prints
{a: 1, b: 2, c: 3}

Type Strings

A thin wrapper for portably obtaining readable names of C++ types. Example:

MyBase* base = new MyDerived();
std::cout << rsc::runtime::typeName(*base) << std::endl;

prints
MyDerived