1 #ifndef __JEEP__JPROPERTIES__ 
    2 #define __JEEP__JPROPERTIES__ 
   32 namespace JPP { 
using namespace JEEP; }
 
   57   inline bool fail(std::istream& in)
 
   59     return in.bad() || (in.fail() && !in.eof());
 
  134     virtual std::istream& 
read(std::istream& in)
 override  
  144       if (!buffer.empty()) {
 
  160     virtual std::ostream& 
write(std::ostream& out,
 
  162                                 const char    postfix)
 const override 
  174     virtual std::ostream& 
write(std::ostream& out)
 const override  
  232     virtual std::istream& 
read(std::istream& in)
 override  
  244     virtual std::ostream& 
write(std::ostream& out)
 const override  
  258     virtual std::ostream& 
write(std::ostream& out,
 
  260                                 const char    postfix)
 const override 
  326       return get()->equals(*element.
get());
 
  404       std::ostringstream os;
 
  406       get()->write(os, 
"", 
'\0');
 
  422       std::istringstream in(this->toString());
 
  436     operator const T&() 
const 
  438       return getValue<T>();
 
  498     public std::map<std::string, JPropertiesElement>,
 
  516     static inline std::string 
getKey(
const std::string& buffer, 
const std::string& sep)
 
  520       const size_type pos = buffer.find_last_of(sep);
 
  522       if (pos != string::npos)
 
  523         return buffer.substr(pos + 1);
 
  538         properties(__properties)
 
  565         std::string file_name;
 
  569         fileReader.
read(file_name);
 
  594       void read(
const std::string& file_name)
 
  596         std::ifstream in(file_name.c_str());
 
  636                 const int debug = 0) :
 
  651     void put(
const std::string& key, T& 
object)
 
  667       insert(properties.begin(), properties.end());
 
  685       DEBUG(
"Processing key: " << equation.
getKey() << 
' ' << (p != end()) << endl);
 
  689         istringstream is(equation.
getValue());
 
  693           if (p->second->is_properties()) {
 
  699             ERROR(
"JProperties::read(): no properties object after division <" << equation.
getKey() << 
">" << endl);
 
  707           catch(
const exception& error) {
 
  708             ERROR(
"JProperties::read(): read error at key <" << equation.
getKey() << 
"> " << error.what() << endl);
 
  713           ERROR(
"JProperties::read(): illegal character following key <" << equation.
getKey() << 
"> " << equation.
getSeparator() << endl);
 
  716         if (p->second.getEndMarker()) {
 
  722           ERROR(
"JProperties::read(): error reading data for key <" << equation.
getKey() << 
"> " << equation.
getValue() << endl);
 
  727         WARNING(
"JProperties::read(): unknown key <" << equation.
getKey() << 
">" << endl);
 
  740     bool read(
const std::string& buffer) 
 
  742       std::istringstream in(buffer); 
 
  762     std::istream& 
read(std::istream& in)
 
  768       for (
JEquation equation; in >> equation && 
read(equation); ) {}
 
  784     std::istream& 
read(std::istream& in, 
const std::string& format) 
 
  788       istringstream is(format);
 
  792       for (
string key; is >> key; ) {
 
  793         buffer.push_back(key);
 
  796       return read(in, buffer.begin(), buffer.end());
 
  812     std::istream& 
read(std::istream& in, T __begin, T __end)
 
  816       for (T i = __begin; i != __end; ++i) {
 
  826           WARNING(
"JProperties::read(): unknown key <" << *i << 
">" << endl);
 
  847     std::ostream& 
write(std::ostream& out)
 const 
  851       for (const_iterator i = begin(); i != end(); ++i) {
 
  855         if (i->second->is_properties()) {
 
  856           c = getDefaultDivision ();
 
  858           c = getDefaultSeparator();
 
  861         i->second->write(out, (i->first + c).c_str(), getDefaultEndOfLine());
 
  880     std::ostream& 
write(std::ostream& out, 
const std::string& format) 
 
  884       istringstream is(format);
 
  888       for (
string key; is >> key; ) {
 
  889         buffer.push_back(key);
 
  892       return write(out, buffer.begin(), buffer.end());
 
  908     std::ostream& 
write(std::ostream& out, T __begin, T __end)
 
  912       for (T i = __begin; i != __end; ++i) {
 
  918           out << getDefaultWhiteSpace();
 
  920           p->second->write(out);
 
  924           WARNING(
"JProperties::write(): unknown key <" << *i << 
">" << endl);
 
  943     std::string 
sed(
const std::string& format,
 
  944                     const std::string& prefix  = 
"", 
 
  945                     const std::string& postfix = 
"")
 
  949       string buffer = format;
 
  951       for (
iterator i = begin(); i != end(); ++i) {
 
  953         string::size_type ipos = 0;
 
  955         while ((ipos = buffer.find(prefix + i->first + postfix, ipos)) != string::npos) {
 
  959           i->second->write(out);
 
  961           buffer.replace(ipos, prefix.length() + i->first.length() + postfix.length(), out.str());
 
  978       const_iterator i = find(key);
 
  981         return i->second.getValue<T>();
 
  999         return i->second.getValue<T>();
 
 1017         return i->second.setValue<T>(value);
 
 1031       const_iterator i = find(key);
 
 1034         return i->second.toString();
 
 1046     std::ostream& 
print(std::ostream& out)
 const 
 1063       return properties.
read(in); 
 
 1076       return properties.
write(out); 
 
 1107     virtual std::istream& 
read(std::istream& in)
 override  
 1121     virtual std::ostream& 
write(std::ostream& out, 
 
 1123                                 const char    postfix)
 const override 
 1135     virtual std::ostream& 
write(std::ostream& out)
 const override  
 1182     virtual std::istream& 
read(std::istream& in)
 override  
 1198     virtual std::ostream& 
write(std::ostream& out, 
 
 1200                                 const char    postfix)
 const override 
 1202       using namespace std;
 
 1204       for (JProperties::const_iterator i = 
object.begin(); i != 
object.end(); ++i) {
 
 1208         if (i->second->is_properties()) {
 
 1209           c = 
object.getDefaultDivision ();
 
 1211           c = 
object.getDefaultSeparator();
 
 1214         i->second->write(out, (prefix + i->first + c).c_str(), postfix);
 
 1229     virtual std::ostream& 
write(std::ostream& out)
 const override  
 1271                                     const int debug = 1)
 
 1273     using namespace JPP;
 
 1277     properties = T::template getProperties<JClass<T>::is_constant>(
object, parameters, 
debug);
 
 1293 #define gmake_property(A) JProperties::value_type(JProperties::getKey(#A,".>/:"), JEEP::JPropertiesElement(A))
 
 1294 #define zmake_property(A) JProperties::value_type(#A,                             JEEP::JPropertiesElement(A)) 
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
 
General purpose messaging.
 
#define DEBUG(A)
Message macros.
 
Interface for I/O of properties element.
 
virtual bool is_properties() const
Get properties type.
 
virtual bool equals(const JPropertiesElementInterface &element) const
Equality between property element interfaces.
 
virtual std::ostream & write(std::ostream &out) const=0
Stream output.
 
The property value class.
 
void setEndMarker(const bool marker)
Set end marker.
 
JPropertiesElement(T &value)
Constructor.
 
void setValue(const T &value)
Set value of this JPropertiesElement.
 
bool getEndMarker() const
Get end marker.
 
JPropertiesElement & operator=(T &value)
Assignment operator.
 
JPropertiesElement()
Default constructor.
 
const T & getValue() const
Get value.
 
T toValue() const
Convert to template type.
 
std::string toString() const
Convert to string.
 
bool equals(const JPropertiesElement &element) const
Equality between property elements.
 
virtual std::ostream & write(std::ostream &out) const override
Stream output.
 
virtual std::istream & read(std::istream &in) override
Stream input.
 
JPropertiesTemplateElement(const JProperties &value)
Constructor.
 
virtual bool is_properties() const override
Get properties type.
 
virtual std::ostream & write(std::ostream &out, const char *prefix, const char postfix) const override
Stream output.
 
virtual bool equals(const JPropertiesElementInterface &element) const override
Equality between property element interfaces.
 
virtual std::ostream & write(std::ostream &out, const char *prefix, const char postfix) const override
Stream output.
 
JPropertiesTemplateElement(JProperties::JFileReader &value)
Constructor.
 
virtual std::ostream & write(std::ostream &out) const override
Stream output.
 
virtual std::istream & read(std::istream &in) override
Stream input.
 
JProperties::JFileReader & object
 
Template specialisation of JPropertiesTemplateElement for const data type.
 
virtual std::ostream & write(std::ostream &out, const char *prefix, const char postfix) const override
Stream output.
 
virtual std::ostream & write(std::ostream &out) const override
Stream output.
 
JPropertiesTemplateElement(const T &value)
Constructor.
 
virtual std::istream & read(std::istream &in) override
Stream input.
 
virtual bool equals(const JPropertiesElementInterface &element) const override
Equality between property element interfaces.
 
Template class for I/O of properties element.
 
virtual std::ostream & write(std::ostream &out, const char *prefix, const char postfix) const override
Stream output.
 
friend class JPropertiesElement
 
virtual std::istream & read(std::istream &in) override
Stream input.
 
JPropertiesTemplateElement(T &value)
Constructor.
 
virtual bool equals(const JPropertiesElementInterface &element) const override
Equality between property element interfaces.
 
virtual std::ostream & write(std::ostream &out) const override
Stream output.
 
Auxiliary class to handle input from file.
 
friend std::istream & operator>>(std::istream &in, JProperties::JFileReader &fileReader)
Stream input.
 
friend std::ostream & operator<<(std::ostream &out, const JProperties::JFileReader &fileReader)
Stream output.
 
JFileReader & operator=(const std::string &file_name)
Assignment operator.
 
void read(const std::string &file_name)
Read properties from file.
 
JFileReader(JProperties &__properties)
 
Utility class to parse parameter values.
 
bool read(const std::string &buffer)
Read from input string.
 
std::ostream & print(std::ostream &out) const
Print the current parameter values.
 
std::string getString(const std::string &key) const
Get string value.
 
std::istream & read(std::istream &in, const std::string &format)
Read from input stream according given format.
 
static std::string getKey(const std::string &buffer, const std::string &sep)
Utility method to strip off all leading characters from a string until specified character(s).
 
T & getValue(const std::string &key)
Get value.
 
friend std::ostream & operator<<(std::ostream &out, const JProperties &properties)
Stream output.
 
std::istream & read(std::istream &in, T __begin, T __end)
Read from input stream according given format.
 
JProperties & join(const JProperties &properties)
Join properties objects.
 
void setValue(const std::string &key, const T &value)
Set value.
 
std::ostream & write(std::ostream &out, const std::string &format)
Write to output stream according given format.
 
std::ostream & write(std::ostream &out) const
Write the current parameter values.
 
std::map< std::string, JPropertiesElement > JMap_t
 
std::istream & read(std::istream &in)
Read from input stream.
 
std::ostream & write(std::ostream &out, T __begin, T __end)
Write to output stream according given format.
 
JProperties(const int debug=0)
Constructor.
 
const T & getValue(const std::string &key) const
Get value.
 
JProperties(const JEquationParameters ¶meters, const int debug=0)
Constructor.
 
std::string sed(const std::string &format, const std::string &prefix="", const std::string &postfix="")
Stream editing of input format.
 
bool read(const JEquation &equation)
Read equation.
 
friend std::istream & operator>>(std::istream &in, JProperties &properties)
Stream input.
 
void put(const std::string &key, T &object)
Put object at given key.
 
Facet class to specify parsing of equations in currect locale (see class JLANG::JEquation).
 
Simple data structure to support I/O of equations (see class JLANG::JEquation).
 
JEquationParameters & join(const JEquationParameters &value)
Join equation parameters.
 
General purpose equation class.
 
const std::string & getKey() const
Get key.
 
const std::string & getValue() const
Get value.
 
const char getSeparator() const
Get separator.
 
Exception for opening of file.
 
Exception for reading of file.
 
Template definition of test availability of comparison operators.
 
virtual JClass_t * get() const override
Get pointer.
 
Exception when parsing a value.
 
The template JSharedPointer class can be used to share a pointer to an object.
 
Interface for ASCII output using standard streams.
 
virtual std::ostream & write(std::ostream &out) const =0
Stream output.
 
Interface for ASCII output with prefix and postfix using standard streams.
 
virtual std::ostream & write(std::ostream &out, const char *prefix, const char postfix) const =0
Stream output.
 
General puprpose classes and methods.
 
std::ostream & writeObject(std::ostream &out, const T &object)
Stream output of object.
 
bool fail(std::istream &in)
Check for stream state.
 
JProperties & getProperties(T &object, const JEquationParameters ¶meters=JEquationParameters(), const int debug=1)
Get properties of a given object.
 
std::istream & readObject(std::istream &in, T &object)
Stream input of object.
 
bool compareObjects(const T &first, const T &second, JBool< true >)
Comparison of comparable objects.
 
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
 
Auxiliary class for handling debug parameter within a class.
 
Auxiliary class to define value, reference and pointer types for given data type and category.