mirror of
https://github.com/GerbilSoft/mst06.git
synced 2025-06-18 11:35:31 -04:00
Mst: Added saveXML() to save the string table in XML format.
Added an internal copy of TinyXML2 for Windows builds. Based on the rom-properties build. main.cpp: Replace the file extension on the source file with .xml and use that as the destination filename.
This commit is contained in:
parent
4f7df957eb
commit
aa4019b94d
@ -2,7 +2,9 @@ PROJECT(mst06_base)
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 3.1)
|
||||
|
||||
LIST(APPEND CMAKE_MODULE_PATH
|
||||
"${CMAKE_SOURCE_DIR}/cmake/macros"
|
||||
"${CMAKE_SOURCE_DIR}/cmake/modules"
|
||||
"${CMAKE_SOURCE_DIR}/cmake/libs"
|
||||
)
|
||||
|
||||
# If no build type is set, default to "Debug".
|
||||
@ -15,6 +17,14 @@ ELSEIF(TMP_BUILD_TYPE MATCHES "none")
|
||||
ENDIF()
|
||||
UNSET(TMP_BUILD_TYPE)
|
||||
|
||||
# Put all the binaries and libraries into a single directory.
|
||||
# NOTE: CACHE INTERNAL is required in order to get this to work
|
||||
# for KDE5 for some reason. (and maybe that's why KDE4 did this
|
||||
# layout by default?)
|
||||
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin" CACHE INTERNAL "Put all binaries in a single directory.")
|
||||
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" CACHE INTERNAL "Put all libraries in a single directory.")
|
||||
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" CACHE INTERNAL "Put all archives in a single directory.")
|
||||
|
||||
# Program information.
|
||||
SET(DESCRIPTION "Sonic '06 MST File Decoder and Encoder")
|
||||
SET(PACKAGE_NAME "mst06")
|
||||
@ -33,6 +43,32 @@ IF(VERSION_DEVEL)
|
||||
ENDIF(VERSION_DEVEL)
|
||||
SET(VERSION_STRING_WIN32 "${VERSION_MAJOR},${VERSION_MINOR},${VERSION_PATCH},${VERSION_DEVEL}")
|
||||
|
||||
# Split Debug macro.
|
||||
# Also sets the image version for Windows builds.
|
||||
INCLUDE(Win32ImageVersionLinkerFlags)
|
||||
MACRO(DO_SPLIT_DEBUG _target)
|
||||
IF(TARGET ${_target})
|
||||
# Split debug information.
|
||||
INCLUDE(SetMSVCDebugPath)
|
||||
SET_MSVC_DEBUG_PATH(${_target})
|
||||
IF(SPLIT_DEBUG)
|
||||
INCLUDE(SplitDebugInformation)
|
||||
SPLIT_DEBUG_INFORMATION(${_target})
|
||||
ENDIF(SPLIT_DEBUG)
|
||||
# Set image version.
|
||||
# Subprojects can override ${VERSION_MAJOR} and ${VERSION_MINOR}.
|
||||
# FIXME: If minor version is e.g. "3", Windows interprets it as "03",
|
||||
# so "1.3" will actually be "1.03".
|
||||
WIN32_IMAGE_VERSION_LINKER_FLAGS(${VERSION_MAJOR} ${VERSION_MINOR})
|
||||
ENDIF(TARGET ${_target})
|
||||
ENDMACRO(DO_SPLIT_DEBUG)
|
||||
|
||||
# Windows-specific functions.
|
||||
INCLUDE(WindowsFunctions)
|
||||
|
||||
# Check for required libraries.
|
||||
INCLUDE(CheckTinyXML2)
|
||||
|
||||
########### Add uninstall target ###############
|
||||
CONFIGURE_FILE(
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
|
||||
@ -116,4 +152,5 @@ ELSE(MSVC)
|
||||
ENDIF(MSVC)
|
||||
|
||||
# Project subdirectories.
|
||||
ADD_SUBDIRECTORY(extlib)
|
||||
ADD_SUBDIRECTORY(src)
|
||||
|
59
cmake/libs/CheckTinyXML2.cmake
Normal file
59
cmake/libs/CheckTinyXML2.cmake
Normal file
@ -0,0 +1,59 @@
|
||||
# Check for TinyXML2.
|
||||
# If TinyXML2 isn't found, extlib/tinyxml2/ will be used instead.
|
||||
|
||||
# TODO: Conditionally enable XML?
|
||||
SET(ENABLE_XML 1)
|
||||
IF(ENABLE_XML)
|
||||
|
||||
IF(NOT USE_INTERNAL_XML)
|
||||
IF(TinyXML2_LIBRARY MATCHES "^tinyxml2$" OR TinyXML2_LIBRARY MATCHES "^tinyxml2_static$")
|
||||
# Internal TinyXML2 was previously in use.
|
||||
UNSET(XML_FOUND)
|
||||
UNSET(HAVE_XML)
|
||||
UNSET(TinyXML2_LIBRARY CACHE)
|
||||
ENDIF()
|
||||
|
||||
# Check for TinyXML2.
|
||||
FIND_PACKAGE(TinyXML2)
|
||||
IF(TinyXML2_FOUND)
|
||||
# Found system TinyXML2.
|
||||
SET(HAVE_XML 1)
|
||||
ELSE()
|
||||
# System TinyXML2 was not found.
|
||||
MESSAGE(STATUS "Using the internal copy of TinyXML2 since a system version was not found.")
|
||||
SET(USE_INTERNAL_XML ON CACHE STRING "Use the internal copy of TinyXML2." FORCE)
|
||||
ENDIF()
|
||||
ELSE()
|
||||
MESSAGE(STATUS "Using the internal copy of TinyXML2.")
|
||||
ENDIF(NOT USE_INTERNAL_XML)
|
||||
|
||||
IF(USE_INTERNAL_XML)
|
||||
# Using the internal TinyXML2 library.
|
||||
# NOTE: The tinyxml2 target has implicit include directories,
|
||||
# so we don't need to set the variables.
|
||||
SET(TinyXML2_FOUND 1)
|
||||
SET(HAVE_XML 1)
|
||||
IF(WIN32)
|
||||
# Using DLLs on Windows.
|
||||
# TODO: Build a dylib for Mac OS X.
|
||||
SET(USE_INTERNAL_XML_DLL ON)
|
||||
ELSE()
|
||||
# Using static linking on other systems.
|
||||
SET(USE_INTERNAL_XML_DLL OFF)
|
||||
ENDIF()
|
||||
# TinyXML2 v7.0.0's CMakeLists.txt uses the same target for
|
||||
# both DLL and static library builds.
|
||||
SET(TinyXML2_LIBRARY tinyxml2 CACHE "TinyXML2 library." INTERNAL FORCE)
|
||||
SET(TinyXML2_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/extlib/tinyxml2")
|
||||
ELSE(USE_INTERNAL_XML)
|
||||
SET(USE_INTERNAL_XML_DLL OFF)
|
||||
ENDIF(USE_INTERNAL_XML)
|
||||
|
||||
ELSE(ENABLE_XML)
|
||||
# Disable TinyXML2.
|
||||
UNSET(TinyXML2_FOUND)
|
||||
UNSET(HAVE_XML)
|
||||
UNSET(USE_INTERNAL_XML)
|
||||
UNSET(USE_INTERNAL_XML_DLL)
|
||||
UNSET(TinyXML2_LIBRARY)
|
||||
ENDIF(ENABLE_XML)
|
105
cmake/libs/FindLibraryPkgConfig.cmake
Normal file
105
cmake/libs/FindLibraryPkgConfig.cmake
Normal file
@ -0,0 +1,105 @@
|
||||
# Find a library using PkgConfig.
|
||||
#
|
||||
# Required variables:
|
||||
# - _prefix: Variable prefix.
|
||||
# - _prefix: pkgconfig package name. (Used for variable prefixes.)
|
||||
# - _include: Include file to test.
|
||||
# - _library: Library name, without the leading "lib".
|
||||
# - _target: Name for the imported target.
|
||||
#
|
||||
# If found, the following variables will be defined:
|
||||
# - ${_prefix}_FOUND: System has the package.
|
||||
# - ${_prefix}_INCLUDE_DIRS: Package include directories.
|
||||
# - ${_prefix}_LIBRARIES: Package libraries.
|
||||
# - ${_prefix}_DEFINITIONS: Compiler switches required for using the package.
|
||||
# - ${_prefix}_VERSION: Package version.
|
||||
#
|
||||
# In addition, if a package has extensiondir or extensionsdir set,
|
||||
# the appropriate ${_prefix}_* variable will also be set.
|
||||
#
|
||||
# A target with the name ${_target} will be created with all of
|
||||
# these definitions.
|
||||
#
|
||||
# References:
|
||||
# - https://cmake.org/Wiki/CMake:How_To_Find_Libraries
|
||||
# - http://francesco-cek.com/cmake-and-gtk-3-the-easy-way/
|
||||
#
|
||||
FUNCTION(FIND_LIBRARY_PKG_CONFIG _prefix _pkgconf _include _library _target)
|
||||
FIND_PACKAGE(PkgConfig)
|
||||
IF(PKG_CONFIG_FOUND)
|
||||
PKG_CHECK_MODULES(PC_${_prefix} QUIET ${_pkgconf})
|
||||
SET(${_prefix}_DEFINITIONS ${PC_${_prefix}_CFLAGS_OTHER})
|
||||
|
||||
FIND_PATH(${_prefix}_INCLUDE_DIR ${_include}
|
||||
HINTS ${PC_${_prefix}_INCLUDEDIR} ${PC_${_prefix}_INCLUDE_DIRS})
|
||||
FIND_LIBRARY(${_prefix}_LIBRARY NAMES ${_library} lib${_library}
|
||||
HINTS ${PC_${_prefix}_LIBDIR} ${PC_${_prefix}_LIBRARY_DIRS})
|
||||
|
||||
# Version must be set before calling FPHSA.
|
||||
SET(${_prefix}_VERSION ${PC_${_prefix}_VERSION})
|
||||
MARK_AS_ADVANCED(${_prefix}_VERSION)
|
||||
|
||||
# Handle the QUIETLY and REQUIRED arguments and set
|
||||
# ${_prefix}_FOUND to TRUE if all listed variables
|
||||
# are TRUE.
|
||||
SET(${_prefix}_PREV_FOUND ${_prefix}_FOUND)
|
||||
INCLUDE(FindPackageHandleStandardArgs)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(${_prefix}
|
||||
FOUND_VAR ${_prefix}_FOUND
|
||||
REQUIRED_VARS ${_prefix}_LIBRARY ${_prefix}_INCLUDE_DIR
|
||||
VERSION_VAR ${_prefix}_VERSION
|
||||
)
|
||||
MARK_AS_ADVANCED(${_prefix}_INCLUDE_DIR ${_prefix}_LIBRARY)
|
||||
|
||||
SET(${_prefix}_LIBRARIES ${${_prefix}_LIBRARY})
|
||||
SET(${_prefix}_INCLUDE_DIRS ${${_prefix}_INCLUDE_DIR})
|
||||
|
||||
# Create the library target.
|
||||
IF(${_prefix}_FOUND)
|
||||
IF(NOT TARGET ${_target})
|
||||
ADD_LIBRARY(${_target} UNKNOWN IMPORTED)
|
||||
ENDIF(NOT TARGET ${_target})
|
||||
SET_TARGET_PROPERTIES(${_target} PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${${_prefix}_INCLUDE_DIRS}")
|
||||
SET_TARGET_PROPERTIES(${_target} PROPERTIES
|
||||
IMPORTED_LOCATION "${${_prefix}_LIBRARY}")
|
||||
SET_TARGET_PROPERTIES(${_target} PROPERTIES
|
||||
COMPILE_DEFINITIONS "${${_prefix}_DEFINITIONS}")
|
||||
|
||||
# Add include directories from the pkgconfig's Cflags section.
|
||||
FOREACH(CFLAG ${PC_${_prefix}_CFLAGS})
|
||||
IF(CFLAG MATCHES "^-I")
|
||||
STRING(SUBSTRING "${CFLAG}" 2 -1 INCDIR)
|
||||
LIST(APPEND ${_prefix}_INCLUDE_DIRS "${INCDIR}")
|
||||
UNSET(INCDIR)
|
||||
ENDIF(CFLAG MATCHES "^-I")
|
||||
ENDFOREACH()
|
||||
SET_TARGET_PROPERTIES(${_target} PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${${_prefix}_INCLUDE_DIRS}")
|
||||
|
||||
IF(COMMAND PKG_GET_VARIABLE)
|
||||
IF(NOT ${_prefix}_PREV_FOUND)
|
||||
MESSAGE(STATUS "Found ${_prefix}: ${${_prefix}_LIBRARY} (version ${${_prefix}_VERSION})")
|
||||
ENDIF(NOT ${_prefix}_PREV_FOUND)
|
||||
# Check for extensiondir and/or extensionsdir.
|
||||
PKG_GET_VARIABLE(${_prefix}_EXTENSION_DIR ${_pkgconf} extensiondir)
|
||||
PKG_GET_VARIABLE(${_prefix}_EXTENSIONS_DIR ${_pkgconf} extensionsdir)
|
||||
ENDIF(COMMAND PKG_GET_VARIABLE)
|
||||
|
||||
# Replace hard-coded prefixes.
|
||||
INCLUDE(ReplaceHardcodedPrefix)
|
||||
FOREACH(VAR EXTENSION_DIR EXTENSIONS_DIR)
|
||||
REPLACE_HARDCODED_PREFIX(${_prefix}_${VAR} "${PC_${_prefix}_PREFIX}")
|
||||
ENDFOREACH()
|
||||
|
||||
# Export variables.
|
||||
FOREACH(VAR FOUND INCLUDE_DIRS LIBRARY LIBRARIES DEFINITIONS EXTENSION_DIR EXTENSIONS_DIR VERSION)
|
||||
SET(${_prefix}_${VAR} ${${_prefix}_${VAR}} CACHE INTERNAL "${_prefix}_${VAR}")
|
||||
ENDFOREACH()
|
||||
ELSE(${_prefix}_FOUND)
|
||||
MESSAGE(STATUS "NOT FOUND: ${_prefix}")
|
||||
ENDIF(${_prefix}_FOUND)
|
||||
ELSE(PKG_CONFIG_FOUND)
|
||||
MESSAGE(STATUS "NOT FOUND: PkgConfig - cannot search for ${_prefix}")
|
||||
ENDIF(PKG_CONFIG_FOUND)
|
||||
ENDFUNCTION()
|
22
cmake/libs/FindTinyXML2.cmake
Normal file
22
cmake/libs/FindTinyXML2.cmake
Normal file
@ -0,0 +1,22 @@
|
||||
# Find TinyXML2 libraries and headers.
|
||||
# If found, the following variables will be defined:
|
||||
# - TinyXML2_FOUND: System has TinyXML2.
|
||||
# - TinyXML2_INCLUDE_DIRS: TinyXML2 include directories.
|
||||
# - TinyXML2_LIBRARIES: TinyXML2 libraries.
|
||||
# - TinyXML2_DEFINITIONS: Compiler switches required for using TinyXML2.
|
||||
#
|
||||
# In addition, a target TinyXML2::tinyxml2 will be created with all of
|
||||
# these definitions.
|
||||
#
|
||||
# References:
|
||||
# - https://cmake.org/Wiki/CMake:How_To_Find_Libraries
|
||||
# - http://francesco-cek.com/cmake-and-gtk-3-the-easy-way/
|
||||
#
|
||||
|
||||
INCLUDE(FindLibraryPkgConfig)
|
||||
FIND_LIBRARY_PKG_CONFIG(TinyXML2
|
||||
tinyxml2 # pkgconfig
|
||||
tinyxml2.h # header
|
||||
tinyxml2 # library
|
||||
TinyXML2::tinyxml2 # imported target
|
||||
)
|
14
cmake/macros/ReplaceHardcodedPrefix.cmake
Normal file
14
cmake/macros/ReplaceHardcodedPrefix.cmake
Normal file
@ -0,0 +1,14 @@
|
||||
# Replace hard-coded prefixes.
|
||||
# Parameters:
|
||||
# - _var: Variable containing the path with the prefix to replcae.
|
||||
# - _prefix: Prefix to replace.
|
||||
|
||||
MACRO(REPLACE_HARDCODED_PREFIX _var _prefix)
|
||||
IF(NOT "${_prefix}" STREQUAL "${CMAKE_INSTALL_PREFIX}")
|
||||
STRING(LENGTH "${_prefix}" prefix_LEN)
|
||||
IF(${_var})
|
||||
STRING(SUBSTRING "${${_var}}" ${prefix_LEN} -1 prefix_SUB)
|
||||
SET(${_var} "${CMAKE_INSTALL_PREFIX}${prefix_SUB}")
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
ENDMACRO()
|
54
cmake/macros/SetMSVCDebugPath.cmake
Normal file
54
cmake/macros/SetMSVCDebugPath.cmake
Normal file
@ -0,0 +1,54 @@
|
||||
# Split debug information from an executable into a separate file.
|
||||
# SPLIT_DEBUG_INFORMATION(EXE_TARGET)
|
||||
#
|
||||
# References:
|
||||
# - http://cmake.3232098.n2.nabble.com/Save-stripped-debugging-information-td6819195.html
|
||||
# - http://sourceware.org/bugzilla/show_bug.cgi?id=14527
|
||||
# - If debug symbols are stripped before .gnu_debuglink is added,
|
||||
# the section will be truncated to .gnu_deb, and hence won't
|
||||
# be recognized by gdb.
|
||||
# - FIXME: If the above .gnu_debuglink workaround is used, Windows XP
|
||||
# and Windows 7 will claim that the executable isn't a valid Win32
|
||||
# executable. (Wine ignores it and works fine!)
|
||||
#
|
||||
MACRO(SET_MSVC_DEBUG_PATH _target)
|
||||
IF(MSVC)
|
||||
# CMake seems to use weird settings for the PDB file.
|
||||
# (at least version 2.8.12.2; 3.0.0 might be different)
|
||||
STRING(REGEX REPLACE
|
||||
"/Fd<OBJECT_DIR>/"
|
||||
"/Fd<TARGET_PDB>"
|
||||
CMAKE_C_COMPILE_OBJECT "${CMAKE_C_COMPILE_OBJECT}")
|
||||
STRING(REGEX REPLACE
|
||||
"/Fd<OBJECT_DIR>/"
|
||||
"/Fd<TARGET_PDB>"
|
||||
CMAKE_CXX_COMPILE_OBJECT "${CMAKE_CXX_COMPILE_OBJECT}")
|
||||
|
||||
# Handle target prefixes if not overridden.
|
||||
# NOTE: Cannot easily use the TYPE property in a generator expression...
|
||||
GET_PROPERTY(TARGET_TYPE TARGET ${_target} PROPERTY TYPE)
|
||||
SET(PREFIX_EXPR_1 "$<$<STREQUAL:$<TARGET_PROPERTY:${_target},PREFIX>,>:${CMAKE_${TARGET_TYPE}_PREFIX}>")
|
||||
SET(PREFIX_EXPR_2 "$<$<NOT:$<STREQUAL:$<TARGET_PROPERTY:${_target},PREFIX>,>>:$<TARGET_PROPERTY:${_target},PREFIX>>")
|
||||
SET(PREFIX_EXPR_FULL "${PREFIX_EXPR_1}${PREFIX_EXPR_2}")
|
||||
|
||||
# If a custom OUTPUT_NAME was specified, use it.
|
||||
SET(OUTPUT_NAME_EXPR_1 "$<$<STREQUAL:$<TARGET_PROPERTY:${_target},OUTPUT_NAME>,>:${_target}>")
|
||||
SET(OUTPUT_NAME_EXPR_2 "$<$<NOT:$<STREQUAL:$<TARGET_PROPERTY:${_target},OUTPUT_NAME>,>>:$<TARGET_PROPERTY:${_target},OUTPUT_NAME>>")
|
||||
SET(OUTPUT_NAME_EXPR "${OUTPUT_NAME_EXPR_1}${OUTPUT_NAME_EXPR_2}")
|
||||
SET(OUTPUT_NAME_FULL "${PREFIX_EXPR_FULL}${OUTPUT_NAME_EXPR}$<TARGET_PROPERTY:${_target},POSTFIX>")
|
||||
|
||||
SET(SPLITDEBUG_SOURCE "$<TARGET_FILE:${_target}>")
|
||||
SET(SPLITDEBUG_TARGET "$<TARGET_FILE_DIR:${_target}>/${OUTPUT_NAME_FULL}.debug")
|
||||
|
||||
SET(OUTPUT_NAME_EXPR_1 "$<TARGET_PROPERTY:${_target},PREFIX>$<TARGET_PROPERTY:${_target},OUTPUT_NAME>$<TARGET_PROPERTY:${_target},POSTFIX>")
|
||||
SET(OUTPUT_NAME_EXPR_2 "$<$<STREQUAL:$<TARGET_PROPERTY:${_target},OUTPUT_NAME>,>:$<TARGET_PROPERTY:${_target},PREFIX>${_target}$<TARGET_PROPERTY:${_target},POSTFIX>>")
|
||||
|
||||
# Set the target PDB filename.
|
||||
SET_TARGET_PROPERTIES(${_target}
|
||||
PROPERTIES PDB "$<TARGET_FILE_DIR:${_target}>/${OUTPUT_NAME_EXPR_1}${OUTPUT_NAME_EXPR_2}.pdb"
|
||||
)
|
||||
|
||||
UNSET(OUTPUT_NAME_EXPR_1)
|
||||
UNSET(OUTPUT_NAME_EXPR_2)
|
||||
ENDIF(MSVC)
|
||||
ENDMACRO(SET_MSVC_DEBUG_PATH)
|
35
cmake/macros/Win32ImageVersionLinkerFlags.cmake
Normal file
35
cmake/macros/Win32ImageVersionLinkerFlags.cmake
Normal file
@ -0,0 +1,35 @@
|
||||
# Win32 image version linker flags.
|
||||
# Determines the appropriate flags to use with MinGW and MSVC.
|
||||
# The TARGET_VERSION field causes executables to be named
|
||||
# program.exe-1.0 when built with MinGW, so we can't use it.
|
||||
#
|
||||
# The appropriate flags are automatically appended to
|
||||
# CMAKE_EXE_LINKER_FLAGS_(DEBUG|RELEASE) and
|
||||
# CMAKE_SHARED_LINKER_FLAGS_(DEBUG|RELEASE).
|
||||
|
||||
MACRO(WIN32_IMAGE_VERSION_LINKER_FLAGS _major_version _minor_version)
|
||||
IF(WIN32)
|
||||
IF(MSVC)
|
||||
SET(_remove_flags "/version:<TARGET_VERSION_MAJOR>.<TARGET_VERSION_MINOR>")
|
||||
SET(_linker_flags "-version:${_major_version}.${_minor_version}")
|
||||
ELSEIF(MINGW)
|
||||
# NOTE: Also ${CMAKE_GNULD_IMAGE_VERSION}.
|
||||
SET(_remove_flags "-Wl,--major-image-version,<TARGET_VERSION_MAJOR>,--minor-image-version,<TARGET_VERSION_MINOR>")
|
||||
SET(_linker_flags "-Wl,--major-image-version,${_major_version},--minor-image-version,${_minor_version}")
|
||||
ELSE()
|
||||
MESSAGE(FATAL_ERROR "Unknown Windows compiler, please fix WIN32_IMAGE_VERSION_LINKER_FLAGS.")
|
||||
ENDIF()
|
||||
|
||||
# Replace the version flags.
|
||||
STRING(REPLACE "${_remove_flags}" "${_linker_flags}" CMAKE_C_CREATE_SHARED_MODULE "${CMAKE_C_CREATE_SHARED_MODULE}")
|
||||
STRING(REPLACE "${_remove_flags}" "${_linker_flags}" CMAKE_C_CREATE_SHARED_LIBRARY "${CMAKE_C_CREATE_SHARED_LIBRARY}")
|
||||
STRING(REPLACE "${_remove_flags}" "${_linker_flags}" CMAKE_C_LINK_EXECUTABLE "${CMAKE_C_LINK_EXECUTABLE}")
|
||||
STRING(REPLACE "${_remove_flags}" "${_linker_flags}" CMAKE_CXX_CREATE_SHARED_MODULE "${CMAKE_CXX_CREATE_SHARED_MODULE}")
|
||||
STRING(REPLACE "${_remove_flags}" "${_linker_flags}" CMAKE_CXX_CREATE_SHARED_LIBRARY "${CMAKE_CXX_CREATE_SHARED_LIBRARY}")
|
||||
STRING(REPLACE "${_remove_flags}" "${_linker_flags}" CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE}")
|
||||
|
||||
# Unset temporary variables.
|
||||
UNSET(_remove_flags)
|
||||
UNSET(_linker_flags)
|
||||
ENDIF(WIN32)
|
||||
ENDMACRO(WIN32_IMAGE_VERSION_LINKER_FLAGS)
|
28
cmake/macros/WindowsFunctions.cmake
Normal file
28
cmake/macros/WindowsFunctions.cmake
Normal file
@ -0,0 +1,28 @@
|
||||
###### Windows-specific CMake functions. ######
|
||||
|
||||
# Set Windows subsystem when building with MSVC.
|
||||
FUNCTION(SET_WINDOWS_SUBSYSTEM _target _subsystem)
|
||||
IF(WIN32 AND MSVC)
|
||||
GET_TARGET_PROPERTY(TARGET_LINK_FLAGS ${_target} LINK_FLAGS)
|
||||
IF(TARGET_LINK_FLAGS)
|
||||
SET(TARGET_LINK_FLAGS "${TARGET_LINK_FLAGS} ${RP_LINKER_FLAGS_${_subsystem}_EXE}")
|
||||
ELSE()
|
||||
SET(TARGET_LINK_FLAGS "${RP_LINKER_FLAGS_${_subsystem}_EXE}")
|
||||
ENDIF()
|
||||
SET_TARGET_PROPERTIES(${_target} PROPERTIES LINK_FLAGS "${TARGET_LINK_FLAGS}")
|
||||
ENDIF(WIN32 AND MSVC)
|
||||
ENDFUNCTION()
|
||||
|
||||
# Disable automatic manifest generation when building with MSVC.
|
||||
# Only use this if you have a custom manifest specified in the resource script.
|
||||
FUNCTION(SET_WINDOWS_NO_MANIFEST _target)
|
||||
IF(WIN32 AND MSVC)
|
||||
GET_TARGET_PROPERTY(TARGET_LINK_FLAGS ${_target} LINK_FLAGS)
|
||||
IF(TARGET_LINK_FLAGS)
|
||||
SET(TARGET_LINK_FLAGS "${TARGET_LINK_FLAGS} /MANIFEST:NO")
|
||||
ELSE()
|
||||
SET(TARGET_LINK_FLAGS "/MANIFEST:NO")
|
||||
ENDIF()
|
||||
SET_TARGET_PROPERTIES(${_target} PROPERTIES LINK_FLAGS "${TARGET_LINK_FLAGS}")
|
||||
ENDIF(WIN32 AND MSVC)
|
||||
ENDFUNCTION()
|
53
extlib/CMakeLists.txt
Normal file
53
extlib/CMakeLists.txt
Normal file
@ -0,0 +1,53 @@
|
||||
PROJECT(extlib)
|
||||
|
||||
# Set common properties for extlib targets.
|
||||
INCLUDE(SetMSVCDebugPath)
|
||||
FUNCTION(SET_EXTLIB_PROPERTIES)
|
||||
FOREACH(_target ${ARGV})
|
||||
IF(TARGET ${_target})
|
||||
# Exclude from ALL builds.
|
||||
SET_TARGET_PROPERTIES(${_target} PROPERTIES EXCLUDE_FROM_ALL TRUE)
|
||||
ENDIF(TARGET ${_target})
|
||||
ENDFOREACH(_target ${ARGV})
|
||||
ENDFUNCTION(SET_EXTLIB_PROPERTIES)
|
||||
|
||||
# Don't install any of these libraries by default.
|
||||
# zlib and libpng will be installed if they're
|
||||
# built as shared libraries.
|
||||
SET(SKIP_INSTALL_LIBRARIES ON)
|
||||
SET(SKIP_INSTALL_HEADERS ON)
|
||||
SET(SKIP_INSTALL_FILES ON)
|
||||
SET(SKIP_INSTALL_ALL ON)
|
||||
SET(BUILD_SHARED_LIBS OFF)
|
||||
|
||||
# TODO: DirInstallPaths.
|
||||
SET(CMAKE_INSTALL_BINDIR "bin")
|
||||
|
||||
# tinyxml2
|
||||
IF(USE_INTERNAL_XML)
|
||||
# Use the internal copy of TinyXML2.
|
||||
# On Windows, this will build DLLs.
|
||||
# On other systems, this will be statically-linked.
|
||||
# TODO: Build a dylib for Mac OS X.
|
||||
IF(WIN32)
|
||||
SET(SKIP_INSTALL_LIBRARIES OFF)
|
||||
SET(SKIP_INSTALL_ALL OFF)
|
||||
SET(BUILD_STATIC_LIBS OFF)
|
||||
SET(BUILD_SHARED_LIBS ON)
|
||||
ELSE()
|
||||
SET(SKIP_INSTALL_LIBRARIES ON)
|
||||
SET(SKIP_INSTALL_ALL ON)
|
||||
SET(BUILD_STATIC_LIBS ON)
|
||||
SET(BUILD_SHARED_LIBS OFF)
|
||||
ENDIF()
|
||||
|
||||
# Build TinyXML2.
|
||||
ADD_SUBDIRECTORY(tinyxml2)
|
||||
|
||||
# NOTE: Cannot remove targets from all builds
|
||||
# if they're being installed.
|
||||
SET_EXTLIB_PROPERTIES(tinyxml2_static)
|
||||
#SET_EXTLIB_PROPERTIES(tinyxml2)
|
||||
|
||||
# TODO: Set TinyXML2::tinyxml2 and use it in libromdata?
|
||||
ENDIF(USE_INTERNAL_XML)
|
20
extlib/tinyxml2/.gitignore
vendored
Normal file
20
extlib/tinyxml2/.gitignore
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
# intermediate files
|
||||
Win32/
|
||||
x64/
|
||||
ipch/
|
||||
resources/out/
|
||||
tinyxml2/tinyxml2-cbp/bin/
|
||||
tinyxml2/tinyxml2-cbp/obj/
|
||||
tinyxml2/bin/
|
||||
tinyxml2/temp/
|
||||
.artifacts/
|
||||
.projects/
|
||||
*.sdf
|
||||
*.suo
|
||||
*.opensdf
|
||||
*.user
|
||||
*.depend
|
||||
*.layout
|
||||
*.o
|
||||
*.vc.db
|
||||
*.vc.opendb
|
195
extlib/tinyxml2/CMakeLists.txt
Normal file
195
extlib/tinyxml2/CMakeLists.txt
Normal file
@ -0,0 +1,195 @@
|
||||
# rom-properties:
|
||||
# Unix: Add -fpic/-fPIC in order to use this static library in plugins.
|
||||
IF(UNIX AND NOT APPLE)
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fpic -fPIC")
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpic -fPIC")
|
||||
ENDIF(UNIX AND NOT APPLE)
|
||||
|
||||
IF(BIICODE)
|
||||
ADD_BIICODE_TARGETS()
|
||||
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/resources)
|
||||
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/resources DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
|
||||
ENDIF()
|
||||
RETURN()
|
||||
ENDIF(BIICODE)
|
||||
# rom-properties: Disabled; use the main project policies.
|
||||
IF(0)
|
||||
cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
|
||||
cmake_policy(VERSION 2.6)
|
||||
if(POLICY CMP0063)
|
||||
cmake_policy(SET CMP0063 OLD)
|
||||
endif()
|
||||
ENDIF(0) # rom-properties
|
||||
|
||||
project(tinyxml2)
|
||||
# rom-properties: Disabled.
|
||||
IF(0)
|
||||
include(GNUInstallDirs)
|
||||
include(CTest)
|
||||
#enable_testing()
|
||||
ENDIF(0) # rom-properties
|
||||
|
||||
#CMAKE_BUILD_TOOL
|
||||
|
||||
################################
|
||||
# set lib version here
|
||||
|
||||
set(GENERIC_LIB_VERSION "7.0.1")
|
||||
set(GENERIC_LIB_SOVERSION "7")
|
||||
|
||||
################################
|
||||
# Add definitions
|
||||
|
||||
################################
|
||||
# Add targets
|
||||
# By Default shared library is being built
|
||||
# To build static libs also - Do cmake . -DBUILD_STATIC_LIBS:BOOL=ON
|
||||
# User can choose not to build shared library by using cmake -DBUILD_SHARED_LIBS:BOOL=OFF
|
||||
# To build only static libs use cmake . -DBUILD_SHARED_LIBS:BOOL=OFF -DBUILD_STATIC_LIBS:BOOL=ON
|
||||
# To build the tests, use cmake . -DBUILD_TESTS:BOOL=ON
|
||||
# To disable the building of the tests, use cmake . -DBUILD_TESTS:BOOL=OFF
|
||||
|
||||
# rom-properties: Don't use option() here; it's set by extlib.
|
||||
IF(0)
|
||||
option(BUILD_SHARED_LIBS "build as shared library" ON)
|
||||
option(BUILD_TESTS "build xmltest (deprecated: Use BUILD_TESTING)" ON)
|
||||
ENDIF(0) # rom-properties
|
||||
|
||||
# To allow using tinyxml in another shared library
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
|
||||
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
|
||||
set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
|
||||
|
||||
# to distinguish between debug and release lib
|
||||
set(CMAKE_DEBUG_POSTFIX "d")
|
||||
|
||||
# rom-properties: Add the custom .rc file in Windows DLL builds.
|
||||
# FIXME: Don't add it if building both DLL and static.
|
||||
IF(WIN32 AND BUILD_SHARED_LIBS)
|
||||
SET(TINYXML2_RC "tinyxml2.rc")
|
||||
ENDIF(WIN32 AND BUILD_SHARED_LIBS)
|
||||
add_library(tinyxml2 tinyxml2.cpp tinyxml2.h ${TINYXML2_RC})
|
||||
|
||||
set_target_properties(tinyxml2 PROPERTIES
|
||||
COMPILE_DEFINITIONS "TINYXML2_EXPORT"
|
||||
VERSION "${GENERIC_LIB_VERSION}"
|
||||
SOVERSION "${GENERIC_LIB_SOVERSION}")
|
||||
# rom-properties: Set TINYXML2_IMPORT when linking to TinyXML2.
|
||||
TARGET_COMPILE_DEFINITIONS(tinyxml2
|
||||
PRIVATE "TINYXML2_EXPORT"
|
||||
INTERFACE "TINYXML2_IMPORT")
|
||||
|
||||
target_compile_definitions(tinyxml2 PUBLIC $<$<CONFIG:Debug>:TINYXML2_DEBUG>)
|
||||
|
||||
if(DEFINED CMAKE_VERSION AND NOT "${CMAKE_VERSION}" VERSION_LESS "2.8.11")
|
||||
target_include_directories(tinyxml2 PUBLIC
|
||||
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
|
||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
|
||||
|
||||
# rom-properties: This is already set in the platform configuration.
|
||||
IF(0)
|
||||
if(MSVC)
|
||||
target_compile_definitions(tinyxml2 PUBLIC -D_CRT_SECURE_NO_WARNINGS)
|
||||
endif(MSVC)
|
||||
ENDIF(0) # rom-properties
|
||||
else()
|
||||
include_directories(${PROJECT_SOURCE_DIR})
|
||||
|
||||
# rom-properties: This is already set in the platform configuration.
|
||||
IF(0)
|
||||
if(MSVC)
|
||||
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
||||
endif(MSVC)
|
||||
ENDIF(0) # rom-properties
|
||||
endif()
|
||||
|
||||
# rom-properties: Disable target export.
|
||||
IF(0)
|
||||
# export targets for find_package config mode
|
||||
export(TARGETS tinyxml2
|
||||
FILE ${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}Targets.cmake)
|
||||
ENDIF(0) # rom-properties
|
||||
|
||||
# rom-properties:
|
||||
# - Only install on Windows.
|
||||
# - TODO: Install .dylib/.so into macOS bundle.
|
||||
# - Disabled installation of export files and import libraries.
|
||||
# - Use the correct RUNTIME destination.
|
||||
# - Install PDB files.
|
||||
IF(WIN32)
|
||||
install(TARGETS tinyxml2
|
||||
#EXPORT ${CMAKE_PROJECT_NAME}Targets
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
#LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
#ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
)
|
||||
ENDIF(WIN32)
|
||||
|
||||
# rom-properties: Split debug functionality; Windows subsystem.
|
||||
DO_SPLIT_DEBUG(tinyxml2)
|
||||
SET_WINDOWS_SUBSYSTEM(tinyxml2 WIN32)
|
||||
IF(WIN32 AND BUILD_SHARED_LIBS AND INSTALL_DEBUG)
|
||||
# FIXME: Generator expression $<TARGET_PROPERTY:${_target},PDB> didn't work with CPack-3.6.1.
|
||||
INCLUDE(DirInstallPaths)
|
||||
# TODO: Test on MinGW.
|
||||
# FIXME: Generator PDB expression doesn't have the debug postfix for some reason,
|
||||
# so cpack fails in debug builds if we get the PDB property.
|
||||
SET(PDB_FILENAME_D "$<TARGET_FILE_DIR:tinyxml2>/tinyxml2${CMAKE_DEBUG_POSTFIX}.pdb")
|
||||
SET(PDB_FILENAME_R "$<TARGET_FILE_DIR:tinyxml2>/tinyxml2${CMAKE_RELEASE_POSTFIX}.pdb")
|
||||
INSTALL(FILES "${PDB_FILENAME_D}" "${PDB_FILENAME_R}"
|
||||
DESTINATION "${DIR_INSTALL_DLL_DEBUG}"
|
||||
COMPONENT "debug"
|
||||
OPTIONAL
|
||||
)
|
||||
UNSET(PDB_FILENAME_D)
|
||||
UNSET(PDB_FILENAME_R)
|
||||
ENDIF(WIN32 AND BUILD_SHARED_LIBS AND INSTALL_DEBUG)
|
||||
|
||||
# rom-properties: Don't build xmltest or install anything else.
|
||||
IF(0)
|
||||
if(BUILD_TESTING AND BUILD_TESTS)
|
||||
add_executable(xmltest xmltest.cpp)
|
||||
add_dependencies(xmltest tinyxml2)
|
||||
target_link_libraries(xmltest tinyxml2)
|
||||
|
||||
# Copy test resources and create test output directory
|
||||
add_custom_command(TARGET xmltest POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/resources $<TARGET_FILE_DIR:xmltest>/resources
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory $<TARGET_FILE_DIR:xmltest>/resources/out
|
||||
COMMENT "Configuring xmltest resources directory: ${CMAKE_CURRENT_BINARY_DIR}/resources"
|
||||
)
|
||||
|
||||
add_test(NAME xmltest COMMAND xmltest WORKING_DIRECTORY $<TARGET_FILE_DIR:xmltest>)
|
||||
endif()
|
||||
|
||||
install(FILES tinyxml2.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
||||
|
||||
configure_file(tinyxml2.pc.in tinyxml2.pc @ONLY)
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/tinyxml2.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
|
||||
|
||||
# uninstall target
|
||||
if(NOT TARGET uninstall)
|
||||
configure_file(
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
|
||||
IMMEDIATE @ONLY)
|
||||
|
||||
add_custom_target(uninstall
|
||||
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
|
||||
endif()
|
||||
|
||||
include(CMakePackageConfigHelpers)
|
||||
set(TARGETS_EXPORT_NAME "${PROJECT_NAME}Targets")
|
||||
configure_package_config_file(
|
||||
"Config.cmake.in"
|
||||
"${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}Config.cmake"
|
||||
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${CMAKE_PROJECT_NAME}"
|
||||
)
|
||||
install(FILES
|
||||
${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}Config.cmake
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${CMAKE_PROJECT_NAME})
|
||||
|
||||
install(EXPORT ${CMAKE_PROJECT_NAME}Targets NAMESPACE tinyxml2::
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${CMAKE_PROJECT_NAME})
|
||||
ENDIF(0) # rom-properties
|
BIN
extlib/tinyxml2/TinyXML2_small.png
Normal file
BIN
extlib/tinyxml2/TinyXML2_small.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 210 KiB |
16
extlib/tinyxml2/_MODIFIED_TINYXML2.txt
Normal file
16
extlib/tinyxml2/_MODIFIED_TINYXML2.txt
Normal file
@ -0,0 +1,16 @@
|
||||
This copy of tinyxml2-7.0.1 is a modified version of the original.
|
||||
|
||||
The following changes have been made to the original:
|
||||
|
||||
- Non-CMake build infrastructure has been removed.
|
||||
|
||||
- Parts of the original CMakeLists.txt that were not necessary for
|
||||
rom-properties have been disabled, including the test suite.
|
||||
|
||||
- Test cases are no longer built and run.
|
||||
|
||||
- cmake_minimum_required() is disabled, since it interfered with
|
||||
policies set by the main build infrastructure.
|
||||
|
||||
To obtain the original tinyxml2-7.0.1, visit:
|
||||
https://github.com/leethomason/tinyxml2
|
7
extlib/tinyxml2/biicode.conf
Normal file
7
extlib/tinyxml2/biicode.conf
Normal file
@ -0,0 +1,7 @@
|
||||
# Biicode configuration file
|
||||
|
||||
[paths]
|
||||
/
|
||||
|
||||
[dependencies]
|
||||
xmltest.cpp + resources/*.xml
|
108
extlib/tinyxml2/contrib/html5-printer.cpp
Normal file
108
extlib/tinyxml2/contrib/html5-printer.cpp
Normal file
@ -0,0 +1,108 @@
|
||||
// g++ -Wall -O2 contrib/html5-printer.cpp -o html5-printer -ltinyxml2
|
||||
|
||||
// This program demonstrates how to use "tinyxml2" to generate conformant HTML5
|
||||
// by deriving from the "tinyxml2::XMLPrinter" class.
|
||||
|
||||
// http://dev.w3.org/html5/markup/syntax.html
|
||||
|
||||
// In HTML5, there are 16 so-called "void" elements. "void elements" NEVER have
|
||||
// inner content (but they MAY have attributes), and are assumed to be self-closing.
|
||||
// An example of a self-closig HTML5 element is "<br/>" (line break)
|
||||
// All other elements are called "non-void" and MUST never self-close.
|
||||
// Examples: "<div class='lolcats'></div>".
|
||||
|
||||
// tinyxml2::XMLPrinter will emit _ALL_ XML elements with no inner content as
|
||||
// self-closing. This behavior produces space-effeceint XML, but incorrect HTML5.
|
||||
|
||||
// Author: Dennis Jenkins, dennis (dot) jenkins (dot) 75 (at) gmail (dot) com.
|
||||
// License: Same as tinyxml2 (zlib, see below)
|
||||
// This example is a small contribution to the world! Enjoy it!
|
||||
|
||||
/*
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any
|
||||
damages arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any
|
||||
purpose, including commercial applications, and to alter it and
|
||||
redistribute it freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must
|
||||
not claim that you wrote the original software. If you use this
|
||||
software in a product, an acknowledgment in the product documentation
|
||||
would be appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and
|
||||
must not be misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
*/
|
||||
|
||||
|
||||
#include "../tinyxml2.h"
|
||||
#include <iostream>
|
||||
|
||||
#if defined (_MSC_VER)
|
||||
#define strcasecmp stricmp
|
||||
#endif
|
||||
|
||||
using namespace tinyxml2;
|
||||
|
||||
// Contrived input containing a mix of void and non-void HTML5 elements.
|
||||
// When printed via XMLPrinter, some non-void elements will self-close (not valid HTML5).
|
||||
static const char input[] =
|
||||
"<html><body><p style='a'></p><br/>©<col a='1' b='2'/><div a='1'></div></body></html>";
|
||||
|
||||
// XMLPrinterHTML5 is small enough, just put the entire implementation inline.
|
||||
class XMLPrinterHTML5 : public XMLPrinter
|
||||
{
|
||||
public:
|
||||
XMLPrinterHTML5 (FILE* file=0, bool compact = false, int depth = 0) :
|
||||
XMLPrinter (file, compact, depth)
|
||||
{}
|
||||
|
||||
protected:
|
||||
virtual void CloseElement () {
|
||||
if (_elementJustOpened && !isVoidElement (_stack.PeekTop())) {
|
||||
SealElementIfJustOpened();
|
||||
}
|
||||
XMLPrinter::CloseElement();
|
||||
}
|
||||
|
||||
virtual bool isVoidElement (const char *name) {
|
||||
// Complete list of all HTML5 "void elements",
|
||||
// http://dev.w3.org/html5/markup/syntax.html
|
||||
static const char *list[] = {
|
||||
"area", "base", "br", "col", "command", "embed", "hr", "img",
|
||||
"input", "keygen", "link", "meta", "param", "source", "track", "wbr",
|
||||
NULL
|
||||
};
|
||||
|
||||
// I could use 'bsearch', but I don't have MSVC to test on (it would work with gcc/libc).
|
||||
for (const char **p = list; *p; ++p) {
|
||||
if (!strcasecmp (name, *p)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
int main (void) {
|
||||
XMLDocument doc (false);
|
||||
doc.Parse (input);
|
||||
|
||||
std::cout << "INPUT:\n" << input << "\n\n";
|
||||
|
||||
XMLPrinter prn (NULL, true);
|
||||
doc.Print (&prn);
|
||||
std::cout << "XMLPrinter (not valid HTML5):\n" << prn.CStr() << "\n\n";
|
||||
|
||||
XMLPrinterHTML5 html5 (NULL, true);
|
||||
doc.Print (&html5);
|
||||
std::cout << "XMLPrinterHTML5:\n" << html5.CStr() << "\n";
|
||||
|
||||
return 0;
|
||||
}
|
2445
extlib/tinyxml2/dox
Normal file
2445
extlib/tinyxml2/dox
Normal file
File diff suppressed because it is too large
Load Diff
323
extlib/tinyxml2/readme.md
Normal file
323
extlib/tinyxml2/readme.md
Normal file
@ -0,0 +1,323 @@
|
||||
TinyXML-2
|
||||
=========
|
||||
|
||||
[](https://travis-ci.org/leethomason/tinyxml2) [](https://ci.appveyor.com/project/leethomason/tinyxml2)
|
||||
|
||||

|
||||
|
||||
TinyXML-2 is a simple, small, efficient, C++ XML parser that can be
|
||||
easily integrated into other programs.
|
||||
|
||||
The master is hosted on github:
|
||||
https://github.com/leethomason/tinyxml2
|
||||
|
||||
The online HTML version of these docs:
|
||||
http://leethomason.github.io/tinyxml2/
|
||||
|
||||
Examples are in the "related pages" tab of the HTML docs.
|
||||
|
||||
What it does.
|
||||
-------------
|
||||
|
||||
In brief, TinyXML-2 parses an XML document, and builds from that a
|
||||
Document Object Model (DOM) that can be read, modified, and saved.
|
||||
|
||||
XML stands for "eXtensible Markup Language." It is a general purpose
|
||||
human and machine readable markup language to describe arbitrary data.
|
||||
All those random file formats created to store application data can
|
||||
all be replaced with XML. One parser for everything.
|
||||
|
||||
http://en.wikipedia.org/wiki/XML
|
||||
|
||||
There are different ways to access and interact with XML data.
|
||||
TinyXML-2 uses a Document Object Model (DOM), meaning the XML data is parsed
|
||||
into a C++ objects that can be browsed and manipulated, and then
|
||||
written to disk or another output stream. You can also construct an XML document
|
||||
from scratch with C++ objects and write this to disk or another output
|
||||
stream. You can even use TinyXML-2 to stream XML programmatically from
|
||||
code without creating a document first.
|
||||
|
||||
TinyXML-2 is designed to be easy and fast to learn. It is one header and
|
||||
one cpp file. Simply add these to your project and off you go.
|
||||
There is an example file - xmltest.cpp - to get you started.
|
||||
|
||||
TinyXML-2 is released under the ZLib license,
|
||||
so you can use it in open source or commercial code. The details
|
||||
of the license are at the top of every source file.
|
||||
|
||||
TinyXML-2 attempts to be a flexible parser, but with truly correct and
|
||||
compliant XML output. TinyXML-2 should compile on any reasonably C++
|
||||
compliant system. It does not rely on exceptions, RTTI, or the STL.
|
||||
|
||||
What it doesn't do.
|
||||
-------------------
|
||||
|
||||
TinyXML-2 doesn't parse or use DTDs (Document Type Definitions) or XSLs
|
||||
(eXtensible Stylesheet Language.) There are other parsers out there
|
||||
that are much more fully featured. But they are also much bigger,
|
||||
take longer to set up in your project, have a higher learning curve,
|
||||
and often have a more restrictive license. If you are working with
|
||||
browsers or have more complete XML needs, TinyXML-2 is not the parser for you.
|
||||
|
||||
TinyXML-1 vs. TinyXML-2
|
||||
-----------------------
|
||||
|
||||
TinyXML-2 is now the focus of all development, well tested, and your
|
||||
best choice between the two APIs. At this point, unless you are maintaining
|
||||
legacy code, you should choose TinyXML-2.
|
||||
|
||||
TinyXML-2 uses a similar API to TinyXML-1 and the same
|
||||
rich test cases. But the implementation of the parser is completely re-written
|
||||
to make it more appropriate for use in a game. It uses less memory, is faster,
|
||||
and uses far fewer memory allocations.
|
||||
|
||||
TinyXML-2 has no requirement or support for STL. By returning `const char*`
|
||||
TinyXML-2 can be much more efficient with memory usage. (TinyXML-1 did support
|
||||
and use STL, but consumed much more memory for the DOM representation.)
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
### Code Page
|
||||
|
||||
TinyXML-2 uses UTF-8 exclusively when interpreting XML. All XML is assumed to
|
||||
be UTF-8.
|
||||
|
||||
Filenames for loading / saving are passed unchanged to the underlying OS.
|
||||
|
||||
### Memory Model
|
||||
|
||||
An XMLDocument is a C++ object like any other, that can be on the stack, or
|
||||
new'd and deleted on the heap.
|
||||
|
||||
However, any sub-node of the Document, XMLElement, XMLText, etc, can only
|
||||
be created by calling the appropriate XMLDocument::NewElement, NewText, etc.
|
||||
method. Although you have pointers to these objects, they are still owned
|
||||
by the Document. When the Document is deleted, so are all the nodes it contains.
|
||||
|
||||
### White Space
|
||||
|
||||
#### Whitespace Preservation (default)
|
||||
|
||||
Microsoft has an excellent article on white space: http://msdn.microsoft.com/en-us/library/ms256097.aspx
|
||||
|
||||
By default, TinyXML-2 preserves white space in a (hopefully) sane way that is almost compliant with the
|
||||
spec. (TinyXML-1 used a completely different model, much more similar to 'collapse', below.)
|
||||
|
||||
As a first step, all newlines / carriage-returns / line-feeds are normalized to a
|
||||
line-feed character, as required by the XML spec.
|
||||
|
||||
White space in text is preserved. For example:
|
||||
|
||||
<element> Hello, World</element>
|
||||
|
||||
The leading space before the "Hello" and the double space after the comma are
|
||||
preserved. Line-feeds are preserved, as in this example:
|
||||
|
||||
<element> Hello again,
|
||||
World</element>
|
||||
|
||||
However, white space between elements is **not** preserved. Although not strictly
|
||||
compliant, tracking and reporting inter-element space is awkward, and not normally
|
||||
valuable. TinyXML-2 sees these as the same XML:
|
||||
|
||||
<document>
|
||||
<data>1</data>
|
||||
<data>2</data>
|
||||
<data>3</data>
|
||||
</document>
|
||||
|
||||
<document><data>1</data><data>2</data><data>3</data></document>
|
||||
|
||||
#### Whitespace Collapse
|
||||
|
||||
For some applications, it is preferable to collapse whitespace. Collapsing
|
||||
whitespace gives you "HTML-like" behavior, which is sometimes more suitable
|
||||
for hand typed documents.
|
||||
|
||||
TinyXML-2 supports this with the 'whitespace' parameter to the XMLDocument constructor.
|
||||
(The default is to preserve whitespace, as described above.)
|
||||
|
||||
However, you may also use COLLAPSE_WHITESPACE, which will:
|
||||
|
||||
* Remove leading and trailing whitespace
|
||||
* Convert newlines and line-feeds into a space character
|
||||
* Collapse a run of any number of space characters into a single space character
|
||||
|
||||
Note that (currently) there is a performance impact for using COLLAPSE_WHITESPACE.
|
||||
It essentially causes the XML to be parsed twice.
|
||||
|
||||
#### Error Reporting
|
||||
|
||||
TinyXML-2 reports the line number of any errors in an XML document that
|
||||
cannot be parsed correctly. In addition, all nodes (elements, declarations,
|
||||
text, comments etc.) and attributes have a line number recorded as they are parsed.
|
||||
This allows an application that performs additional validation of the parsed
|
||||
XML document (e.g. application-implemented DTD validation) to report
|
||||
line number information for error messages.
|
||||
|
||||
### Entities
|
||||
|
||||
TinyXML-2 recognizes the pre-defined "character entities", meaning special
|
||||
characters. Namely:
|
||||
|
||||
& &
|
||||
< <
|
||||
> >
|
||||
" "
|
||||
' '
|
||||
|
||||
These are recognized when the XML document is read, and translated to their
|
||||
UTF-8 equivalents. For instance, text with the XML of:
|
||||
|
||||
Far & Away
|
||||
|
||||
will have the Value() of "Far & Away" when queried from the XMLText object,
|
||||
and will be written back to the XML stream/file as an ampersand.
|
||||
|
||||
Additionally, any character can be specified by its Unicode code point:
|
||||
The syntax ` ` or ` ` are both to the non-breaking space character.
|
||||
This is called a 'numeric character reference'. Any numeric character reference
|
||||
that isn't one of the special entities above, will be read, but written as a
|
||||
regular code point. The output is correct, but the entity syntax isn't preserved.
|
||||
|
||||
### Printing
|
||||
|
||||
#### Print to file
|
||||
You can directly use the convenience function:
|
||||
|
||||
XMLDocument doc;
|
||||
...
|
||||
doc.SaveFile( "foo.xml" );
|
||||
|
||||
Or the XMLPrinter class:
|
||||
|
||||
XMLPrinter printer( fp );
|
||||
doc.Print( &printer );
|
||||
|
||||
#### Print to memory
|
||||
Printing to memory is supported by the XMLPrinter.
|
||||
|
||||
XMLPrinter printer;
|
||||
doc.Print( &printer );
|
||||
// printer.CStr() has a const char* to the XML
|
||||
|
||||
#### Print without an XMLDocument
|
||||
|
||||
When loading, an XML parser is very useful. However, sometimes
|
||||
when saving, it just gets in the way. The code is often set up
|
||||
for streaming, and constructing the DOM is just overhead.
|
||||
|
||||
The Printer supports the streaming case. The following code
|
||||
prints out a trivially simple XML file without ever creating
|
||||
an XML document.
|
||||
|
||||
XMLPrinter printer( fp );
|
||||
printer.OpenElement( "foo" );
|
||||
printer.PushAttribute( "foo", "bar" );
|
||||
printer.CloseElement();
|
||||
|
||||
Examples
|
||||
--------
|
||||
|
||||
#### Load and parse an XML file.
|
||||
|
||||
/* ------ Example 1: Load and parse an XML file. ---- */
|
||||
{
|
||||
XMLDocument doc;
|
||||
doc.LoadFile( "dream.xml" );
|
||||
}
|
||||
|
||||
#### Lookup information.
|
||||
|
||||
/* ------ Example 2: Lookup information. ---- */
|
||||
{
|
||||
XMLDocument doc;
|
||||
doc.LoadFile( "dream.xml" );
|
||||
|
||||
// Structure of the XML file:
|
||||
// - Element "PLAY" the root Element, which is the
|
||||
// FirstChildElement of the Document
|
||||
// - - Element "TITLE" child of the root PLAY Element
|
||||
// - - - Text child of the TITLE Element
|
||||
|
||||
// Navigate to the title, using the convenience function,
|
||||
// with a dangerous lack of error checking.
|
||||
const char* title = doc.FirstChildElement( "PLAY" )->FirstChildElement( "TITLE" )->GetText();
|
||||
printf( "Name of play (1): %s\n", title );
|
||||
|
||||
// Text is just another Node to TinyXML-2. The more
|
||||
// general way to get to the XMLText:
|
||||
XMLText* textNode = doc.FirstChildElement( "PLAY" )->FirstChildElement( "TITLE" )->FirstChild()->ToText();
|
||||
title = textNode->Value();
|
||||
printf( "Name of play (2): %s\n", title );
|
||||
}
|
||||
|
||||
Using and Installing
|
||||
--------------------
|
||||
|
||||
There are 2 files in TinyXML-2:
|
||||
* tinyxml2.cpp
|
||||
* tinyxml2.h
|
||||
|
||||
And additionally a test file:
|
||||
* xmltest.cpp
|
||||
|
||||
Simply compile and run. There is a visual studio 2017 project included, a simple Makefile,
|
||||
an Xcode project, a Code::Blocks project, and a cmake CMakeLists.txt included to help you.
|
||||
The top of tinyxml.h even has a simple g++ command line if you are are Unix/Linuk/BSD and
|
||||
don't want to use a build system.
|
||||
|
||||
Versioning
|
||||
----------
|
||||
|
||||
TinyXML-2 uses semantic versioning. http://semver.org/ Releases are now tagged in github.
|
||||
|
||||
Note that the major version will (probably) change fairly rapidly. API changes are fairly
|
||||
common.
|
||||
|
||||
Documentation
|
||||
-------------
|
||||
|
||||
The documentation is build with Doxygen, using the 'dox'
|
||||
configuration file.
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
TinyXML-2 is released under the zlib license:
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any
|
||||
damages arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any
|
||||
purpose, including commercial applications, and to alter it and
|
||||
redistribute it freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must
|
||||
not claim that you wrote the original software. If you use this
|
||||
software in a product, an acknowledgment in the product documentation
|
||||
would be appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and
|
||||
must not be misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
|
||||
Contributors
|
||||
------------
|
||||
|
||||
Thanks very much to everyone who sends suggestions, bugs, ideas, and
|
||||
encouragement. It all helps, and makes this project fun.
|
||||
|
||||
The original TinyXML-1 has many contributors, who all deserve thanks
|
||||
in shaping what is a very successful library. Extra thanks to Yves
|
||||
Berquin and Andrew Ellerton who were key contributors.
|
||||
|
||||
TinyXML-2 grew from that effort. Lee Thomason is the original author
|
||||
of TinyXML-2 (and TinyXML-1) but TinyXML-2 has been and is being improved
|
||||
by many contributors.
|
||||
|
||||
Thanks to John Mackay at http://john.mackay.rosalilastudio.com for the TinyXML-2 logo!
|
||||
|
||||
|
4546
extlib/tinyxml2/resources/dream.xml
Normal file
4546
extlib/tinyxml2/resources/dream.xml
Normal file
File diff suppressed because it is too large
Load Diff
0
extlib/tinyxml2/resources/empty.xml
Normal file
0
extlib/tinyxml2/resources/empty.xml
Normal file
11
extlib/tinyxml2/resources/utf8test.xml
Normal file
11
extlib/tinyxml2/resources/utf8test.xml
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document>
|
||||
<English name="name" value="value">The world has many languages</English>
|
||||
<Russian name="название(имя)" value="ценность">Мир имеет много языков</Russian>
|
||||
<Spanish name="el nombre" value="el valor">el mundo tiene muchos idiomas</Spanish>
|
||||
<SimplifiedChinese name="名字" value="价值">世界有很多语言</SimplifiedChinese>
|
||||
<Русский название="name" ценность="value"><имеет></Русский>
|
||||
<汉语 名字="name" 价值="value">世界有很多语言</汉语>
|
||||
<Heavy>"Mëtæl!"</Heavy>
|
||||
<ä>Umlaut Element</ä>
|
||||
</document>
|
11
extlib/tinyxml2/resources/utf8testverify.xml
Normal file
11
extlib/tinyxml2/resources/utf8testverify.xml
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document>
|
||||
<English name="name" value="value">The world has many languages</English>
|
||||
<Russian name="название(имя)" value="ценность">Мир имеет много языков</Russian>
|
||||
<Spanish name="el nombre" value="el valor">el mundo tiene muchos idiomas</Spanish>
|
||||
<SimplifiedChinese name="名字" value="价值">世界有很多语言</SimplifiedChinese>
|
||||
<Русский название="name" ценность="value"><имеет></Русский>
|
||||
<汉语 名字="name" 价值="value">世界有很多语言</汉语>
|
||||
<Heavy>"Mëtæl!"</Heavy>
|
||||
<ä>Umlaut Element</ä>
|
||||
</document>
|
1
extlib/tinyxml2/resources/xmltest-4636783552757760.xml
Normal file
1
extlib/tinyxml2/resources/xmltest-4636783552757760.xml
Normal file
File diff suppressed because one or more lines are too long
1
extlib/tinyxml2/resources/xmltest-5330.xml
Normal file
1
extlib/tinyxml2/resources/xmltest-5330.xml
Normal file
File diff suppressed because one or more lines are too long
1
extlib/tinyxml2/resources/xmltest-5720541257269248.xml
Normal file
1
extlib/tinyxml2/resources/xmltest-5720541257269248.xml
Normal file
File diff suppressed because one or more lines are too long
145
extlib/tinyxml2/setversion.py
Executable file
145
extlib/tinyxml2/setversion.py
Executable file
@ -0,0 +1,145 @@
|
||||
# Python program to set the version.
|
||||
##############################################
|
||||
|
||||
import re
|
||||
import sys
|
||||
import optparse
|
||||
|
||||
def fileProcess( name, lineFunction ):
|
||||
filestream = open( name, 'r' )
|
||||
if filestream.closed:
|
||||
print( "file " + name + " not open." )
|
||||
return
|
||||
|
||||
output = ""
|
||||
print( "--- Processing " + name + " ---------" )
|
||||
while 1:
|
||||
line = filestream.readline()
|
||||
if not line: break
|
||||
output += lineFunction( line )
|
||||
filestream.close()
|
||||
|
||||
if not output: return # basic error checking
|
||||
|
||||
print( "Writing file " + name )
|
||||
filestream = open( name, "w" );
|
||||
filestream.write( output );
|
||||
filestream.close()
|
||||
|
||||
def echoInput( line ):
|
||||
return line
|
||||
|
||||
parser = optparse.OptionParser( "usage: %prog major minor build" )
|
||||
(options, args) = parser.parse_args()
|
||||
if len(args) != 3:
|
||||
parser.error( "incorrect number of arguments" );
|
||||
|
||||
major = args[0]
|
||||
minor = args[1]
|
||||
build = args[2]
|
||||
versionStr = major + "." + minor + "." + build
|
||||
|
||||
print ("Setting dox,tinyxml2.h")
|
||||
print ("Version: " + major + "." + minor + "." + build)
|
||||
|
||||
#### Write the tinyxml.h ####
|
||||
|
||||
def engineRule( line ):
|
||||
|
||||
matchMajor = "static const int TIXML2_MAJOR_VERSION"
|
||||
matchMinor = "static const int TIXML2_MINOR_VERSION"
|
||||
matchBuild = "static const int TIXML2_PATCH_VERSION"
|
||||
|
||||
if line[0:len(matchMajor)] == matchMajor:
|
||||
print( "1)tinyxml2.h Major found" )
|
||||
return matchMajor + " = " + major + ";\n"
|
||||
|
||||
elif line[0:len(matchMinor)] == matchMinor:
|
||||
print( "2)tinyxml2.h Minor found" )
|
||||
return matchMinor + " = " + minor + ";\n"
|
||||
|
||||
elif line[0:len(matchBuild)] == matchBuild:
|
||||
print( "3)tinyxml2.h Build found" )
|
||||
return matchBuild + " = " + build + ";\n"
|
||||
|
||||
else:
|
||||
return line;
|
||||
|
||||
fileProcess( "tinyxml2.h", engineRule )
|
||||
|
||||
def macroVersionRule( line ):
|
||||
|
||||
matchMajor = "#define TINYXML2_MAJOR_VERSION"
|
||||
matchMinor = "#define TINYXML2_MINOR_VERSION"
|
||||
matchBuild = "#define TINYXML2_PATCH_VERSION"
|
||||
|
||||
if line[0:len(matchMajor)] == matchMajor:
|
||||
print( "1)macro Major found" )
|
||||
return matchMajor + " " + major + "\n"
|
||||
|
||||
elif line[0:len(matchMinor)] == matchMinor:
|
||||
print( "2)macro Minor found" )
|
||||
return matchMinor + " " + minor + "\n"
|
||||
|
||||
elif line[0:len(matchBuild)] == matchBuild:
|
||||
print( "3)macro Build found" )
|
||||
return matchBuild + " " + build + "\n"
|
||||
|
||||
else:
|
||||
return line;
|
||||
|
||||
fileProcess("tinyxml2.h", macroVersionRule)
|
||||
|
||||
#### Write the dox ####
|
||||
|
||||
def doxRule( line ):
|
||||
|
||||
match = "PROJECT_NUMBER"
|
||||
|
||||
if line[0:len( match )] == match:
|
||||
print( "dox project found" )
|
||||
return "PROJECT_NUMBER = " + major + "." + minor + "." + build + "\n"
|
||||
|
||||
else:
|
||||
return line;
|
||||
|
||||
fileProcess( "dox", doxRule )
|
||||
|
||||
|
||||
#### Write the CMakeLists.txt ####
|
||||
|
||||
def cmakeRule1( line ):
|
||||
|
||||
matchVersion = "set(GENERIC_LIB_VERSION"
|
||||
|
||||
if line[0:len(matchVersion)] == matchVersion:
|
||||
print( "1)tinyxml2.h Major found" )
|
||||
return matchVersion + " \"" + major + "." + minor + "." + build + "\")" + "\n"
|
||||
|
||||
else:
|
||||
return line;
|
||||
|
||||
fileProcess( "CMakeLists.txt", cmakeRule1 )
|
||||
|
||||
def cmakeRule2( line ):
|
||||
|
||||
matchSoversion = "set(GENERIC_LIB_SOVERSION"
|
||||
|
||||
if line[0:len(matchSoversion)] == matchSoversion:
|
||||
print( "1)tinyxml2.h Major found" )
|
||||
return matchSoversion + " \"" + major + "\")" + "\n"
|
||||
|
||||
else:
|
||||
return line;
|
||||
|
||||
fileProcess( "CMakeLists.txt", cmakeRule2 )
|
||||
|
||||
print( "Release note:" )
|
||||
print( '1. Build. g++ -Wall -DTINYXML2_DEBUG tinyxml2.cpp xmltest.cpp -o gccxmltest.exe' )
|
||||
print( '2. Commit. git commit -am"setting the version to ' + versionStr + '"' )
|
||||
print( '3. Tag. git tag ' + versionStr )
|
||||
print( ' OR git tag -a ' + versionStr + ' -m [tag message]' )
|
||||
print( 'Remember to "git push" both code and tag. For the tag:' )
|
||||
print( 'git push origin [tagname]')
|
||||
|
||||
|
2837
extlib/tinyxml2/tinyxml2.cpp
Normal file
2837
extlib/tinyxml2/tinyxml2.cpp
Normal file
File diff suppressed because it is too large
Load Diff
2309
extlib/tinyxml2/tinyxml2.h
Normal file
2309
extlib/tinyxml2/tinyxml2.h
Normal file
File diff suppressed because it is too large
Load Diff
10
extlib/tinyxml2/tinyxml2.pc.in
Normal file
10
extlib/tinyxml2/tinyxml2.pc.in
Normal file
@ -0,0 +1,10 @@
|
||||
prefix=@CMAKE_INSTALL_PREFIX@
|
||||
exec_prefix=${prefix}
|
||||
libdir=${exec_prefix}/@CMAKE_INSTALL_LIBDIR@
|
||||
includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@
|
||||
|
||||
Name: TinyXML2
|
||||
Description: simple, small, C++ XML parser
|
||||
Version: @GENERIC_LIB_VERSION@
|
||||
Libs: -L${libdir} -ltinyxml2
|
||||
Cflags: -I${includedir}
|
47
extlib/tinyxml2/tinyxml2.rc
Normal file
47
extlib/tinyxml2/tinyxml2.rc
Normal file
@ -0,0 +1,47 @@
|
||||
#include <windows.h>
|
||||
|
||||
#define TINYXML2_VERSION_NUMERIC 7,0,1,0
|
||||
#define TINYXML2_VERSION_STRING "7.0.1"
|
||||
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION TINYXML2_VERSION_NUMERIC
|
||||
PRODUCTVERSION TINYXML2_VERSION_NUMERIC
|
||||
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS VS_FF_DEBUG
|
||||
#else
|
||||
FILEFLAGS 0
|
||||
#endif
|
||||
FILEOS VOS__WINDOWS32
|
||||
FILETYPE VFT_DLL
|
||||
FILESUBTYPE 0 // not used
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904B0"
|
||||
//language ID = U.S. English, char set = Unicode
|
||||
BEGIN
|
||||
VALUE "FileDescription", "TinyXML-2\0"
|
||||
VALUE "FileVersion", TINYXML2_VERSION_STRING "\0"
|
||||
#ifdef _DEBUG
|
||||
VALUE "InternalName", "tinyxml2d.dll\0"
|
||||
#else
|
||||
VALUE "InternalName", "tinyxml2.dll\0"
|
||||
#endif
|
||||
VALUE "LegalCopyright", "(C) 2000-2018 Lee Thomason\0"
|
||||
#ifdef _DEBUG
|
||||
VALUE "OriginalFilename", "tinyxml2d.dll\0"
|
||||
#else
|
||||
VALUE "OriginalFilename", "tinyxml2.dll\0"
|
||||
#endif
|
||||
VALUE "ProductName", "TinyXML-2\0"
|
||||
VALUE "ProductVersion", TINYXML2_VERSION_STRING "\0"
|
||||
VALUE "Comments", "For more information visit https://github.com/leethomason/tinyxml2\0"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x0409, 1252
|
||||
END
|
||||
END
|
2355
extlib/tinyxml2/xmltest.cpp
Normal file
2355
extlib/tinyxml2/xmltest.cpp
Normal file
File diff suppressed because it is too large
Load Diff
@ -71,13 +71,19 @@ ADD_EXECUTABLE(mst06
|
||||
${mst06_SRCS} ${mst06_H}
|
||||
${mst06_OS_SRCS}
|
||||
)
|
||||
SET_PROPERTY(TARGET mst06 PROPERTY C_STANDARD 99)
|
||||
SET_PROPERTY(TARGET mst06 PROPERTY CXX_STANDARD 11)
|
||||
DO_SPLIT_DEBUG(mst06)
|
||||
TARGET_INCLUDE_DIRECTORIES(mst06 PRIVATE "${CMAKE_CURRENT_BINARY_DIR}")
|
||||
|
||||
# TODO: Enable wildcard expansion on Windows?
|
||||
INCLUDE(SetWindowsEntrypoint)
|
||||
SET_WINDOWS_ENTRYPOINT(mst06 wmain OFF)
|
||||
|
||||
IF(ICONV_LIBRARY)
|
||||
TARGET_LINK_LIBRARIES(mst06 PRIVATE ${ICONV_LIBRARY})
|
||||
ENDIF(ICONV_LIBRARY)
|
||||
|
||||
# TODO: Enable wildcard expansion on Windows?
|
||||
INCLUDE(SetWindowsEntrypoint)
|
||||
SET_WINDOWS_ENTRYPOINT(mst06 wmain OFF)
|
||||
IF(ENABLE_XML AND TinyXML2_FOUND)
|
||||
TARGET_LINK_LIBRARIES(mst06 PRIVATE ${TinyXML2_LIBRARY})
|
||||
TARGET_INCLUDE_DIRECTORIES(mst06 PRIVATE ${TinyXML2_INCLUDE_DIR})
|
||||
ENDIF(ENABLE_XML AND TinyXML2_FOUND)
|
||||
|
71
src/Mst.cpp
71
src/Mst.cpp
@ -41,6 +41,10 @@ using std::vector;
|
||||
// Text encoding functions.
|
||||
#include "TextFuncs.hpp"
|
||||
|
||||
// TODO: Check ENABLE_XML?
|
||||
#include <tinyxml2.h>
|
||||
using namespace tinyxml2;
|
||||
|
||||
Mst::Mst()
|
||||
: m_version(1)
|
||||
, m_isBigEndian(true)
|
||||
@ -53,6 +57,10 @@ Mst::Mst()
|
||||
*/
|
||||
int Mst::loadMST(const TCHAR *filename)
|
||||
{
|
||||
if (!filename) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
int err;
|
||||
|
||||
// Clear the current string tables.
|
||||
@ -310,6 +318,69 @@ int Mst::loadMST(const TCHAR *filename)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom XMLPrinter that uses tabs instead of spaces.
|
||||
*/
|
||||
class MstXMLPrinter : public XMLPrinter
|
||||
{
|
||||
public:
|
||||
MstXMLPrinter(FILE *file = nullptr, bool compact = false, int depth = 0)
|
||||
: XMLPrinter(file, compact, depth) { }
|
||||
|
||||
public:
|
||||
void PrintSpace(int depth) final
|
||||
{
|
||||
for (; depth > 0; depth--) {
|
||||
Putc('\t');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Save the string table as XML.
|
||||
* @param filename XML filename.
|
||||
* @return 0 on success; negative POSIX error code or positive TinyXML2 error code on error.
|
||||
*/
|
||||
int Mst::saveXML(const TCHAR *filename) const
|
||||
{
|
||||
if (!filename) {
|
||||
return -EINVAL;
|
||||
} else if (m_vStrTbl.empty()) {
|
||||
return -ENODATA; // TODO: Better error code?
|
||||
}
|
||||
|
||||
// Create an XML document.
|
||||
XMLDocument xml;
|
||||
XMLDeclaration *xml_decl = xml.NewDeclaration();
|
||||
xml.InsertFirstChild(xml_decl);
|
||||
XMLElement *xml_msgTbl = xml.NewElement("mst06");
|
||||
xml.InsertEndChild(xml_msgTbl);
|
||||
xml_msgTbl->SetAttribute("name", m_name.c_str());
|
||||
|
||||
size_t i = 0;
|
||||
for (auto iter = m_vStrTbl.cbegin(); iter != m_vStrTbl.cend(); ++iter, ++i) {
|
||||
XMLElement *xml_msg = xml.NewElement("message");
|
||||
xml_msgTbl->InsertEndChild(xml_msg);
|
||||
xml_msg->SetAttribute("index", static_cast<unsigned int>(i));
|
||||
xml_msg->SetAttribute("name", iter->first.c_str());
|
||||
if (!iter->second.empty()) {
|
||||
xml_msg->SetText(utf16_to_utf8(iter->second).c_str());
|
||||
}
|
||||
}
|
||||
|
||||
// Save the XML document.
|
||||
// NOTE: Using our custom XMLPrinter for tabs instead of spaces.
|
||||
FILE *f_xml = _tfopen(filename, _T("w"));
|
||||
if (!f_xml) {
|
||||
// Error opening the XML file.
|
||||
return -errno;
|
||||
}
|
||||
|
||||
MstXMLPrinter stream(f_xml, false);
|
||||
xml.Print(&stream);
|
||||
return xml.ErrorID();
|
||||
}
|
||||
|
||||
/**
|
||||
* Dump the string table to stdout.
|
||||
*/
|
||||
|
16
src/Mst.hpp
16
src/Mst.hpp
@ -46,15 +46,23 @@ class Mst
|
||||
*/
|
||||
int loadMST(const TCHAR *filename);
|
||||
|
||||
/**
|
||||
* Save the string table as XML.
|
||||
* @param filename XML filename.
|
||||
* @return 0 on success; negative POSIX error code or positive TinyXML2 error code on error.
|
||||
*/
|
||||
int saveXML(const TCHAR *filename) const;
|
||||
|
||||
public:
|
||||
// TODO: Save MST, Load XML
|
||||
// TODO: Iterator and mutator functions.
|
||||
|
||||
public:
|
||||
/**
|
||||
* Dump the string table to stdout.
|
||||
*/
|
||||
void dump(void) const;
|
||||
|
||||
public:
|
||||
// TODO: Save MST, Load XML, Save XML
|
||||
// TODO: Iterator and mutator functions.
|
||||
|
||||
public:
|
||||
/** Accessor functions. **/
|
||||
|
||||
|
40
src/main.cpp
40
src/main.cpp
@ -26,17 +26,25 @@
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
using std::pair;
|
||||
using std::string;
|
||||
using std::vector;
|
||||
using std::pair;
|
||||
using std::wstring;
|
||||
|
||||
#include "tcharx.h"
|
||||
#include "Mst.hpp"
|
||||
|
||||
#ifdef _WIN32
|
||||
# define SLASH_CHAR _T('\\')
|
||||
#else /* !_WIN32 */
|
||||
# define SLASH_CHAR '/'
|
||||
#endif
|
||||
|
||||
int _tmain(int argc, TCHAR *argv[])
|
||||
{
|
||||
if (argc != 2) {
|
||||
_ftprintf(stderr, _T("Syntax: %s mst_file.mst\n"), argv[0]);
|
||||
_ftprintf(stderr, _T("File will be converted to mst_file.xml.\n"));
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
@ -47,8 +55,32 @@ int _tmain(int argc, TCHAR *argv[])
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// Dump the MST.
|
||||
mst.dump();
|
||||
// Create a filename for the XML file.
|
||||
// NOTE: If it's an absolute path, the XML file will be
|
||||
// stored in the same directory as the MST file.
|
||||
tstring xml_filename(argv[1]);
|
||||
bool replaced_ext = false;
|
||||
size_t slashpos = xml_filename.rfind(SLASH_CHAR);
|
||||
size_t dotpos = xml_filename.rfind(_T('.'));
|
||||
if (dotpos != tstring::npos) {
|
||||
// We have a dot.
|
||||
// If a slash is present, it must be before the dot.
|
||||
if (slashpos == tstring::npos || slashpos < dotpos) {
|
||||
// Replace the extension.
|
||||
xml_filename.resize(dotpos);
|
||||
xml_filename += _T(".xml");
|
||||
replaced_ext = true;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
if (!replaced_ext) {
|
||||
// No extension to replace.
|
||||
// Add an extension.
|
||||
xml_filename += _T(".xml");
|
||||
}
|
||||
|
||||
// Convert to XML.
|
||||
ret = mst.saveXML(xml_filename.c_str());
|
||||
_tprintf(_T("*** saveXML to %s: %d\n"), xml_filename.c_str(), ret);
|
||||
return ret;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user