DD4hep - The AIDA detector description toolkit for high energy physics experiments
DD4hep  Rev:Unversioneddirectory
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
BasicGrammar.h
Go to the documentation of this file.
1 //==========================================================================
2 // AIDA Detector description implementation for LCD
3 //--------------------------------------------------------------------------
4 // Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
5 // All rights reserved.
6 //
7 // For the licensing terms see $DD4hepINSTALL/LICENSE.
8 // For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
9 //
10 // Author : M.Frank
11 //
12 //==========================================================================
13 #ifndef DD4HEP_DDG4_BASICGRAMMAR_H
14 #define DD4HEP_DDG4_BASICGRAMMAR_H
15 
16 // C/C++ include files
17 #include <string>
18 #include <typeinfo>
19 
21 namespace DD4hep {
22 
24 
37  class BasicGrammar {
38  public:
40  BasicGrammar();
42  virtual ~BasicGrammar();
43 
45  template <typename TYPE> static const BasicGrammar& instance();
47  static void invalidConversion(const std::type_info& from, const std::type_info& to);
49  static void invalidConversion(const std::string& value, const std::type_info& to);
51  virtual const std::type_info& type() const = 0;
53  virtual const std::string& type_name() const = 0;
55  virtual size_t sizeOf() const = 0;
57  virtual std::string str(const void* ptr) const = 0;
59  virtual bool fromString(void* ptr, const std::string& value) const = 0;
60  };
61 } // End namespace DD4hep
62 
63 #endif /* DD4HEP_DDG4_BASICGRAMMAR_H */
virtual const std::string & type_name() const =0
Access to the type information name.
virtual const std::type_info & type() const =0
Access to the type information.
virtual std::string str(const void *ptr) const =0
Serialize an opaque value to a string.
Base class describing string evaluation to C++ objects using boost::spirit.
Definition: BasicGrammar.h:37
static const BasicGrammar & instance()
Instance factory.
static void invalidConversion(const std::type_info &from, const std::type_info &to)
Error callback on invalid conversion.
virtual size_t sizeOf() const =0
Access the object size (sizeof operator)
virtual ~BasicGrammar()
Default destructor.
virtual bool fromString(void *ptr, const std::string &value) const =0
Set value from serialized string. On successful data conversion TRUE is returned. ...
BasicGrammar()
Default constructor.