00001 /* 00002 ** ClanLib SDK 00003 ** Copyright (c) 1997-2005 The ClanLib Team 00004 ** 00005 ** This software is provided 'as-is', without any express or implied 00006 ** warranty. In no event will the authors be held liable for any damages 00007 ** arising from the use of this software. 00008 ** 00009 ** Permission is granted to anyone to use this software for any purpose, 00010 ** including commercial applications, and to alter it and redistribute it 00011 ** freely, subject to the following restrictions: 00012 ** 00013 ** 1. The origin of this software must not be misrepresented; you must not 00014 ** claim that you wrote the original software. If you use this software 00015 ** in a product, an acknowledgment in the product documentation would be 00016 ** appreciated but is not required. 00017 ** 2. Altered source versions must be plainly marked as such, and must not be 00018 ** misrepresented as being the original software. 00019 ** 3. This notice may not be removed or altered from any source distribution. 00020 ** 00021 ** Note: Some of the libraries ClanLib link to may have additional 00022 ** requirements or restrictions. 00023 ** 00024 ** File Author(s): 00025 ** 00026 ** Magnus Norddahl 00027 */ 00028 00029 #include "precomp.h" 00030 #include "xml_token_load.h" 00031 #include "xml_token_load_generic.h" 00032 #include "xml_token_string.h" 00033 00035 // CL_XMLTokenLoad construction: 00036 00037 CL_XMLTokenLoad::CL_XMLTokenLoad() 00038 : impl(new CL_XMLTokenLoad_Generic) 00039 { 00040 } 00041 00042 CL_XMLTokenLoad::CL_XMLTokenLoad(const CL_XMLTokenLoad ©) 00043 : impl(copy.impl) 00044 { 00045 } 00046 00047 CL_XMLTokenLoad::~CL_XMLTokenLoad() 00048 { 00049 } 00050 00052 // CL_XMLTokenLoad attributes: 00053 00054 CL_XMLToken::TokenType CL_XMLTokenLoad::get_type() const 00055 { 00056 return impl->type; 00057 } 00058 00059 CL_XMLToken::TokenVariant CL_XMLTokenLoad::get_variant() const 00060 { 00061 return impl->variant; 00062 } 00063 00064 std::string CL_XMLTokenLoad::get_name() const 00065 { 00066 return impl->name.to_string(); 00067 } 00068 00069 std::string CL_XMLTokenLoad::get_value() const 00070 { 00071 return impl->value.to_string(); 00072 } 00073 00074 int CL_XMLTokenLoad::get_attributes_number() const 00075 { 00076 return impl->attributes.size(); 00077 } 00078 00079 std::pair<std::string, std::string> CL_XMLTokenLoad::get_attribute(int attribute_num) const 00080 { 00081 if (attribute_num < 0 || attribute_num >= (int)impl->attributes.size()) 00082 return std::make_pair(std::string(), std::string()); 00083 00084 std::pair<CL_XMLTokenString, CL_XMLTokenString> const & attribute = impl->attributes[attribute_num]; 00085 return std::make_pair(attribute.first.to_string(), attribute.second.to_string()); 00086 } 00087 00088 const std::pair<CL_XMLTokenString, CL_XMLTokenString> & CL_XMLTokenLoad::get_attribute_fast(int attribute_num) const 00089 { 00090 return impl->attributes[attribute_num]; 00091 } 00092 00094 // CL_XMLTokenLoad operations: 00095 00096 void CL_XMLTokenLoad::set_type(TokenType type) 00097 { 00098 impl->type = type; 00099 } 00100 00101 void CL_XMLTokenLoad::set_variant(TokenVariant variant) 00102 { 00103 impl->variant = variant; 00104 } 00105 00106 void CL_XMLTokenLoad::set_name(const CL_XMLTokenString & name) 00107 { 00108 impl->name = name; 00109 } 00110 00111 void CL_XMLTokenLoad::set_value(const CL_XMLTokenString & value) 00112 { 00113 impl->value = value; 00114 } 00115 00116 void CL_XMLTokenLoad::set_attribute(const CL_XMLTokenString & name, const CL_XMLTokenString & value) 00117 { 00118 int size = impl->attributes.size(); 00119 for (int i=0; i<size; i++) 00120 { 00121 if (impl->attributes[i].first == name) 00122 { 00123 impl->attributes[i].second = value; 00124 return; 00125 } 00126 } 00127 impl->attributes.push_back(std::make_pair(name, value)); 00128 } 00129 00131 // CL_XMLTokenLoad implementation:
1.4.1