datatypes.cpp
Go to the documentation of this file.
00001 /*
00002  * datatypes.cpp
00003  *
00004  *  Created on: Jul 3, 2012
00005  *      Author: sdries
00006  */
00007 
00008 #include "wire/core/datatypes.h"
00009 
00010 namespace mhf {
00011 
00012 std::map<Attribute, std::string> AttributeConv::ATTR_TO_STR;
00013 
00014 std::map<std::string, Attribute> AttributeConv::STR_TO_ATTR;
00015 
00016 Attribute AttributeConv::attribute(const std::string& attribute_str) {
00017     std::map<std::string, Attribute>::iterator it = STR_TO_ATTR.find(attribute_str);
00018     if (it == STR_TO_ATTR.end()) {
00019         Attribute attribute_id = STR_TO_ATTR.size();
00020         STR_TO_ATTR[attribute_str] = attribute_id;
00021         ATTR_TO_STR[attribute_id] = attribute_str;
00022         return attribute_id;
00023     }
00024     return it->second;
00025 }
00026 
00027 std::string AttributeConv::attribute_str(const Attribute& attribute) {
00028     std::map<Attribute, std::string>::iterator it = ATTR_TO_STR.find(attribute);
00029     if (it == ATTR_TO_STR.end()) {
00030         return "";
00031     }
00032     return it->second;
00033 }
00034 
00035 }
00036 
00037 
00038 


wire_core
Author(s): Sjoerd van den Dries, Jos Elfring
autogenerated on Tue Jan 7 2014 11:43:19