CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CodedException.h
Go to the documentation of this file.
1 #ifndef Utilities_CodedException_h
2 #define Utilities_CodedException_h
3 
14 
15 #include <string>
16 #include <map>
17 
18 #define EDM_MAP_ENTRY(map, ns, name) map[ns::name]=#name
19 #define EDM_MAP_ENTRY_NONS(map, name) map[name]=#name
20 
21 namespace edm {
22  template <class Code>
24  {
25  public:
26  explicit CodedException(Code category);
27 
28  CodedException(Code category,
29  const std::string& message);
30 
31  CodedException(Code category,
32  const std::string& message,
33  const cms::Exception& another);
34 
35  CodedException(const CodedException& other);
36 
37  virtual ~CodedException() throw();
38 
39  Code categoryCode() const { return category_; }
40 
41  int returnCode() const { return static_cast<int>(category_); }
42 
43  static std::string codeToString(Code);
44 
45  typedef std::map<Code,std::string> CodeMap;
46  private:
47 
48  Code category_;
49  };
50 
51 
53 
54 #if 0
55  template <class Code>
57 #endif
58 
59  template <class Code>
61  {
62  extern void getCodeTable(CodeMap*&);
63  CodeMap* trans;
64  getCodeTable(trans);
65  typename CodeMap::const_iterator i(trans->find(c));
66  return i!=trans->end() ? i->second : std::string("UnknownCode");
67  }
68 
69 
70  template <class Code>
72  cms::Exception(codeToString(aCategory)),
73  category_(aCategory)
74  {
75  }
76 
77  template <class Code>
79  const std::string& message):
80  cms::Exception(codeToString(aCategory),message),
81  category_(aCategory)
82  {
83  }
84 
85  template <class Code>
87  const std::string& message,
88  const cms::Exception& another):
89  cms::Exception(codeToString(aCategory),message,another),
90  category_(aCategory)
91  {
92  }
93 
94  template <class Code>
96  cms::Exception(other),
97  category_(other.category_)
98  {
99  }
100 
101  template <class Code>
103  {
104  }
105 
106 }
107 
108 #endif
int i
Definition: DBlmapReader.cc:9
static std::string codeToString(Code)
-----------— implementation details ---------------—
CodedException(Code category)
Code categoryCode() const
string message
Definition: argparse.py:126
std::map< Code, std::string > CodeMap
int returnCode() const
void getCodeTable(edm::Exception::CodeMap *&setme)
Definition: EDMException.cc:40
std::string category() const
Definition: Exception.cc:74