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)
23 #include <dpl/wrt-dao-ro/config_parser_data.h>
24 #include <dpl/log/log.h>
25 #include <libxml/xmlreader.h>
26 #include <libxml/xmlstring.h>
29 bool IsSpace(const xmlChar* str);
30 bool CopyChar(xmlChar* out, xmlChar* in);
33 bool IsSpace(const xmlChar* str)
35 int charlen = xmlUTF8Size(str);
66 unsigned char c2 = *(str + 1);
67 unsigned char c3 = *(str + 2);
68 if ((c2 == 0x9a && c3 == 0x80) || (c2 == 0xa0 && c3 == 0x8e)) {
98 if (*(str + 2) == 0x9f) {
108 if (*(str + 1) == 0x80 && *(str + 2) == 0x80) {
123 bool CopyChar(xmlChar* out,
126 int size = xmlUTF8Size(in);
147 //TODO temporary fix until commits the rewrite of this functionality.
148 void NormalizeString(DPL::String& str)
150 DPL::Optional<DPL::String> opt = str;
151 NormalizeString(opt);
155 void NormalizeString (DPL::Optional<DPL::String>& txt)
158 std::string tmp = DPL::ToUTF8String(*txt);
159 const xmlChar* str = reinterpret_cast<const xmlChar*>(tmp.c_str());
160 if (!xmlCheckUTF8(str)) {
161 LogError("Not valid UTF8");
167 while ((c = const_cast<xmlChar*>(xmlUTF8Strpos(str, i))) != NULL) {
174 xmlChar* tmpnew = xmlUTF8Strndup(c, xmlUTF8Strlen(c) + 1);
177 while ((c = const_cast<xmlChar*>(xmlUTF8Strpos(str, i))) != NULL) {
186 xmlChar space[6] = { 0x20 };
197 txt = DPL::FromUTF8String(reinterpret_cast<char*>(tmpnew));
202 bool ConfigParserData::Param::operator==(const Param& other) const
204 return name == other.name && value == other.value;
207 bool ConfigParserData::Param::operator!=(const Param& other) const
209 return name != other.name || value != other.value;
212 bool ConfigParserData::Param::operator >(const Param& other) const
214 if (name == other.name) {
215 return value > other.value;
217 return name > other.name;
221 bool ConfigParserData::Param::operator>=(const Param& other) const
223 if (name >= other.name) {
226 return value >= other.value;
230 bool ConfigParserData::Param::operator <(const Param& other) const
232 if (name == other.name) {
233 return value < other.value;
235 return name < other.name;
239 bool ConfigParserData::Param::operator<=(const Param& other) const
241 if (name <= other.name) {
244 return value <= other.value;
248 bool ConfigParserData::Feature::operator==(const Feature& other) const
250 return name == other.name && paramsList == other.paramsList;
253 bool ConfigParserData::Feature::operator!=(const Feature& other) const
255 return name != other.name || paramsList != other.paramsList;
258 bool ConfigParserData::Feature::operator >(const Feature& other) const
260 if (name > other.name) {
263 if (name < other.name) {
266 return paramsList > other.paramsList;
269 bool ConfigParserData::Feature::operator>=(const Feature& other) const
271 if (name > other.name) {
274 if (name < other.name) {
277 return paramsList >= other.paramsList;
280 bool ConfigParserData::Feature::operator <(const Feature& other) const
282 if (name < other.name) {
285 if (name > other.name) {
288 return paramsList < other.paramsList;
291 bool ConfigParserData::Feature::operator<=(const Feature& other) const
293 if (name < other.name) {
296 if (name > other.name) {
299 return paramsList <= other.paramsList;
302 bool ConfigParserData::Privilege::operator==(const Privilege& other) const
304 return name == other.name;
307 bool ConfigParserData::Privilege::operator!=(const Privilege& other) const
309 return name != other.name;
312 bool ConfigParserData::Privilege::operator >(const Privilege& other) const
314 return name > other.name;
317 bool ConfigParserData::Privilege::operator>=(const Privilege& other) const
319 return name >= other.name;
322 bool ConfigParserData::Privilege::operator <(const Privilege& other) const
324 return name < other.name;
327 bool ConfigParserData::Privilege::operator<=(const Privilege& other) const
329 return name < other.name;
332 bool ConfigParserData::Icon::operator==(const Icon& other) const
334 return src == other.src;
337 bool ConfigParserData::Icon::operator!=(const Icon& other) const
339 return src != other.src;
342 bool ConfigParserData::Icon::operator >(const Icon& other) const
344 return src > other.src;
347 bool ConfigParserData::Icon::operator>=(const Icon& other) const
349 return src >= other.src;
352 bool ConfigParserData::Icon::operator <(const Icon& other) const
354 return src < other.src;
357 bool ConfigParserData::Icon::operator<=(const Icon& other) const
359 return src <= other.src;
362 bool ConfigParserData::Preference::operator==(const Preference& other) const
364 return name == other.name;
367 bool ConfigParserData::Preference::operator!=(const Preference& other) const
369 return name != other.name;
372 bool ConfigParserData::Preference::operator >(const Preference& other) const
374 return name > other.name;
377 bool ConfigParserData::Preference::operator>=(const Preference& other) const
379 return name >= other.name;
382 bool ConfigParserData::Preference::operator <(const Preference& other) const
384 return name < other.name;
387 bool ConfigParserData::Preference::operator<=(const Preference& other) const
389 return name <= other.name;
392 bool ConfigParserData::AccessInfo::operator== (const AccessInfo& info) const
394 return m_strIRI == info.m_strIRI && m_bSubDomainAccess ==
395 info.m_bSubDomainAccess;
398 bool ConfigParserData::AccessInfo::operator!= (const AccessInfo& info) const
400 return m_strIRI != info.m_strIRI || m_bSubDomainAccess !=
401 info.m_bSubDomainAccess;
404 bool ConfigParserData::AccessInfo::operator <(const AccessInfo& info) const
406 if (m_strIRI == info.m_strIRI) {
407 return m_bSubDomainAccess < info.m_bSubDomainAccess;
409 return m_strIRI < info.m_strIRI;
413 bool ConfigParserData::Setting::operator==(const Setting& other) const
415 return m_name == other.m_name &&
416 m_value == other.m_value;
419 bool ConfigParserData::Setting::operator!=(const Setting& other) const
421 return m_name != other.m_name ||
422 m_value != other.m_value;
425 bool ConfigParserData::Setting::operator >(const Setting& other) const
427 return m_name > other.m_name;
430 bool ConfigParserData::Setting::operator>=(const Setting& other) const
432 return m_name >= other.m_name;
435 bool ConfigParserData::Setting::operator <(const Setting& other) const
437 return m_name < other.m_name;
440 bool ConfigParserData::Setting::operator<=(const Setting& other) const
442 return m_name <= other.m_name;
445 bool ConfigParserData::ServiceInfo::operator== (const ServiceInfo& info) const
447 return m_src == info.m_src &&
448 m_operation == info.m_operation &&
449 m_scheme == info.m_scheme &&
450 m_mime == info.m_mime;
453 bool ConfigParserData::ServiceInfo::operator!= (const ServiceInfo& info) const
455 return m_src != info.m_src &&
456 m_operation != info.m_operation &&
457 m_scheme != info.m_scheme &&
458 m_mime != info.m_mime;