2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 * @file config_parser_data.cpp
18 * @author Lukasz Wrzosek (l.wrzosek@samsung.com)
22 #include <dpl/wrt-dao-ro/config_parser_data.h>
23 #include <dpl/log/log.h>
24 #include <libxml/xmlreader.h>
25 #include <libxml/xmlstring.h>
28 bool IsSpace(const xmlChar* str);
29 bool CopyChar(xmlChar* out, xmlChar* in);
32 bool IsSpace(const xmlChar* str)
34 int charlen = xmlUTF8Size(str);
65 unsigned char c2 = *(str + 1);
66 unsigned char c3 = *(str + 2);
67 if ((c2 == 0x9a && c3 == 0x80) || (c2 == 0xa0 && c3 == 0x8e)) {
97 if (*(str + 2) == 0x9f) {
107 if (*(str + 1) == 0x80 && *(str + 2) == 0x80) {
122 bool CopyChar(xmlChar* out,
125 int size = xmlUTF8Size(in);
146 //TODO temporary fix until commits the rewrite of this functionality.
147 void NormalizeString(DPL::String& str)
149 DPL::Optional<DPL::String> opt = str;
150 NormalizeString(opt);
154 void NormalizeString (DPL::Optional<DPL::String>& txt)
157 std::string tmp = DPL::ToUTF8String(*txt);
158 const xmlChar* str = reinterpret_cast<const xmlChar*>(tmp.c_str());
159 if (!xmlCheckUTF8(str)) {
160 LogError("Not valid UTF8");
166 while ((c = const_cast<xmlChar*>(xmlUTF8Strpos(str, i))) != NULL) {
173 xmlChar* tmpnew = xmlUTF8Strndup(c, xmlUTF8Strlen(c) + 1);
176 while ((c = const_cast<xmlChar*>(xmlUTF8Strpos(str, i))) != NULL) {
185 xmlChar space[6] = { 0x20 };
196 txt = DPL::FromUTF8String(reinterpret_cast<char*>(tmpnew));
201 bool ConfigParserData::Param::operator==(const Param& other) const
203 return name == other.name && value == other.value;
206 bool ConfigParserData::Param::operator!=(const Param& other) const
208 return name != other.name || value != other.value;
211 bool ConfigParserData::Param::operator >(const Param& other) const
213 if (name == other.name) {
214 return value > other.value;
216 return name > other.name;
220 bool ConfigParserData::Param::operator>=(const Param& other) const
222 if (name >= other.name) {
225 return value >= other.value;
229 bool ConfigParserData::Param::operator <(const Param& other) const
231 if (name == other.name) {
232 return value < other.value;
234 return name < other.name;
238 bool ConfigParserData::Param::operator<=(const Param& other) const
240 if (name <= other.name) {
243 return value <= other.value;
247 bool ConfigParserData::Feature::operator==(const Feature& other) const
249 return name == other.name && paramsList == other.paramsList;
252 bool ConfigParserData::Feature::operator!=(const Feature& other) const
254 return name != other.name || paramsList != other.paramsList;
257 bool ConfigParserData::Feature::operator >(const Feature& other) const
259 if (name > other.name) {
262 if (name < other.name) {
265 return paramsList > other.paramsList;
268 bool ConfigParserData::Feature::operator>=(const Feature& other) const
270 if (name > other.name) {
273 if (name < other.name) {
276 return paramsList >= other.paramsList;
279 bool ConfigParserData::Feature::operator <(const Feature& other) const
281 if (name < other.name) {
284 if (name > other.name) {
287 return paramsList < other.paramsList;
290 bool ConfigParserData::Feature::operator<=(const Feature& other) const
292 if (name < other.name) {
295 if (name > other.name) {
298 return paramsList <= other.paramsList;
301 bool ConfigParserData::Icon::operator==(const Icon& other) const
303 return src == other.src;
306 bool ConfigParserData::Icon::operator!=(const Icon& other) const
308 return src != other.src;
311 bool ConfigParserData::Icon::operator >(const Icon& other) const
313 return src > other.src;
316 bool ConfigParserData::Icon::operator>=(const Icon& other) const
318 return src >= other.src;
321 bool ConfigParserData::Icon::operator <(const Icon& other) const
323 return src < other.src;
326 bool ConfigParserData::Icon::operator<=(const Icon& other) const
328 return src <= other.src;
331 bool ConfigParserData::Preference::operator==(const Preference& other) const
333 return name == other.name;
336 bool ConfigParserData::Preference::operator!=(const Preference& other) const
338 return name != other.name;
341 bool ConfigParserData::Preference::operator >(const Preference& other) const
343 return name > other.name;
346 bool ConfigParserData::Preference::operator>=(const Preference& other) const
348 return name >= other.name;
351 bool ConfigParserData::Preference::operator <(const Preference& other) const
353 return name < other.name;
356 bool ConfigParserData::Preference::operator<=(const Preference& other) const
358 return name <= other.name;
361 bool ConfigParserData::AccessInfo::operator== (const AccessInfo& info) const
363 return m_strIRI == info.m_strIRI && m_bSubDomainAccess ==
364 info.m_bSubDomainAccess;
367 bool ConfigParserData::AccessInfo::operator!= (const AccessInfo& info) const
369 return m_strIRI != info.m_strIRI || m_bSubDomainAccess !=
370 info.m_bSubDomainAccess;
373 bool ConfigParserData::AccessInfo::operator <(const AccessInfo& info) const
375 if (m_strIRI == info.m_strIRI) {
376 return m_bSubDomainAccess < info.m_bSubDomainAccess;
378 return m_strIRI < info.m_strIRI;
382 bool ConfigParserData::Setting::operator==(const Setting& other) const
384 return m_name == other.m_name &&
385 m_value == other.m_value;
388 bool ConfigParserData::Setting::operator!=(const Setting& other) const
390 return m_name != other.m_name ||
391 m_value != other.m_value;
394 bool ConfigParserData::Setting::operator >(const Setting& other) const
396 return m_name > other.m_name;
399 bool ConfigParserData::Setting::operator>=(const Setting& other) const
401 return m_name >= other.m_name;
404 bool ConfigParserData::Setting::operator <(const Setting& other) const
406 return m_name < other.m_name;
409 bool ConfigParserData::Setting::operator<=(const Setting& other) const
411 return m_name <= other.m_name;
414 bool ConfigParserData::ServiceInfo::operator== (const ServiceInfo& info) const
416 return m_src == info.m_src &&
417 m_operation == info.m_operation &&
418 m_scheme == info.m_scheme &&
419 m_mime == info.m_mime;
422 bool ConfigParserData::ServiceInfo::operator!= (const ServiceInfo& info) const
424 return m_src != info.m_src &&
425 m_operation != info.m_operation &&
426 m_scheme != info.m_scheme &&
427 m_mime != info.m_mime;