Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include <string>
00016
00017
00018 #include "DataFormats/FWLite/interface/format_type_name.h"
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 static const std::string s_symbolToMangled[] = {"::", "_1",
00030 "_" , "_2",
00031 "," , "_3",
00032 " " , "_4",
00033 "&" , "_7",
00034 "*" , "_8",
00035 "<" , "_9",
00036 ">" , "_0"
00037 };
00038 static const unsigned int s_symbolToMangledSize = sizeof(s_symbolToMangled)/sizeof(std::string);
00039 namespace fwlite {
00040
00042 std::string format_type_to_mangled(const std::string& iType) {
00043 std::string returnValue;
00044 returnValue.append(static_cast<std::string::size_type>(iType.size()*2),' ');
00045 std::string::size_type fromIndex=0;
00046 std::string::size_type toIndex=0;
00047 unsigned int sIndex=0;
00048 for(;fromIndex<iType.size();++fromIndex) {
00049 bool foundMatch = false;
00050 for(sIndex=0;sIndex<s_symbolToMangledSize;) {
00051 const std::string& symbol = s_symbolToMangled[sIndex];
00052 if(iType.substr(fromIndex,symbol.size())==symbol) {
00053 foundMatch = true;
00054 break;
00055 }
00056 ++sIndex;
00057 ++sIndex;
00058 }
00059 if(!foundMatch) {
00060 returnValue[toIndex]=iType[fromIndex];
00061 ++toIndex;
00062 } else {
00063 const std::string& mangled=s_symbolToMangled[sIndex+1];
00064 returnValue.replace(toIndex,mangled.size(),mangled);
00065 toIndex += mangled.size();
00066 fromIndex += s_symbolToMangled[sIndex].size()-1;
00067 }
00068 }
00069 returnValue.resize(toIndex);
00070 return returnValue;
00071 }
00072
00074 std::string unformat_mangled_to_type(const std::string& iMangled) {
00075 std::string returnValue;
00076 returnValue.append(static_cast<std::string::size_type>(iMangled.size()*2),' ');
00077 std::string::size_type fromIndex=0;
00078 std::string::size_type toIndex=0;
00079 unsigned int sIndex=0;
00080 for(;fromIndex<iMangled.size();++fromIndex) {
00081 bool foundMatch = false;
00082 for(sIndex=0;sIndex<s_symbolToMangledSize;) {
00083 const std::string& mangled = s_symbolToMangled[sIndex+1];
00084 if(iMangled.substr(fromIndex,mangled.size())==mangled) {
00085 foundMatch = true;
00086 break;
00087 }
00088 ++sIndex;
00089 ++sIndex;
00090 }
00091 if(!foundMatch) {
00092 returnValue[toIndex]=iMangled[fromIndex];
00093 ++toIndex;
00094 } else {
00095 const std::string& symbol=s_symbolToMangled[sIndex];
00096 returnValue.replace(toIndex,symbol.size(),symbol);
00097 toIndex += symbol.size();
00098 fromIndex += s_symbolToMangled[sIndex+1].size()-1;
00099 }
00100 }
00101 returnValue.resize(toIndex);
00102 return returnValue;
00103 }
00104
00105 }