MBSim

Project Page
xmlnamespacemapping.h
00001 /* Copyright (C) 2004-2010 MBSim Development Team
00002  *
00003  * This library is free software; you can redistribute it and/or 
00004  * modify it under the terms of the GNU Lesser General Public 
00005  * License as published by the Free Software Foundation; either 
00006  * version 2.1 of the License, or (at your option) any later version. 
00007  *  
00008  * This library is distributed in the hope that it will be useful, 
00009  * but WITHOUT ANY WARRANTY; without even the implied warranty of 
00010  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
00011  * Lesser General Public License for more details. 
00012  *  
00013  * You should have received a copy of the GNU Lesser General Public 
00014  * License along with this library; if not, write to the Free Software 
00015  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
00016  *
00017  * Contact: friedrich.at.gc@googlemail.com
00018  */
00019 
00020 #ifndef _MBSIM_XMLNAMESPACEMAPPING_H_
00021 #define _MBSIM_XMLNAMESPACEMAPPING_H_
00022 
00023 #include <string>
00024 #include <map>
00025 
00026 namespace MBSim {
00027 
00029 class XMLNamespaceMapping {
00030   public:
00031 
00032     typedef std::map<std::string, std::string> M_NSPRE;
00033 
00035     static M_NSPRE getNamespacePrefixMapping();
00036 
00038     static void registerXMLNamespaceMapping(double priority, const std::string &ns, const std::string &prefix);
00039 
00040   private:
00041 
00042     typedef std::pair<std::string, std::string> P_NSPRE;
00043     typedef std::multimap<double, P_NSPRE> MM_PRINSPRE;
00044     typedef std::pair<double, P_NSPRE> P_PRINSPRE;
00045 
00046     XMLNamespaceMapping() {}
00047 
00048     static XMLNamespaceMapping &instance();
00049 
00050     MM_PRINSPRE priorityNSPrefix;
00051 };
00052 
00055 class RegisterXMLNamespaceMapping {
00056   public:
00057 
00058     RegisterXMLNamespaceMapping(double priority, const std::string &ns, const std::string &prefix);
00059 
00060 };
00061 
00062 #define MBSIM_XMLNAMESPACEMAPPING_CONCAT1(X, Y) X##Y
00063 #define MBSIM_XMLNAMESPACEMAPPING_CONCAT(X, Y) MBSIM_XMLNAMESPACEMAPPING_CONCAT1(X, Y)
00064 #define MBSIM_XMLNAMESPACEMAPPING_APPENDLINE(X) MBSIM_XMLNAMESPACEMAPPING_CONCAT(X, __LINE__)
00065 
00067 #define MBSIM_REGISTER_XMLNAMESPACEMAPPING(priority, ns, prefix) \
00068   static MBSim::RegisterXMLNamespaceMapping \
00069     MBSIM_XMLNAMESPACEMAPPING_APPENDLINE(registerXMLNamespaceMappingDummyVariable)(priority, ns, prefix);
00070 
00071 }
00072 
00073 #endif