Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JSTDToolkit.hh
Go to the documentation of this file.
1 #ifndef __JLANG__JSTDTOOLKIT__
2 #define __JLANG__JSTDTOOLKIT__
3 
4 #include "JLang/JSTDTypes.hh"
6 #include "JLang/JException.hh"
7 
8 
9 /**
10  * \author mdejong
11  */
12 
13 /**
14  * Auxiliary classes and methods for STD containers.
15  */
16 namespace JLANG {}
17 namespace JPP { using namespace JLANG; }
18 
19 namespace JLANG {
20 
21  /**
22  * Get value in map.
23  *
24  * Note that this method throws an exception if the given key is absent.
25  *
26  * \param map map
27  * \param key key
28  * \return value
29  */
30  template<class JKey_t, class JValue_t, class JComparator_t, class JAllocator_t>
31  inline const JValue_t& get_key(const std::map<JKey_t, JValue_t, JComparator_t, JAllocator_t>& map, const JKey_t key)
32  {
34 
35  if (i != map.end()) {
36 
37  return i->second;
38 
39  } else {
40 
41  THROW(JTypeInformationException, "Invalid key <" << STREAM("?") << key << ">");
42  }
43  }
44 }
45 
46 #endif
Exception for absence of type information.
Definition: JException.hh:612
Exceptions.
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:670
Auxiliary data structure for handling std::ostream.
Forward declarations of STD containers.
const char * map
Definition: elog.cc:87
const JValue_t & get_key(const std::map< JKey_t, JValue_t, JComparator_t, JAllocator_t > &map, const JKey_t key)
Get value in map.
Definition: JSTDToolkit.hh:31