MongoType
MongoDB Collection Data Dump with BSON Types
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
BSONTypeMap.hpp
Go to the documentation of this file.
1 
28 #ifndef BSONTYPEMAP_HPP_
29 #define BSONTYPEMAP_HPP_
30 
31 namespace mongotype {
32 
33 //----------------------------------------------------------------------------
34 
47  string name;
51  string description;
52 
53 public:
57  BSONTypeElement(const char* pname = "", const char* pdescription = "") :
58  name(pname), description(pdescription) {
59  }
60 
65  const string& getName() const {
66  return name;
67  }
68 
73  const string& getDesc() const {
74  return description;
75  }
76 };
77 
81 typedef map<BSONType, const BSONTypeElement> BSONTypeStringsMap;
85 typedef BSONTypeStringsMap::value_type BSONTypeStringsMapPair;
86 
87 //----------------------------------------------------------------------------
88 
95 class BSONTypeMap {
96 
97 protected:
101  const BSONElement& element;
102 
103 public:
104 
109  BSONTypeMap(const BSONElement& e) :
110  element(e) {
111  }
112 
116  const BSONTypeElement& lookup(BSONType type);
117 
122  return lookup(element.type());
123  }
124 
129  string to_string() {
130  const BSONTypeElement& bsts = lookup();
131  string s("(");
132  s += bsts.getName();
133  s += "/";
134  s += bsts.getDesc();
135  s += ")";
136  return s;
137  }
138 
144  return out << bstn.to_string();
145  }
146 };
147 
148 //----------------------------------------------------------------------------
149 
150 } /* namespace mongotype */
151 #endif /* BSONTYPEMAP_HPP_ */