Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:smarty12
kodi-platform
_service:obs_scm:kodi-platform-2018.03.02.obscpio
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File _service:obs_scm:kodi-platform-2018.03.02.obscpio of Package kodi-platform
0707011C2000F2000081A40000000200000002000000015A98D2FF00000A17000000FD0000001000000000000000000000002800000000kodi-platform-2018.03.02/CMakeLists.txtproject(kodiplatform) cmake_minimum_required(VERSION 2.6) enable_language(CXX) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}) find_package(Kodi REQUIRED) find_package(TinyXML REQUIRED) find_package(Threads REQUIRED) find_package(p8-platform REQUIRED) include(UseMultiArch.cmake) include(CheckAtomic.cmake) set(kodiplatform_NAME kodiplatform) set(kodiplatform_DESCRIPTION "Kodi add-on platform support library") set(kodiplatform_VERSION_MAJOR ${APP_VERSION_MAJOR}) set(kodiplatform_VERSION_MINOR ${APP_VERSION_MINOR}) set(kodiplatform_VERSION_PATCH 0) if(NOT WIN32) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC") endif() set(kodiplatform_INCLUDE_DIRS ${TINYXML_INCLUDE_DIR} "${CMAKE_INSTALL_PREFIX}/include/kodi") IF(WIN32) LIST(APPEND kodiplatform_INCLUDE_DIRS "${CMAKE_INSTALL_PREFIX}/include/kodi/windows") ENDIF(WIN32) set(kodiplatform_LIBRARIES ${CMAKE_THREAD_LIBS_INIT} ${TINYXML_LIBRARIES}) if(NOT ${CORE_SYSTEM_NAME} STREQUAL "") if(${CORE_SYSTEM_NAME} STREQUAL "osx" OR ${CORE_SYSTEM_NAME} STREQUAL "ios") list(APPEND kodiplatform_LIBRARIES "-framework CoreVideo") endif() endif() set(SOURCES src/util/XMLUtils.cpp) include_directories(${TINYXML_INCLUDE_DIR} ${KODI_INCLUDE_DIR} ${p8-platform_INCLUDE_DIRS}) add_library(kodiplatform ${SOURCES} ${PLAT_SOURCES}) target_link_libraries(kodiplatform ${kodiplatform_LIBRARIES} ${p8-platform_LIBRARIES}) set_target_properties(kodiplatform PROPERTIES VERSION ${kodiplatform_VERSION_MAJOR}.${kodiplatform_VERSION_MINOR}.${kodiplatform_VERSION_PATCH} SOVERSION ${kodiplatform_VERSION_MAJOR}.0) install(TARGETS kodiplatform DESTINATION ${CMAKE_INSTALL_LIBDIR}) install(FILES src/util/XMLUtils.h DESTINATION include/kodi/util) IF(NOT WIN32) # Pkgconfig include(PkgConfigHandler.cmake) configure_pc_file(kodiplatform kodiplatform.pc.in kodiplatform.pc ${CMAKE_INSTALL_PREFIX} ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR} ${CMAKE_INSTALL_PREFIX}/include) install(FILES ${CMAKE_BINARY_DIR}/kodiplatform.pc DESTINATION ${CMAKE_INSTALL_LIBDIR_NOARCH}/pkgconfig) ENDIF(NOT WIN32) # config mode configure_file (kodiplatform-config.cmake.in kodiplatform-config.cmake @ONLY) install(FILES ${CMAKE_BINARY_DIR}/kodiplatform-config.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR_NOARCH}/kodiplatform) # Quell warnings with in-tree builds set(KODI_BUILD_DIR ${KODI_BUILD_DIR}) 0707011C2000F3000081A40000000200000002000000015A98D2FF00000266000000FD0000001000000000000000000000002B00000000kodi-platform-2018.03.02/CheckAtomic.cmakeinclude(CheckCXXSourceCompiles) check_library_exists(atomic __atomic_fetch_add_4 "" HAVE_LIBATOMIC) if (HAVE_LIBATOMIC) list(APPEND CMAKE_REQUIRED_LIBRARIES "atomic") endif() CHECK_CXX_SOURCE_COMPILES("int main() { long* temp=0; long ret=__sync_add_and_fetch(temp, 1); return 0; }" HAS_BUILTIN_SYNC_ADD_AND_FETCH) CHECK_CXX_SOURCE_COMPILES("int main() { long* temp=0; long ret=__sync_sub_and_fetch(temp, 1); return 0; }" HAS_BUILTIN_SYNC_SUB_AND_FETCH) CHECK_CXX_SOURCE_COMPILES("int main() { long *temp = 0; long ret=__sync_val_compare_and_swap(temp, 1, 1); return 0; }" HAS_BUILTIN_SYNC_VAL_COMPARE_AND_SWAP)0707011C2000F4000081A40000000200000002000000015A98D2FF00000359000000FD0000001000000000000000000000002B00000000kodi-platform-2018.03.02/FindTinyXML.cmake# - Find TinyXML # Find the native TinyXML includes and library # # TINYXML_FOUND - True if TinyXML found. # TINYXML_INCLUDE_DIR - where to find tinyxml.h, etc. # TINYXML_LIBRARIES - List of libraries when using TinyXML. # IF( TINYXML_INCLUDE_DIR ) # Already in cache, be silent SET( TinyXML_FIND_QUIETLY TRUE ) ENDIF( TINYXML_INCLUDE_DIR ) FIND_PATH( TINYXML_INCLUDE_DIR "tinyxml.h" PATH_SUFFIXES "tinyxml" ) FIND_LIBRARY( TINYXML_LIBRARIES NAMES "tinyxml" PATH_SUFFIXES "tinyxml" ) # handle the QUIETLY and REQUIRED arguments and set TINYXML_FOUND to TRUE if # all listed variables are TRUE INCLUDE( "FindPackageHandleStandardArgs" ) FIND_PACKAGE_HANDLE_STANDARD_ARGS( "TinyXML" DEFAULT_MSG TINYXML_INCLUDE_DIR TINYXML_LIBRARIES ) MARK_AS_ADVANCED( TINYXML_INCLUDE_DIR TINYXML_LIBRARIES ) 0707011C2000F5000081A40000000200000002000000015A98D2FF00001201000000FD0000001000000000000000000000003000000000kodi-platform-2018.03.02/PkgConfigHandler.cmake# translate a list of libraries into a command-line that can be passed to the # compiler/linker. first parameter is the name of the variable that will # receive this list, the rest is considered the list of libraries function (linker_cmdline what INTO outvar FROM) # if we are going to put these in regexps, we must escape period string (REPLACE "." "\\." esc_dl_pref "${CMAKE_SHARED_LIBRARY_PREFIX}") string (REPLACE "." "\\." esc_dl_suff "${CMAKE_SHARED_LIBRARY_SUFFIX}") string (REPLACE "." "\\." esc_ar_pref "${CMAKE_STATIC_LIBRARY_PREFIX}") string (REPLACE "." "\\." esc_ar_suff "${CMAKE_STATIC_LIBRARY_PREFIX}") # CMake loves absolute paths, whereas libtool won't have any of it! # (you get an error message about argument not parsed). translate each # of the libraries into a linker option set (deplib_list "") foreach (deplib IN LISTS ARGN) # starts with a hyphen already? then just add it string (SUBSTRING ${deplib} 0 1 dash) if (${dash} STREQUAL "-") list (APPEND deplib_list ${deplib}) else (${dash} STREQUAL "-") # otherwise, parse the name into a directory and a name get_filename_component (deplib_dir ${deplib} PATH) get_filename_component (deplib_orig ${deplib} NAME) string (REGEX REPLACE "^${esc_dl_pref}(.*)${esc_dl_suff}$" "\\1" deplib_name ${deplib_orig} ) string (REGEX REPLACE "^${esc_ar_pref}(.*)${esc_ar_suff}$" "\\1" deplib_name ${deplib_name} ) # directory and name each on their own; this is somewhat # unsatisfactory because it may be that a system dir is specified # by an earlier directory and you start picking up libraries from # there instead of the "closest" path here. also, the soversion # is more or less lost. remove system default path, to lessen the # chance that we pick the wrong library if (NOT ((deplib_dir STREQUAL "/usr/lib") OR (deplib_dir STREQUAL "/usr/${CMAKE_INSTALL_LIBDIR}"))) list (APPEND deplib_list "-L${deplib_dir}") endif (NOT ((deplib_dir STREQUAL "/usr/lib") OR (deplib_dir STREQUAL "/usr/${CMAKE_INSTALL_LIBDIR}"))) # if there was no translation of the name, the library is named # unconventionally (.so.3gf, I'm looking at you), so pass this # name unmodified to the linker switch if (deplib_orig STREQUAL deplib_name) list (APPEND deplib_list "-l:${deplib_orig}") else (deplib_orig STREQUAL deplib_name) list (APPEND deplib_list "-l${deplib_name}") endif (deplib_orig STREQUAL deplib_name) endif (${dash} STREQUAL "-") endforeach (deplib) # caller determines whether we want it returned as a list or a string if ("${what}" STREQUAL "LIST") set (${outvar} ${deplib_list}) else ("${what}" STREQUAL "LIST") set (${outvar} "${deplib_list}") string (REPLACE ";" " " ${outvar} "${${outvar}}") endif ("${what}" STREQUAL "LIST") set (${outvar} "${${outvar}}" PARENT_SCOPE) endfunction (linker_cmdline what INTO outvar FROM) # convert a list back to a command-line string function (unseparate_args var_name prefix value) separate_arguments (value) foreach (item IN LISTS value) set (prefixed_item "${prefix}${item}") if (${var_name}) set (${var_name} "${${var_name}} ${prefixed_item}") else (${var_name}) set (${var_name} "${prefixed_item}") endif (${var_name}) endforeach (item) set (${var_name} "${${var_name}}" PARENT_SCOPE) endfunction (unseparate_args var_name prefix value) # wrapper to set variables in pkg-config file function (configure_pc_file name source dest prefix libdir includedir) # escape set of standard strings unseparate_args (includes "-I" "${${name}_INCLUDE_DIRS}") unseparate_args (defs "" "${${name}_DEFINITIONS}") linker_cmdline (STRING INTO libs FROM ${${name}_LIBRARIES}) # necessary to make these variables visible to configure_file set (name "${${name}_NAME}") set (description "${${name}_DESCRIPTION}") set (major "${${name}_VERSION_MAJOR}") set (minor "${${name}_VERSION_MINOR}") set (target "${name}") linker_cmdline (STRING INTO target from ${target}) configure_file (${source} ${dest} @ONLY) endfunction (configure_pc_file name source dist prefix libdir includedir) 0707011C2000F6000081A40000000200000002000000015A98D2FF00000726000000FD0000001000000000000000000000002C00000000kodi-platform-2018.03.02/UseMultiArch.cmake# - Multiarch support in object code library directories # # This module sets the following variable # CMAKE_INSTALL_LIBDIR to lib, lib64 or lib/x86_64-linux-gnu # depending on the platform; use this path # for platform-specific binaries. # # CMAKE_INSTALL_LIBDIR_NOARCH to lib or lib64 depending on the platform; # use this path for architecture-independent # files. # # Note that it will override the results of GNUInstallDirs if included after # that module. # Fedora uses lib64/ for 64-bit systems, Debian uses lib/x86_64-linux-gnu; # Fedora put module files in lib64/ too, but Debian uses lib/ for that if ("${CMAKE_SYSTEM_NAME}" MATCHES "Linux" AND "${CMAKE_INSTALL_PREFIX}" STREQUAL "/usr") # Debian or Ubuntu? if (EXISTS "/etc/debian_version") set (_libdir_def "lib/${CMAKE_LIBRARY_ARCHITECTURE}") set (_libdir_noarch "lib") elseif (EXISTS "/etc/fedora-release" OR EXISTS "/etc/redhat-release" OR EXISTS "/etc/slackware-version" OR EXISTS "/etc/gentoo-release") # 64-bit system? if (CMAKE_SIZEOF_VOID_P EQUAL 8) set (_libdir_noarch "lib64") else (CMAKE_SIZEOF_VOID_P EQUAL 8) set (_libdir_noarch "lib") endif (CMAKE_SIZEOF_VOID_P EQUAL 8) set (_libdir_def "${_libdir_noarch}") else () set (_libdir_def "lib") set (_libdir_noarch "lib") endif () else () set (_libdir_def "lib") set (_libdir_noarch "lib") endif () # let the user override if somewhere else is desirable set (CMAKE_INSTALL_LIBDIR "${_libdir_def}" CACHE PATH "Object code libraries") set (CMAKE_INSTALL_LIBDIR_NOARCH "${_libdir_noarch}" CACHE PATH "Architecture-independent library files") mark_as_advanced ( CMAKE_INSTALL_LIBDIR CMAKE_INSTALL_LIBDIR_NOARCH ) 0707011C6E4535000041ED0000000200000002000000035A98D2FF00000000000000FD0000001000000000000000000000002000000000kodi-platform-2018.03.02/debian0707011C6E4536000081A40000000200000002000000015A98D2FF000003E7000000FD0000001000000000000000000000002A00000000kodi-platform-2018.03.02/debian/changelogkodiplatform (17.1.0-1~trusty) trusty; urgency=medium * rename find_package kodi to Kodi -- h.udo <hudokkow@gmail.com> Mon, 16 May 2016 10:44:56 +0000 kodiplatform (17.0.0-1~trusty) trusty; urgency=medium * adjust to libplatform rename to libp8-platform -- wsnipex <wsnipex@a1.net> Thu, 12 Feb 2015 13:28:01 +0100 kodiplatform (16.0.0-1~trusty) trusty; urgency=medium * split up into libplatform and libkodiplatform, and removed libCEC-only code -- Lars Op den Kamp <lars@opdenkamp.eu> Thu, 20 Apr 2015 12:16:17 +0100 kodiplatform (15.0.0-1~trusty) trusty; urgency=medium * rebrand to kodi * bump to Isengard -- wsnipex <wsnipex@a1.net> Thu, 12 Feb 2015 13:28:01 +0100 xbmcplatform (14.0.0-1~trusty) trusty; urgency=medium * bump version -- wsnipex <wsnipex@a1.net> Mon, 07 Jul 2014 08:23:48 +0200 xbmcplatform (13.0.0-1~raring) raring; urgency=low * Initial release -- Arne Morten Kvarving <arne.morten.kvarving@sintef.no> Sun, 19 May 2013 02:23:53 +0200 0707011C6E4537000081A40000000200000002000000015A98D2FF000003FC000000FD0000001000000000000000000000002D00000000kodi-platform-2018.03.02/debian/changelog.inkodiplatform (17.1.0-#TAGREV#~#DIST#) #DIST#; urgency=medium * rename find_package kodi to Kodi -- h.udo <hudokkow@gmail.com> Mon, 16 May 2016 10:44:56 +0000 kodiplatform (17.0.0-#TAGREV#~#DIST#) #DIST#; urgency=medium * adjust to libplatform rename to libp8-platform -- wsnipex <wsnipex@a1.net> Thu, 12 Feb 2015 13:28:01 +0100 kodiplatform (16.0.0-#TAGREV#~#DIST#) #DIST#; urgency=medium * split up into libplatform and libkodiplatform, and removed libCEC-only code -- Lars Op den Kamp <lars@opdenkamp.eu> Thu, 20 Apr 2015 12:16:17 +0100 kodiplatform (15.0.0-1~#DIST#) #DIST#; urgency=medium * rebrand to kodi * bump to Isengard -- wsnipex <wsnipex@a1.net> Thu, 12 Feb 2015 13:28:01 +0100 xbmcplatform (14.0.0-1~#DIST#) #DIST#; urgency=medium * bump version -- wsnipex <wsnipex@a1.net> Mon, 07 Jul 2014 08:23:48 +0200 xbmcplatform (13.0.0-1~#DIST#) #DIST#; urgency=low * Initial release -- Arne Morten Kvarving <arne.morten.kvarving@sintef.no> Sun, 19 May 2013 02:23:53 +0200 0707011C6E4538000081A40000000200000002000000015A98D2FF00000002000000FD0000001000000000000000000000002700000000kodi-platform-2018.03.02/debian/compat8 0707011C6E4539000081A40000000200000002000000015A98D2FF00000300000000FD0000001000000000000000000000002800000000kodi-platform-2018.03.02/debian/controlSource: kodiplatform Priority: extra Maintainer: Arne Morten Kvarving <arne.morten.kvarving@sintef.no> Build-Depends: debhelper (>= 8.0.0), cmake, libtinyxml-dev, kodi-addon-dev, libp8-platform-dev Standards-Version: 3.9.5 Section: libs Package: libkodiplatform-dev Section: libdevel Architecture: any Multi-Arch: same Depends: libkodiplatform17 (= ${binary:Version}), libtinyxml-dev, libp8-platform-dev Provides: libkodiplatform-dev Description: Kodi platform support library -- development files Kodi platform support library Package: libkodiplatform17 Section: libs Architecture: any Multi-Arch: same Depends: ${shlibs:Depends}, ${misc:Depends}, libp8-platform2 Provides: libkodiplatform Description: Kodi platform support library Kodi platform support library 0707011C6E453A000081A40000000200000002000000015A98D2FF0000084A000000FD0000001000000000000000000000002A00000000kodi-platform-2018.03.02/debian/copyrightFormat: http://dep.debian.net/deps/dep5 Upstream-Name: kodiplatform Source: https://github.com/xbmc/kodi-platform.git Files: * Copyright: 2011-2012 Pulse-Eight Limited 2005-2015 Team XBMC License: This program is dual-licensed; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. . This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. . You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. . . Alternatively, you can license this library under a commercial license, please contact Pulse-Eight Licensing for more information. . For more information contact: Pulse-Eight Licensing <license@pulse-eight.com> Files: debian/* Copyright: 2013 Arne Morten Kvarving <arne.morten.kvarving@sintef.no> License: GPL-2+ This package is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. . This package is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. . You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/> . On Debian systems, the complete text of the GNU General Public License version 2 can be found in "/usr/share/common-licenses/GPL-2". # Please also look if there are files or directories which have a # different copyright/license attached and list them here. 0707011C6E453B000081A40000000200000002000000015A98D2FF0000004B000000FD0000001000000000000000000000003C00000000kodi-platform-2018.03.02/debian/libkodiplatform-dev.installusr/include/* usr/lib/*/*.so usr/lib/pkgconfig/*.pc usr/lib/kodiplatform/* 0707011C6E453C000081A40000000200000002000000015A98D2FF00000011000000FD0000001000000000000000000000003A00000000kodi-platform-2018.03.02/debian/libkodiplatform17.installusr/lib/*/*.so.* 0707011C6E453D000081ED0000000200000002000000015A98D2FF0000022B000000FD0000001000000000000000000000002600000000kodi-platform-2018.03.02/debian/rules#!/usr/bin/make -f # -*- makefile -*- # Sample debian/rules that uses debhelper. # This file was originally written by Joey Hess and Craig Small. # As a special exception, when this file is copied by dh-make into a # dh-make output file, you may use that output file without restriction. # This special exception was added by Craig Small in version 0.37 of dh-make. # Uncomment this to turn on verbose mode. #export DH_VERBOSE=1 %: dh $@ override_dh_auto_configure: cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=1 -DCMAKE_INSTALL_PREFIX=/usr 0707011C6E453E000041ED0000000200000002000000025A98D2FF00000000000000FD0000001000000000000000000000002700000000kodi-platform-2018.03.02/debian/source0707011C6E453F000081A40000000200000002000000015A98D2FF0000000D000000FD0000001000000000000000000000002E00000000kodi-platform-2018.03.02/debian/source/format3.0 (native) 0707011C2000F7000081A40000000200000002000000015A98D2FF00000644000000FD0000001000000000000000000000003600000000kodi-platform-2018.03.02/kodiplatform-config.cmake.in# - kodiplatform config mode # # Defines the following variables: # kodiplatform_FOUND - true # kodiplatform_VERSION - version of the kodiplatform library found, e.g. 0.2 # kodiplatform_INCLUDE_DIRS - header directories with which to compile # kodiplatform_LINKER_FLAGS - flags that must be passed to the linker # kodiplatform_LIBRARIES - names of the libraries with which to link # kodiplatform_LIBRARY_DIRS - directories in which the libraries are situated # # propagate these properties from one build system to the other set (kodiplatform_VERSION "@kodiplatform_VERSION_MAJOR@.@kodiplatform_VERSION_MINOR@") set (kodiplatform_INCLUDE_DIRS @kodiplatform_INCLUDE_DIRS@ @CMAKE_INSTALL_PREFIX@/include) set (kodiplatform_LIBRARY_DIRS "@CMAKE_LIBRARY_OUTPUT_DIRECTORY@") set (kodiplatform_LINKER_FLAGS "@kodiplatform_LINKER_FLAGS@") set (kodiplatform_CONFIG_VARS "@kodiplatform_CONFIG_VARS@") # libraries come from the build tree where this file was generated if(WIN32) set (kodiplatform_LIBRARY "@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/kodiplatform.lib") else(WIN32) set (kodiplatform_LIBRARY "-L@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@ -lkodiplatform") endif(WIN32) set (kodiplatform_LIBRARIES ${kodiplatform_LIBRARY} "@kodiplatform_LIBRARIES@") mark_as_advanced (kodiplatform_LIBRARY) # add the library as a target, so that other things in the project including # this file may depend on it and get rebuild if this library changes. add_library (kodiplatform UNKNOWN IMPORTED) set_property (TARGET kodiplatform PROPERTY IMPORTED_LOCATION "${kodiplatform_LIBRARY}") 0707011C2000F8000081A40000000200000002000000015A98D2FF00000131000000FD0000001000000000000000000000002C00000000kodi-platform-2018.03.02/kodiplatform.pc.inprefix=@prefix@ libdir=@libdir@ includedir=@includedir@ CXX=@CMAKE_CXX_COMPILER@ @CXX_STD0X_FLAGS@ CC=@CMAKE_C_COMPILER@ @C_STD99_FLAGS@ DEPENDENCIES=@kodiplatform_LIBRARIES@ Name: @name@ Description: @description@ @major@.@minor@ Version: @major@.@minor@ Libs: @target@ @libs@ Cflags: @CMAKE_CXX_FLAGS@ 0707011C700609000041ED0000000200000002000000035A98D2FF00000000000000FD0000001000000000000000000000001D00000000kodi-platform-2018.03.02/src0707011C740130000041ED0000000200000002000000025A98D2FF00000000000000FD0000001000000000000000000000002200000000kodi-platform-2018.03.02/src/util0707011C740137000081A40000000200000002000000015A98D2FF00001E31000000FD0000001000000000000000000000002F00000000kodi-platform-2018.03.02/src/util/XMLUtils.cpp/* * Copyright (C) 2005-2008 Team XBMC * http://www.xbmc.org * * This Program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * This Program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with XBMC; see the file COPYING. If not, write to * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * http://www.gnu.org/copyleft/gpl.html * */ #include "XMLUtils.h" #include <p8-platform/util/StringUtils.h> bool XMLUtils::GetHex(const TiXmlNode* pRootNode, const char* strTag, uint32_t& hexValue) { const TiXmlNode* pNode = pRootNode->FirstChild(strTag ); if (!pNode || !pNode->FirstChild()) return false; sscanf(pNode->FirstChild()->Value(), "%x", (uint32_t*) &hexValue ); return true; } bool XMLUtils::GetUInt(const TiXmlNode* pRootNode, const char* strTag, uint32_t& uintValue) { const TiXmlNode* pNode = pRootNode->FirstChild(strTag ); if (!pNode || !pNode->FirstChild()) return false; uintValue = atol(pNode->FirstChild()->Value()); return true; } bool XMLUtils::GetLong(const TiXmlNode* pRootNode, const char* strTag, long& lLongValue) { const TiXmlNode* pNode = pRootNode->FirstChild(strTag ); if (!pNode || !pNode->FirstChild()) return false; lLongValue = atol(pNode->FirstChild()->Value()); return true; } bool XMLUtils::GetInt(const TiXmlNode* pRootNode, const char* strTag, int& iIntValue) { const TiXmlNode* pNode = pRootNode->FirstChild(strTag ); if (!pNode || !pNode->FirstChild()) return false; iIntValue = atoi(pNode->FirstChild()->Value()); return true; } bool XMLUtils::GetInt(const TiXmlNode* pRootNode, const char* strTag, int &value, const int min, const int max) { if (GetInt(pRootNode, strTag, value)) { if (value < min) value = min; if (value > max) value = max; return true; } return false; } bool XMLUtils::GetDouble(const TiXmlNode *root, const char *tag, double &value) { const TiXmlNode* node = root->FirstChild(tag); if (!node || !node->FirstChild()) return false; value = atof(node->FirstChild()->Value()); return true; } bool XMLUtils::GetFloat(const TiXmlNode* pRootNode, const char* strTag, float& value) { const TiXmlNode* pNode = pRootNode->FirstChild(strTag ); if (!pNode || !pNode->FirstChild()) return false; value = (float)atof(pNode->FirstChild()->Value()); return true; } bool XMLUtils::GetFloat(const TiXmlNode* pRootElement, const char *tagName, float& fValue, const float fMin, const float fMax) { if (GetFloat(pRootElement, tagName, fValue)) { // check range if (fValue < fMin) fValue = fMin; if (fValue > fMax) fValue = fMax; return true; } return false; } bool XMLUtils::GetBoolean(const TiXmlNode* pRootNode, const char* strTag, bool& bBoolValue) { const TiXmlNode* pNode = pRootNode->FirstChild(strTag ); if (!pNode || !pNode->FirstChild()) return false; std::string strEnabled = pNode->FirstChild()->Value(); StringUtils::ToLower(strEnabled); if (strEnabled == "off" || strEnabled == "no" || strEnabled == "disabled" || strEnabled == "false" || strEnabled == "0" ) bBoolValue = false; else { bBoolValue = true; if (strEnabled != "on" && strEnabled != "yes" && strEnabled != "enabled" && strEnabled != "true") return false; // invalid bool switch - it's probably some other string. } return true; } bool XMLUtils::GetString(const TiXmlNode* pRootNode, const char* strTag, std::string& strStringValue) { const TiXmlElement* pElement = pRootNode->FirstChildElement(strTag ); if (!pElement) return false; const TiXmlNode* pNode = pElement->FirstChild(); if (pNode != NULL) { strStringValue = pNode->Value(); return true; } strStringValue.clear(); return false; } bool XMLUtils::HasChild(const TiXmlNode* pRootNode, const char* strTag) { const TiXmlElement* pElement = pRootNode->FirstChildElement(strTag); if (!pElement) return false; const TiXmlNode* pNode = pElement->FirstChild(); return (pNode != NULL); } /*! Returns true if the encoding of the document is other then UTF-8. /param strEncoding Returns the encoding of the document. Empty if UTF-8 */ bool XMLUtils::GetEncoding(const TiXmlDocument* pDoc, std::string& strEncoding) { const TiXmlNode* pNode=NULL; while ((pNode=pDoc->IterateChildren(pNode)) && pNode->Type()!=TiXmlNode::TINYXML_DECLARATION) {} if (!pNode) return false; const TiXmlDeclaration* pDecl=pNode->ToDeclaration(); if (!pDecl) return false; strEncoding=pDecl->Encoding(); if (StringUtils::EqualsNoCase(strEncoding, "UTF-8") || StringUtils::EqualsNoCase(strEncoding, "UTF8")) strEncoding.clear(); StringUtils::ToUpper(strEncoding); return !strEncoding.empty(); // Other encoding then UTF8? } /*! Returns true if the encoding of the document is specified as as UTF-8 /param strXML The XML file (embedded in a string) to check. */ bool XMLUtils::HasUTF8Declaration(const std::string &strXML) { std::string test = strXML; StringUtils::ToLower(test); // test for the encoding="utf-8" string if (test.find("encoding=\"utf-8\"") != std::string::npos) return true; // TODO: test for plain UTF8 here? return false; } bool XMLUtils::GetPath(const TiXmlNode* pRootNode, const char* strTag, std::string& strStringValue) { const TiXmlElement* pElement = pRootNode->FirstChildElement(strTag); if (!pElement) return false; const TiXmlNode* pNode = pElement->FirstChild(); if (pNode != NULL) { strStringValue = pNode->Value(); return true; } strStringValue.clear(); return false; } void XMLUtils::SetStringArray(TiXmlNode* pRootNode, const char *strTag, const std::vector<std::string>& arrayValue) { for (unsigned int i = 0; i < arrayValue.size(); i++) SetString(pRootNode, strTag, arrayValue.at(i)); } void XMLUtils::SetString(TiXmlNode* pRootNode, const char *strTag, const std::string& strValue) { TiXmlElement newElement(strTag); TiXmlNode *pNewNode = pRootNode->InsertEndChild(newElement); if (pNewNode) { TiXmlText value(strValue); pNewNode->InsertEndChild(value); } } void XMLUtils::SetInt(TiXmlNode* pRootNode, const char *strTag, int value) { auto strValue = StringUtils::Format("%i", value); SetString(pRootNode, strTag, strValue); } void XMLUtils::SetLong(TiXmlNode* pRootNode, const char *strTag, long value) { auto strValue = StringUtils::Format("%l", value); SetString(pRootNode, strTag, strValue); } void XMLUtils::SetFloat(TiXmlNode* pRootNode, const char *strTag, float value) { auto strValue = StringUtils::Format("%f", value); SetString(pRootNode, strTag, strValue); } void XMLUtils::SetBoolean(TiXmlNode* pRootNode, const char *strTag, bool value) { SetString(pRootNode, strTag, value ? "true" : "false"); } void XMLUtils::SetHex(TiXmlNode* pRootNode, const char *strTag, uint32_t value) { auto strValue = StringUtils::Format("%x", value); SetString(pRootNode, strTag, strValue); } void XMLUtils::SetPath(TiXmlNode* pRootNode, const char *strTag, const std::string& strValue) { TiXmlElement newElement(strTag); newElement.SetAttribute("pathversion", path_version); TiXmlNode *pNewNode = pRootNode->InsertEndChild(newElement); if (pNewNode) { TiXmlText value(strValue); pNewNode->InsertEndChild(value); } } 0707011C740138000081A40000000200000002000000015A98D2FF00000B7F000000FD0000001000000000000000000000002D00000000kodi-platform-2018.03.02/src/util/XMLUtils.h#pragma once /* * Copyright (C) 2005-2008 Team XBMC * http://www.xbmc.org * * This Program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * This Program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with XBMC; see the file COPYING. If not, write to * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. * http://www.gnu.org/copyleft/gpl.html * */ #include <string> #include <vector> #include "tinyxml.h" class XMLUtils { public: static bool HasUTF8Declaration(const std::string &strXML); static bool HasChild(const TiXmlNode* pRootNode, const char* strTag); static bool GetHex(const TiXmlNode* pRootNode, const char* strTag, uint32_t& dwHexValue); static bool GetUInt(const TiXmlNode* pRootNode, const char* strTag, uint32_t& dwUIntValue); static bool GetLong(const TiXmlNode* pRootNode, const char* strTag, long& lLongValue); static bool GetFloat(const TiXmlNode* pRootNode, const char* strTag, float& value); static bool GetDouble(const TiXmlNode* pRootNode, const char* strTag, double &value); static bool GetInt(const TiXmlNode* pRootNode, const char* strTag, int& iIntValue); static bool GetBoolean(const TiXmlNode* pRootNode, const char* strTag, bool& bBoolValue); static bool GetString(const TiXmlNode* pRootNode, const char* strTag, std::string& strStringValue); static bool GetEncoding(const TiXmlDocument* pDoc, std::string& strEncoding); static bool GetPath(const TiXmlNode* pRootNode, const char* strTag, std::string& strStringValue); static bool GetFloat(const TiXmlNode* pRootNode, const char* strTag, float& value, const float min, const float max); static bool GetInt(const TiXmlNode* pRootNode, const char* strTag, int& iIntValue, const int min, const int max); static void SetString(TiXmlNode* pRootNode, const char *strTag, const std::string& strValue); static void SetStringArray(TiXmlNode* pRootNode, const char *strTag, const std::vector<std::string>& arrayValue); static void SetInt(TiXmlNode* pRootNode, const char *strTag, int value); static void SetFloat(TiXmlNode* pRootNode, const char *strTag, float value); static void SetBoolean(TiXmlNode* pRootNode, const char *strTag, bool value); static void SetHex(TiXmlNode* pRootNode, const char *strTag, uint32_t value); static void SetPath(TiXmlNode* pRootNode, const char *strTag, const std::string& strValue); static void SetLong(TiXmlNode* pRootNode, const char *strTag, long iValue); static const int path_version = 1; }; 07070100000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000B00000000TRAILER!!!63 blocks
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor