#ifndef HV_MAP_H_ #define HV_MAP_H_ #include "hconfig.h" #include #include // MultiMap namespace std { /* int main() { std::MultiMap kvs; kvs["name"] = "hw"; kvs["filename"] = "1.jpg"; kvs["filename"] = "2.jpg"; //kvs.insert(std::pair("name", "hw")); //kvs.insert(std::pair("filename", "1.jpg")); //kvs.insert(std::pair("filename", "2.jpg")); for (auto& pair : kvs) { printf("%s:%s\n", pair.first.c_str(), pair.second.c_str()); } auto iter = kvs.find("filename"); if (iter != kvs.end()) { for (int i = 0; i < kvs.count("filename"); ++i, ++iter) { printf("%s:%s\n", iter->first.c_str(), iter->second.c_str()); } } return 0; } */ template class MultiMap : public multimap { public: Value& operator[](Key key) { auto iter = this->insert(std::pair(key,Value())); return (*iter).second; } }; } #ifdef USE_MULTIMAP #define HV_MAP std::MultiMap #else #define HV_MAP std::map #endif // KeyValue typedef std::map keyval_t; typedef std::MultiMap multi_keyval_t; namespace hv { typedef HV_MAP KeyValue; } #endif // HV_MAP_H_