From 44f3183d62a060e08024786a150421bc445a6485 Mon Sep 17 00:00:00 2001 From: Wolfgang Ruppel Date: Thu, 31 Aug 2017 19:20:53 +0200 Subject: [PATCH 1/5] Enhanced CMake install features --- regxmllib/CMakeLists.txt | 61 +++++++++++++++++++++++++++-- regxmllib/regxmllibcConfig.cmake.in | 21 ++++++++++ 2 files changed, 78 insertions(+), 4 deletions(-) create mode 100644 regxmllib/regxmllibcConfig.cmake.in diff --git a/regxmllib/CMakeLists.txt b/regxmllib/CMakeLists.txt index e967a17..2fa5d13 100644 --- a/regxmllib/CMakeLists.txt +++ b/regxmllib/CMakeLists.txt @@ -1,5 +1,6 @@ -cmake_minimum_required (VERSION 3.5) +cmake_minimum_required (VERSION 3.6) project (regxmllibc) +option(BUILD_SHARED_LIBS Bool OFF) include(FindXercesC) find_package(XercesC REQUIRED) @@ -7,22 +8,74 @@ include_directories( ${XercesC_INCLUDE_DIR} src/main/cpp ) +# Append "_d" if debug lib. +set(CMAKE_DEBUG_POSTFIX _d) -file(GLOB_RECURSE SRC_FILES src/main/cpp/*.cpp src/main/cpp/*.h ) -add_library(${PROJECT_NAME} ${SRC_FILES}) +file(GLOB_RECURSE SRC_FILES src/main/cpp/*.cpp ) +file(GLOB_RECURSE INC_FILES src/main/cpp/*.h ) +add_library(${PROJECT_NAME} ${SRC_FILES} ${INC_FILES}) set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 98) target_link_libraries ( ${PROJECT_NAME} ${XercesC_LIBRARY} ) -foreach(source IN LISTS SRC_FILES) +foreach(source IN LISTS SRC_FILES INC_FILES) file(RELATIVE_PATH rel_source ${CMAKE_CURRENT_SOURCE_DIR}/src/main/cpp/com/ ${source}) get_filename_component(source_path ${rel_source} DIRECTORY) string(REPLACE "\\" "/" source_path_msvc "${source_path}") source_group("${source_path_msvc}" FILES "${source}") endforeach() +if(WIN32 AND NOT CYGWIN) + set(DEF_INSTALL_CMAKE_DIR CMake) +else() + set(DEF_INSTALL_CMAKE_DIR lib/CMake/${PROJECT_NAME}) +endif() +set(INSTALL_CMAKE_DIR ${DEF_INSTALL_CMAKE_DIR} CACHE PATH + "Installation directory for CMake files") +set(INSTALL_LIB_DIR lib CACHE PATH "Installation directory for libraries") +set(INSTALL_INCLUDE_DIR include CACHE PATH "Installation directory for header files") + +# Make relative paths absolute (needed later on) +foreach(p LIB BIN INCLUDE CMAKE) + set(var INSTALL_${p}_DIR) + if(NOT IS_ABSOLUTE "${${var}}") + set(${var} "${CMAKE_INSTALL_PREFIX}/${${var}}") + endif() +endforeach() + + +# Export the package for use from the build-tree +# (this registers the build-tree with a global CMake-registry) +export(PACKAGE ${PROJECT_NAME}) + +# Create the ${PROJECT_NAME}Config.cmake file in the install tree +file(RELATIVE_PATH REL_INCLUDE_DIR "${INSTALL_CMAKE_DIR}" "${INSTALL_INCLUDE_DIR}") +set(CONF_INCLUDE_DIRS "\${REGXMLLIBC_CMAKE_DIR}/${REL_INCLUDE_DIR}") +configure_file(${PROJECT_NAME}Config.cmake.in + "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${PROJECT_NAME}Config.cmake" @ONLY) + + +install(EXPORT ${PROJECT_NAME}Targets DESTINATION + ${INSTALL_CMAKE_DIR} COMPONENT dev) + +install(TARGETS ${PROJECT_NAME} +EXPORT ${PROJECT_NAME}Targets DESTINATION ${INSTALL_LIB_DIR} +) + +foreach ( file ${INC_FILES} ) + get_filename_component( dir ${file} DIRECTORY ) + file(RELATIVE_PATH dir2 "${CMAKE_CURRENT_SOURCE_DIR}/src/main/cpp" ${dir}) + message(STATUS ${dir}) + message(STATUS ${dir2}) + install( FILES ${file} DESTINATION "${INSTALL_INCLUDE_DIR}/${PROJECT_NAME}/${dir2}" ) +endforeach() + + +install(FILES + "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${PROJECT_NAME}Config.cmake" + DESTINATION "${INSTALL_CMAKE_DIR}" COMPONENT dev) #unit tests diff --git a/regxmllib/regxmllibcConfig.cmake.in b/regxmllib/regxmllibcConfig.cmake.in new file mode 100644 index 0000000..69b1382 --- /dev/null +++ b/regxmllib/regxmllibcConfig.cmake.in @@ -0,0 +1,21 @@ +# REGXMLLIBC_INCLUDE_DIRS - include directories for regxmllibc +# REGXMLLIBC_LIBRARIES - libraries to link against +# REGXMLLIBC_EXECUTABLE - the bar executable + +# Compute paths +get_filename_component(REGXMLLIBC_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) +# set(regxmllibc_INCLUDE_DIRS "@CONF_INCLUDE_DIRS@/regxmllibc") +set(REGXMLLIBC_INCLUDE_DIRS "@CONF_INCLUDE_DIRS@/regxmllibc") + +# Our library dependencies (contains definitions for IMPORTED targets) +if(NOT TARGET regxmllibc AND NOT regxmllibc_BINARY_DIR) + include("${REGXMLLIBC_CMAKE_DIR}/regxmllibcTargets.cmake") +endif() + +# These are IMPORTED targets created by FooBarTargets.cmake +set(REGXMLLIBC_LIBRARIES + "$<$>:${PROJECT_NAME}>" + "$<$:${PROJECT_NAME}${CMAKE_DEBUG_POSTFIX}>" +) + + From ee34043bc5bf3425b954464dfa459820db3922f6 Mon Sep 17 00:00:00 2001 From: Wolfgang Ruppel Date: Fri, 1 Sep 2017 17:53:42 +0200 Subject: [PATCH 2/5] CMakesList.txt with enhanced install features --- regxmllib/CMakeLists.txt | 77 +++++++++++++++++++++++++++++++++++----- 1 file changed, 69 insertions(+), 8 deletions(-) diff --git a/regxmllib/CMakeLists.txt b/regxmllib/CMakeLists.txt index 394c957..3f84ab1 100644 --- a/regxmllib/CMakeLists.txt +++ b/regxmllib/CMakeLists.txt @@ -1,29 +1,92 @@ -cmake_minimum_required (VERSION 3.5) +cmake_minimum_required (VERSION 3.6) project (regxmllibc) - +option(BUILD_SHARED_LIB Bool OFF) + +if(BUILD_SHARED_LIB) +set(LIB_TYPE SHARED) +if(WIN32 AND NOT CYGWIN) +set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE) +endif(WIN32 AND NOT CYGWIN) +message(STATUS "*** Building DLL library ${LIB_TYPE}") +else(BUILD_SHARED_LIB) +message(STATUS "*** Option BUILD_SHARED_LIB is OFF ${LIB_TYPE}") +add_definitions( -DUTILS_LIB_STATIC ) +endif(BUILD_SHARED_LIB) include(FindXercesC) find_package(XercesC REQUIRED) include_directories( ${XercesC_INCLUDE_DIR} src/main/cpp ) +# Append "_d" if debug lib. +set(CMAKE_DEBUG_POSTFIX _d) + +file(GLOB_RECURSE SRC_FILES src/main/cpp/*.cpp ) +file(GLOB_RECURSE INC_FILES src/main/cpp/*.h ) +add_library(${PROJECT_NAME} ${LIB_TYPE} ${SRC_FILES} ${INC_FILES}) -file(GLOB_RECURSE SRC_FILES src/main/cpp/*.cpp src/main/cpp/*.h ) -add_library(${PROJECT_NAME} ${SRC_FILES}) -install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 98) target_link_libraries ( ${PROJECT_NAME} ${XercesC_LIBRARY} ) -foreach(source IN LISTS SRC_FILES) +foreach(source IN LISTS SRC_FILES INC_FILES) file(RELATIVE_PATH rel_source ${CMAKE_CURRENT_SOURCE_DIR}/src/main/cpp/com/ ${source}) get_filename_component(source_path ${rel_source} DIRECTORY) string(REPLACE "\\" "/" source_path_msvc "${source_path}") source_group("${source_path_msvc}" FILES "${source}") endforeach() +if(WIN32 AND NOT CYGWIN) + set(DEF_INSTALL_CMAKE_DIR CMake) +else() + set(DEF_INSTALL_CMAKE_DIR lib/CMake/${PROJECT_NAME}) +endif() +set(INSTALL_CMAKE_DIR ${DEF_INSTALL_CMAKE_DIR} CACHE PATH + "Installation directory for CMake files") +set(INSTALL_LIB_DIR lib CACHE PATH "Installation directory for libraries") +set(INSTALL_INCLUDE_DIR include CACHE PATH "Installation directory for header files") + +# Make relative paths absolute (needed later on) +foreach(p LIB BIN INCLUDE CMAKE) + set(var INSTALL_${p}_DIR) + if(NOT IS_ABSOLUTE "${${var}}") + set(${var} "${CMAKE_INSTALL_PREFIX}/${${var}}") + endif() +endforeach() + + +# Export the package for use from the build-tree +# (this registers the build-tree with a global CMake-registry) +export(PACKAGE ${PROJECT_NAME}) + +# Create the ${PROJECT_NAME}Config.cmake file in the install tree +file(RELATIVE_PATH REL_INCLUDE_DIR "${INSTALL_CMAKE_DIR}" "${INSTALL_INCLUDE_DIR}") +set(CONF_INCLUDE_DIRS "\${REGXMLLIBC_CMAKE_DIR}/${REL_INCLUDE_DIR}") +configure_file(${PROJECT_NAME}Config.cmake.in + "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${PROJECT_NAME}Config.cmake" @ONLY) + + +install(EXPORT ${PROJECT_NAME}Targets DESTINATION + ${INSTALL_CMAKE_DIR} COMPONENT dev) + +install(TARGETS ${PROJECT_NAME} +EXPORT ${PROJECT_NAME}Targets DESTINATION ${INSTALL_LIB_DIR} +) + +foreach ( file ${INC_FILES} ) + get_filename_component( dir ${file} DIRECTORY ) + file(RELATIVE_PATH dir2 "${CMAKE_CURRENT_SOURCE_DIR}/src/main/cpp" ${dir}) + message(STATUS ${dir}) + message(STATUS ${dir2}) + install( FILES ${file} DESTINATION "${INSTALL_INCLUDE_DIR}/${PROJECT_NAME}/${dir2}" ) +endforeach() + + +install(FILES + "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${PROJECT_NAME}Config.cmake" + DESTINATION "${INSTALL_CMAKE_DIR}" COMPONENT dev) #unit tests @@ -45,5 +108,3 @@ endforeach( UNIT_TEST_PATH ${UNIT_TESTS} ) #add_executable(AUIDTest src/test/cpp/com/sandflow/smpte/util/AUIDTest.cpp) #target_link_libraries(AUIDTest regxmllibc) #add_test(AUIDTest AUIDTest) - -install(DIRECTORY src/main/cpp/com/sandflow DESTINATION include FILES_MATCHING PATTERN "*.h") From 573128e14114cee7f120522b61e60885146cb4e8 Mon Sep 17 00:00:00 2001 From: Wolfgang Ruppel Date: Mon, 25 Sep 2017 22:02:15 +0200 Subject: [PATCH 3/5] Minor changes --- README.cmake.txt | 14 ++++++++++++++ regxmllib/CMakeLists.txt | 10 +++++----- regxmllib/regxmllibcConfig.cmake.in | 5 +---- 3 files changed, 20 insertions(+), 9 deletions(-) create mode 100644 README.cmake.txt diff --git a/README.cmake.txt b/README.cmake.txt new file mode 100644 index 0000000..31b1769 --- /dev/null +++ b/README.cmake.txt @@ -0,0 +1,14 @@ +1 cmake options +-DBUILD_SHARED_LIB=(OFF|ON) default: OFF +-DCMAKE_BUILD_TYPE=(release|debug) default:release + +2 build options +make install or Visual Studio target INSTALL will install regxmllib + +3 using regxmllib in other applications +add +find_package(regxmllibc) +target_link_libraries(${EXECUTABLE} general regxmllibc) +to application's CMakeLists.txt + + diff --git a/regxmllib/CMakeLists.txt b/regxmllib/CMakeLists.txt index 3f84ab1..c49880b 100644 --- a/regxmllib/CMakeLists.txt +++ b/regxmllib/CMakeLists.txt @@ -2,16 +2,18 @@ cmake_minimum_required (VERSION 3.6) project (regxmllibc) option(BUILD_SHARED_LIB Bool OFF) +# Set build type if(BUILD_SHARED_LIB) set(LIB_TYPE SHARED) if(WIN32 AND NOT CYGWIN) set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE) endif(WIN32 AND NOT CYGWIN) -message(STATUS "*** Building DLL library ${LIB_TYPE}") else(BUILD_SHARED_LIB) -message(STATUS "*** Option BUILD_SHARED_LIB is OFF ${LIB_TYPE}") +set(LIB_TYPE STATIC) add_definitions( -DUTILS_LIB_STATIC ) endif(BUILD_SHARED_LIB) +message(STATUS "*** LIB_TYPE is ${LIB_TYPE}") + include(FindXercesC) find_package(XercesC REQUIRED) include_directories( ${XercesC_INCLUDE_DIR} @@ -27,10 +29,9 @@ add_library(${PROJECT_NAME} ${LIB_TYPE} ${SRC_FILES} ${INC_FILES}) set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 98) - - target_link_libraries ( ${PROJECT_NAME} ${XercesC_LIBRARY} ) +# Set Visual Studio filters for nested sourcce paths foreach(source IN LISTS SRC_FILES INC_FILES) file(RELATIVE_PATH rel_source ${CMAKE_CURRENT_SOURCE_DIR}/src/main/cpp/com/ ${source}) get_filename_component(source_path ${rel_source} DIRECTORY) @@ -56,7 +57,6 @@ foreach(p LIB BIN INCLUDE CMAKE) endif() endforeach() - # Export the package for use from the build-tree # (this registers the build-tree with a global CMake-registry) export(PACKAGE ${PROJECT_NAME}) diff --git a/regxmllib/regxmllibcConfig.cmake.in b/regxmllib/regxmllibcConfig.cmake.in index 69b1382..b922d72 100644 --- a/regxmllib/regxmllibcConfig.cmake.in +++ b/regxmllib/regxmllibcConfig.cmake.in @@ -1,6 +1,5 @@ # REGXMLLIBC_INCLUDE_DIRS - include directories for regxmllibc # REGXMLLIBC_LIBRARIES - libraries to link against -# REGXMLLIBC_EXECUTABLE - the bar executable # Compute paths get_filename_component(REGXMLLIBC_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) @@ -12,10 +11,8 @@ if(NOT TARGET regxmllibc AND NOT regxmllibc_BINARY_DIR) include("${REGXMLLIBC_CMAKE_DIR}/regxmllibcTargets.cmake") endif() -# These are IMPORTED targets created by FooBarTargets.cmake +# These are IMPORTED targets created by regxmllibcTargets.cmake set(REGXMLLIBC_LIBRARIES "$<$>:${PROJECT_NAME}>" "$<$:${PROJECT_NAME}${CMAKE_DEBUG_POSTFIX}>" ) - - From 7a1512fbc3527fc974bcf8e5e3918285138caa0c Mon Sep 17 00:00:00 2001 From: Wolfgang Ruppel Date: Sun, 19 Nov 2017 14:33:00 +0100 Subject: [PATCH 4/5] CMake modification --- regxmllib/CMakeLists.txt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/regxmllib/CMakeLists.txt b/regxmllib/CMakeLists.txt index c49880b..9d80c2b 100644 --- a/regxmllib/CMakeLists.txt +++ b/regxmllib/CMakeLists.txt @@ -29,7 +29,7 @@ add_library(${PROJECT_NAME} ${LIB_TYPE} ${SRC_FILES} ${INC_FILES}) set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 98) -target_link_libraries ( ${PROJECT_NAME} ${XercesC_LIBRARY} ) +target_link_libraries ( ${PROJECT_NAME} optimized ${XercesC_LIBRARY_RELEASE} debug ${XercesC_LIBRARY_DEBUG} ) # Set Visual Studio filters for nested sourcce paths foreach(source IN LISTS SRC_FILES INC_FILES) @@ -78,8 +78,6 @@ EXPORT ${PROJECT_NAME}Targets DESTINATION ${INSTALL_LIB_DIR} foreach ( file ${INC_FILES} ) get_filename_component( dir ${file} DIRECTORY ) file(RELATIVE_PATH dir2 "${CMAKE_CURRENT_SOURCE_DIR}/src/main/cpp" ${dir}) - message(STATUS ${dir}) - message(STATUS ${dir2}) install( FILES ${file} DESTINATION "${INSTALL_INCLUDE_DIR}/${PROJECT_NAME}/${dir2}" ) endforeach() From c497555dcf7ff8d7083fdcd2de13faee6f0f20e0 Mon Sep 17 00:00:00 2001 From: imftool Date: Thu, 12 Mar 2020 16:02:13 +0100 Subject: [PATCH 5/5] merge with upstream --- .gitignore | 12 + .travis.yml | 21 + regxmllib/CMakeLists.txt => CMakeLists.txt | 14 +- CONTRIBUTING.txt | 11 + CTestConfig.cmake | 1 + README.txt | 172 +- build.xml | 95 + input/.gitignore | 3 - input/xml-registers/.gitignore | 2 - log4j.properties | 1 + output/register-schemas/.gitignore | 2 - output/regxml-dicts/.gitignore | 2 - output/regxml-schemas/.gitignore | 2 - pom.xml | 215 + regxmllib/.gitignore | 8 - regxmllib/build.properties | 13 - regxmllib/build.xml | 397 - regxmllib/nbproject/build-impl.xml | 1413 - regxmllib/nbproject/genfiles.properties | 8 - regxmllib/nbproject/project.properties | 100 - regxmllib/nbproject/project.xml | 16 - regxmllib/pom.xml | 91 - .../www-smpte-ra-org-reg-395-2014.xml | 28 - ...nfig.cmake.in => regxmllibcConfig.cmake.in | 0 .../main/config/repoversion.properties | 0 .../main/cpp/com/sandflow/smpte/klv/Group.h | 0 .../cpp/com/sandflow/smpte/klv/KLVException.h | 0 .../cpp/com/sandflow/smpte/klv/KLVStream.cpp | 2 +- .../cpp/com/sandflow/smpte/klv/KLVStream.h | 0 .../cpp/com/sandflow/smpte/klv/LocalSet.cpp | 4 +- .../cpp/com/sandflow/smpte/klv/LocalSet.h | 0 .../com/sandflow/smpte/klv/LocalTagRegister.h | 0 .../com/sandflow/smpte/klv/MemoryTriplet.cpp | 0 .../com/sandflow/smpte/klv/MemoryTriplet.h | 0 .../main/cpp/com/sandflow/smpte/klv/Triplet.h | 0 .../cpp/com/sandflow/smpte/mxf/FillItem.cpp | 0 .../cpp/com/sandflow/smpte/mxf/FillItem.h | 0 .../cpp/com/sandflow/smpte/mxf/MXFException.h | 0 .../cpp/com/sandflow/smpte/mxf/MXFStream.cpp | 0 .../cpp/com/sandflow/smpte/mxf/MXFStream.h | 0 .../com/sandflow/smpte/mxf/PartitionPack.cpp | 4 +- .../com/sandflow/smpte/mxf/PartitionPack.h | 0 .../cpp/com/sandflow/smpte/mxf/PrimerPack.cpp | 4 +- .../cpp/com/sandflow/smpte/mxf/PrimerPack.h | 0 .../main/cpp/com/sandflow/smpte/mxf/Set.cpp | 2 +- .../main/cpp/com/sandflow/smpte/mxf/Set.h | 0 .../sandflow/smpte/regxml/FragmentBuilder.cpp | 150 +- .../sandflow/smpte/regxml/FragmentBuilder.h | 53 +- .../smpte/regxml/MXFFragmentBuilder.cpp | 4 +- .../smpte/regxml/MXFFragmentBuilder.h | 6 +- .../definitions/CharacterTypeDefinition.h | 0 .../regxml/definitions/ClassDefinition.h | 0 .../smpte/regxml/definitions/Definition.h | 4 +- .../regxml/definitions/DefinitionVisitor.h | 0 .../definitions/EnumerationTypeDefinition.h | 0 .../ExtendibleEnumerationTypeDefinition.h | 0 .../definitions/FixedArrayTypeDefinition.h | 0 .../definitions/IndirectTypeDefinition.h | 0 .../definitions/IntegerTypeDefinition.h | 0 .../LensSerialFloatTypeDefinition.h | 0 .../regxml/definitions/OpaqueTypeDefinition.h | 0 .../definitions/PropertyAliasDefinition.h | 0 .../regxml/definitions/PropertyDefinition.h | 0 .../regxml/definitions/RecordTypeDefinition.h | 0 .../regxml/definitions/RenameTypeDefinition.h | 0 .../regxml/definitions/SetTypeDefinition.h | 0 .../regxml/definitions/StreamTypeDefinition.h | 0 .../regxml/definitions/StringTypeDefinition.h | 0 .../StrongReferenceTypeDefinition.h | 0 .../definitions/VariableArrayTypeDefinition.h | 0 .../definitions/WeakReferenceTypeDefinition.h | 0 .../smpte/regxml/dict/DefinitionResolver.h | 0 .../smpte/regxml/dict/MetaDictionary.cpp | 42 +- .../smpte/regxml/dict/MetaDictionary.h | 0 .../regxml/dict/MetaDictionaryCollection.cpp | 0 .../regxml/dict/MetaDictionaryCollection.h | 0 .../regxml/dict/importers/XMLImporter.cpp | 78 +- .../smpte/regxml/dict/importers/XMLImporter.h | 4 +- .../main/cpp/com/sandflow/smpte/util/AUID.cpp | 4 +- .../main/cpp/com/sandflow/smpte/util/AUID.h | 0 .../main/cpp/com/sandflow/smpte/util/IDAU.cpp | 0 .../main/cpp/com/sandflow/smpte/util/IDAU.h | 0 .../main/cpp/com/sandflow/smpte/util/UL.cpp | 0 .../main/cpp/com/sandflow/smpte/util/UL.h | 0 .../main/cpp/com/sandflow/smpte/util/UMID.cpp | 0 .../main/cpp/com/sandflow/smpte/util/UMID.h | 0 .../main/cpp/com/sandflow/smpte/util/UUID.cpp | 0 .../main/cpp/com/sandflow/smpte/util/UUID.h | 0 .../cpp/com/sandflow/util/CountingStreamBuf.h | 0 .../main/cpp/com/sandflow/util/DOMHelper.cpp | 16 +- .../main/cpp/com/sandflow/util/DOMHelper.h | 20 +- .../main/cpp/com/sandflow/util/events/Event.h | 4 +- .../com/sandflow/util/events/EventHandler.h | 0 .../sandflow/util/events/NullEventHandler.cpp | 0 .../sandflow/util/events/NullEventHandler.h | 0 .../main/cpp/com/sandflow/util/membuf.h | 0 .../main/cpp/com/sandflow/util/optional.h | 0 .../main/cpp/com/sandflow/util/scoped_ptr.h | 0 .../main/cpp/com/sandflow/util/strformat.cpp | 0 .../main/cpp/com/sandflow/util/strformat.h | 0 .../java/com/sandflow/smpte/klv/Group.java | 0 .../sandflow/smpte/klv/KLVInputStream.java | 794 +- .../java/com/sandflow/smpte/klv/LocalSet.java | 324 +- .../sandflow/smpte/klv/LocalTagRegister.java | 144 +- .../com/sandflow/smpte/klv/MemoryTriplet.java | 148 +- .../java/com/sandflow/smpte/klv/Triplet.java | 122 +- .../klv/adapters/TripletValueAdapter.java | 100 +- .../smpte/klv/adapters/ULValueAdapter.java | 106 +- .../smpte/klv/exceptions/KLVException.java | 110 +- .../exceptions/TripletLengthException.java | 74 +- .../com/sandflow/smpte/klv/package-info.java | 60 +- .../java/com/sandflow/smpte/mxf/FillItem.java | 126 +- .../java/com/sandflow/smpte/mxf/MXFFiles.java | 0 .../sandflow/smpte/mxf/MXFInputStream.java | 331 +- .../com/sandflow/smpte/mxf/PartitionPack.java | 566 +- .../com/sandflow/smpte/mxf/PrimerPack.java | 171 +- .../sandflow/smpte/mxf/RandomIndexPack.java | 258 +- .../main/java/com/sandflow/smpte/mxf/Set.java | 180 +- .../com/sandflow/smpte/mxf/package-info.java | 60 +- .../smpte/register/ElementsRegister.java | 306 +- .../smpte/register/GroupsRegister.java | 362 +- .../smpte/register/LabelsRegister.java | 296 +- .../smpte/register/QualifiedSymbol.java | 182 +- .../smpte/register/TypesRegister.java | 432 +- .../brown_sauce/GroupsRegisterModel.java | 718 +- .../register/brown_sauce/package-info.java | 72 +- .../catsup/ElementsRegisterModel.java | 514 +- .../register/catsup/GroupsRegisterModel.java | 690 +- .../register/catsup/LabelsRegisterModel.java | 370 +- .../register/catsup/TypesRegisterModel.java | 732 +- .../smpte/register/catsup/package-info.java | 72 +- .../exceptions/DuplicateEntryException.java | 74 +- .../exceptions/InvalidEntryException.java | 0 .../sandflow/smpte/register/package-info.java | 76 +- .../smpte/regxml/FragmentBuilder.java | 3550 +- .../smpte/regxml/MXFFragmentBuilder.java | 934 +- .../smpte/regxml/XMLSchemaBuilder.java | 3134 +- .../smpte/regxml/dict/DefinitionResolver.java | 126 +- .../smpte/regxml/dict/MetaDictionary.java | 726 +- .../regxml/dict/MetaDictionaryCollection.java | 300 +- .../definitions/CharacterTypeDefinition.java | 88 +- .../dict/definitions/ClassDefinition.java | 148 +- .../regxml/dict/definitions/Definition.java | 220 +- .../dict/definitions/DefinitionVisitor.java | 148 +- .../EnumerationTypeDefinition.java | 384 +- .../ExtendibleEnumerationTypeDefinition.java | 194 +- .../definitions/FixedArrayTypeDefinition.java | 142 +- .../dict/definitions/FloatTypeDefinition.java | 148 +- .../definitions/IndirectTypeDefinition.java | 88 +- .../definitions/IntegerTypeDefinition.java | 158 +- .../LensSerialFloatTypeDefinition.java | 96 +- .../definitions/NullDefinitionVisitor.java | 268 +- .../definitions/OpaqueTypeDefinition.java | 92 +- .../definitions/PropertyAliasDefinition.java | 130 +- .../dict/definitions/PropertyDefinition.java | 216 +- .../definitions/RecordTypeDefinition.java | 326 +- .../definitions/RenameTypeDefinition.java | 122 +- .../dict/definitions/SetTypeDefinition.java | 126 +- .../definitions/StreamTypeDefinition.java | 90 +- .../definitions/StringTypeDefinition.java | 122 +- .../StrongReferenceTypeDefinition.java | 122 +- .../VariableArrayTypeDefinition.java | 122 +- .../WeakReferenceTypeDefinition.java | 154 +- .../regxml/dict/definitions/package-info.java | 84 +- .../exceptions/DuplicateSymbolException.java | 76 +- .../IllegalDefinitionException.java | 74 +- .../IllegalDictionaryException.java | 68 +- .../dict/importers/RegisterImporter.java | 1454 +- .../smpte/regxml/dict/package-info.java | 82 +- .../sandflow/smpte/regxml/package-info.java | 0 .../smpte/tools/BuildVersionSingleton.java | 160 +- .../tools/GenerateDictionaryXMLSchema.java | 410 +- .../tools/GenerateXMLSchemaDocuments.java | 218 +- .../com/sandflow/smpte/tools/RegXMLDump.java | 819 +- .../smpte/tools/XMLRegistersToDict.java | 304 +- .../java/com/sandflow/smpte/util/AUID.java | 316 +- .../smpte/util/CountingInputStream.java | 236 +- .../sandflow/smpte/util/ExcelCSVParser.java | 308 +- .../com/sandflow/smpte/util/HalfFloat.java | 120 +- .../java/com/sandflow/smpte/util/IDAU.java | 0 .../main/java/com/sandflow/smpte/util/UL.java | 580 +- .../java/com/sandflow/smpte/util/UMID.java | 262 +- .../java/com/sandflow/smpte/util/UUID.java | 454 +- .../sandflow/smpte/util/xml/AUIDAdapter.java | 124 +- .../smpte/util/xml/HexBinaryByteAdapter.java | 110 +- .../smpte/util/xml/HexBinaryLongAdapter.java | 152 +- .../sandflow/smpte/util/xml/ULAdapter.java | 90 +- .../sandflow/smpte/util/xml/UUIDAdapter.java | 90 +- .../sandflow/smpte/util/xml/package-info.java | 60 +- .../com/sandflow/util/events/BasicEvent.java | 0 .../java/com/sandflow/util/events/Event.java | 0 .../sandflow/util/events/EventHandler.java | 0 {regxmllib/src => src}/main/resources/reg.xsd | 202 +- .../smpte/dict/MetaDictionaryTest.cpp | 134 +- .../cpp/com/sandflow/smpte/util/AUIDTest.cpp | 0 .../com/sandflow/smpte/mxf/MXFFilesTest.java | 6 +- .../model2016/GroupsRegisterTest.java | 2 +- .../smpte/regxml/MXFFragmentBuilderTest.java | 898 +- .../smpte/regxml/XMLSchemaBuilderTest.java | 226 + .../sandflow/smpte/tools/RegXMLDumpTest.java | 103 + .../sandflow/smpte/util/HalfFloatTest.java | 114 +- .../com/sandflow/smpte/util/UMIDTest.java | 74 + .../test/resources/mxf-files}/audio1.mxf | Bin .../test/resources/mxf-files}/audio2.mxf | Bin src/test/resources/mxf-files/class14.mxf | Bin 0 -> 31544 bytes src/test/resources/mxf-files/escape-chars.mxf | Bin 0 -> 1207560 bytes .../test/resources/mxf-files}/indirect.mxf | Bin .../mxf-files}/open-incomplete-header.mxf | Bin .../mxf-files}/utf8_embedded_text.mxf | Bin .../test/resources/mxf-files}/video1.mxf | Bin .../test/resources/mxf-files}/video2.mxf | Bin .../registers/brown_sauce/Elements.xml | 0 .../registers/brown_sauce/Groups.xml | 0 .../registers/brown_sauce/Labels.xml | 0 .../resources/registers/brown_sauce/Types.xml | 0 .../resources/registers/catsup/Elements.xml | 0 .../resources/registers/catsup/Groups.xml | 0 .../resources/registers/catsup/Labels.xml | 0 .../test/resources/registers/catsup/Types.xml | 0 .../resources/registers/ponzu/Elements.xml | 45160 +++++++++++++++ src/test/resources/registers/ponzu/Groups.xml | 15803 ++++++ src/test/resources/registers/ponzu/Labels.xml | 36643 +++++++++++++ src/test/resources/registers/ponzu/Types.xml | 10201 ++++ .../resources/registers/snapshot/Elements.xml | 45548 ++++++++++++++++ .../resources/registers/snapshot/Groups.xml | 16007 ++++++ .../resources/registers/snapshot/Labels.xml | 36723 +++++++++++++ .../resources/registers/snapshot/Types.xml | 10261 ++++ ...-schemas-ebucore-smpte-class13-element.xml | 2 +- ...ta-schemas-ebucore-smpte-class13-group.xml | 2 +- ...ata-schemas-ebucore-smpte-class13-type.xml | 2 +- ...te-ra-org-reg-2003-2012-13-1-amwa-as11.xml | 2 +- ...te-ra-org-reg-2003-2012-13-1-amwa-as12.xml | 2 +- ...-smpte-ra-org-reg-2003-2012-13-12-as11.xml | 2 +- ...mpte-ra-org-reg-2003-2012-13-4-archive.xml | 2 +- .../www-smpte-ra-org-reg-2003-2012.xml | 27 +- ...www-smpte-ra-org-reg-335-2012-13-1-aaf.xml | 2 +- ...pte-ra-org-reg-335-2012-13-1-amwa-as10.xml | 2 +- ...pte-ra-org-reg-335-2012-13-1-amwa-as11.xml | 2 +- ...pte-ra-org-reg-335-2012-13-1-amwa-as12.xml | 2 +- ...te-ra-org-reg-335-2012-13-1-amwa-rules.xml | 2 +- ...w-smpte-ra-org-reg-335-2012-13-12-as11.xml | 2 +- .../www-smpte-ra-org-reg-335-2012-13-13.xml | 2 +- ...smpte-ra-org-reg-335-2012-13-4-archive.xml | 2 +- .../www-smpte-ra-org-reg-335-2012-14-9.xml | 62 + .../www-smpte-ra-org-reg-335-2012.xml | 1185 +- ...www-smpte-ra-org-reg-395-2014-13-1-aaf.xml | 64 +- ...a-org-reg-395-2014-13-1-amwa-as-common.xml | 2 +- ...pte-ra-org-reg-395-2014-13-1-amwa-as10.xml | 2 +- ...pte-ra-org-reg-395-2014-13-1-amwa-as11.xml | 2 +- ...pte-ra-org-reg-395-2014-13-1-amwa-as12.xml | 2 +- ...w-smpte-ra-org-reg-395-2014-13-12-as11.xml | 2 +- .../www-smpte-ra-org-reg-395-2014-13-13.xml | 2 +- ...smpte-ra-org-reg-395-2014-13-4-archive.xml | 2 +- .../www-smpte-ra-org-reg-395-2014-14-9.xml | 23 + .../www-smpte-ra-org-reg-395-2014.xml | 67 + .../test/resources/regxml-files}/audio1.xml | 458 +- .../test/resources/regxml-files}/audio2.xml | 428 +- src/test/resources/regxml-files/class14.xml | 192 + .../resources/regxml-files/escape-chars.xml | 263 + .../test/resources/regxml-files}/indirect.xml | 20 +- .../regxml-files}/utf8_embedded_text.xml | 2 +- .../test/resources/regxml-files}/video1.xml | 580 +- .../test/resources/regxml-files}/video2.xml | 600 +- 263 files changed, 234955 insertions(+), 17888 deletions(-) create mode 100644 .gitignore create mode 100644 .travis.yml rename regxmllib/CMakeLists.txt => CMakeLists.txt (90%) create mode 100644 CONTRIBUTING.txt create mode 100644 CTestConfig.cmake create mode 100644 build.xml delete mode 100644 input/.gitignore delete mode 100644 input/xml-registers/.gitignore create mode 100644 log4j.properties delete mode 100644 output/register-schemas/.gitignore delete mode 100644 output/regxml-dicts/.gitignore delete mode 100644 output/regxml-schemas/.gitignore create mode 100644 pom.xml delete mode 100644 regxmllib/.gitignore delete mode 100644 regxmllib/build.properties delete mode 100644 regxmllib/build.xml delete mode 100644 regxmllib/nbproject/build-impl.xml delete mode 100644 regxmllib/nbproject/genfiles.properties delete mode 100644 regxmllib/nbproject/project.properties delete mode 100644 regxmllib/nbproject/project.xml delete mode 100644 regxmllib/pom.xml delete mode 100644 regxmllib/src/test/resources/regxml-dicts/www-smpte-ra-org-reg-395-2014.xml rename regxmllib/regxmllibcConfig.cmake.in => regxmllibcConfig.cmake.in (100%) rename {regxmllib/src => src}/main/config/repoversion.properties (100%) rename {regxmllib/src => src}/main/cpp/com/sandflow/smpte/klv/Group.h (100%) rename {regxmllib/src => src}/main/cpp/com/sandflow/smpte/klv/KLVException.h (100%) rename {regxmllib/src => src}/main/cpp/com/sandflow/smpte/klv/KLVStream.cpp (99%) rename {regxmllib/src => src}/main/cpp/com/sandflow/smpte/klv/KLVStream.h (100%) rename {regxmllib/src => src}/main/cpp/com/sandflow/smpte/klv/LocalSet.cpp (95%) rename {regxmllib/src => src}/main/cpp/com/sandflow/smpte/klv/LocalSet.h (100%) rename {regxmllib/src => src}/main/cpp/com/sandflow/smpte/klv/LocalTagRegister.h (100%) rename {regxmllib/src => src}/main/cpp/com/sandflow/smpte/klv/MemoryTriplet.cpp (100%) rename {regxmllib/src => src}/main/cpp/com/sandflow/smpte/klv/MemoryTriplet.h (100%) rename {regxmllib/src => src}/main/cpp/com/sandflow/smpte/klv/Triplet.h (100%) rename {regxmllib/src => src}/main/cpp/com/sandflow/smpte/mxf/FillItem.cpp (100%) rename {regxmllib/src => src}/main/cpp/com/sandflow/smpte/mxf/FillItem.h (100%) rename {regxmllib/src => src}/main/cpp/com/sandflow/smpte/mxf/MXFException.h (100%) rename {regxmllib/src => src}/main/cpp/com/sandflow/smpte/mxf/MXFStream.cpp (100%) rename {regxmllib/src => src}/main/cpp/com/sandflow/smpte/mxf/MXFStream.h (100%) rename {regxmllib/src => src}/main/cpp/com/sandflow/smpte/mxf/PartitionPack.cpp (95%) rename {regxmllib/src => src}/main/cpp/com/sandflow/smpte/mxf/PartitionPack.h (100%) rename {regxmllib/src => src}/main/cpp/com/sandflow/smpte/mxf/PrimerPack.cpp (97%) rename {regxmllib/src => src}/main/cpp/com/sandflow/smpte/mxf/PrimerPack.h (100%) rename {regxmllib/src => src}/main/cpp/com/sandflow/smpte/mxf/Set.cpp (97%) rename {regxmllib/src => src}/main/cpp/com/sandflow/smpte/mxf/Set.h (100%) rename {regxmllib/src => src}/main/cpp/com/sandflow/smpte/regxml/FragmentBuilder.cpp (84%) rename {regxmllib/src => src}/main/cpp/com/sandflow/smpte/regxml/FragmentBuilder.h (82%) rename {regxmllib/src => src}/main/cpp/com/sandflow/smpte/regxml/MXFFragmentBuilder.cpp (98%) rename {regxmllib/src => src}/main/cpp/com/sandflow/smpte/regxml/MXFFragmentBuilder.h (98%) rename {regxmllib/src => src}/main/cpp/com/sandflow/smpte/regxml/definitions/CharacterTypeDefinition.h (100%) rename {regxmllib/src => src}/main/cpp/com/sandflow/smpte/regxml/definitions/ClassDefinition.h (100%) rename {regxmllib/src => src}/main/cpp/com/sandflow/smpte/regxml/definitions/Definition.h (98%) rename {regxmllib/src => src}/main/cpp/com/sandflow/smpte/regxml/definitions/DefinitionVisitor.h (100%) rename {regxmllib/src => src}/main/cpp/com/sandflow/smpte/regxml/definitions/EnumerationTypeDefinition.h (100%) rename {regxmllib/src => src}/main/cpp/com/sandflow/smpte/regxml/definitions/ExtendibleEnumerationTypeDefinition.h (100%) rename {regxmllib/src => src}/main/cpp/com/sandflow/smpte/regxml/definitions/FixedArrayTypeDefinition.h (100%) rename {regxmllib/src => src}/main/cpp/com/sandflow/smpte/regxml/definitions/IndirectTypeDefinition.h (100%) rename {regxmllib/src => src}/main/cpp/com/sandflow/smpte/regxml/definitions/IntegerTypeDefinition.h (100%) rename {regxmllib/src => src}/main/cpp/com/sandflow/smpte/regxml/definitions/LensSerialFloatTypeDefinition.h (100%) rename {regxmllib/src => src}/main/cpp/com/sandflow/smpte/regxml/definitions/OpaqueTypeDefinition.h (100%) rename {regxmllib/src => src}/main/cpp/com/sandflow/smpte/regxml/definitions/PropertyAliasDefinition.h (100%) rename {regxmllib/src => src}/main/cpp/com/sandflow/smpte/regxml/definitions/PropertyDefinition.h (100%) rename {regxmllib/src => src}/main/cpp/com/sandflow/smpte/regxml/definitions/RecordTypeDefinition.h (100%) rename {regxmllib/src => src}/main/cpp/com/sandflow/smpte/regxml/definitions/RenameTypeDefinition.h (100%) rename {regxmllib/src => src}/main/cpp/com/sandflow/smpte/regxml/definitions/SetTypeDefinition.h (100%) rename {regxmllib/src => src}/main/cpp/com/sandflow/smpte/regxml/definitions/StreamTypeDefinition.h (100%) rename {regxmllib/src => src}/main/cpp/com/sandflow/smpte/regxml/definitions/StringTypeDefinition.h (100%) rename {regxmllib/src => src}/main/cpp/com/sandflow/smpte/regxml/definitions/StrongReferenceTypeDefinition.h (100%) rename {regxmllib/src => src}/main/cpp/com/sandflow/smpte/regxml/definitions/VariableArrayTypeDefinition.h (100%) rename {regxmllib/src => src}/main/cpp/com/sandflow/smpte/regxml/definitions/WeakReferenceTypeDefinition.h (100%) rename {regxmllib/src => src}/main/cpp/com/sandflow/smpte/regxml/dict/DefinitionResolver.h (100%) rename {regxmllib/src => src}/main/cpp/com/sandflow/smpte/regxml/dict/MetaDictionary.cpp (92%) rename {regxmllib/src => src}/main/cpp/com/sandflow/smpte/regxml/dict/MetaDictionary.h (100%) rename {regxmllib/src => src}/main/cpp/com/sandflow/smpte/regxml/dict/MetaDictionaryCollection.cpp (100%) rename {regxmllib/src => src}/main/cpp/com/sandflow/smpte/regxml/dict/MetaDictionaryCollection.h (100%) rename {regxmllib/src => src}/main/cpp/com/sandflow/smpte/regxml/dict/importers/XMLImporter.cpp (81%) rename {regxmllib/src => src}/main/cpp/com/sandflow/smpte/regxml/dict/importers/XMLImporter.h (93%) rename {regxmllib/src => src}/main/cpp/com/sandflow/smpte/util/AUID.cpp (96%) rename {regxmllib/src => src}/main/cpp/com/sandflow/smpte/util/AUID.h (100%) rename {regxmllib/src => src}/main/cpp/com/sandflow/smpte/util/IDAU.cpp (100%) rename {regxmllib/src => src}/main/cpp/com/sandflow/smpte/util/IDAU.h (100%) rename {regxmllib/src => src}/main/cpp/com/sandflow/smpte/util/UL.cpp (100%) rename {regxmllib/src => src}/main/cpp/com/sandflow/smpte/util/UL.h (100%) rename {regxmllib/src => src}/main/cpp/com/sandflow/smpte/util/UMID.cpp (100%) rename {regxmllib/src => src}/main/cpp/com/sandflow/smpte/util/UMID.h (100%) rename {regxmllib/src => src}/main/cpp/com/sandflow/smpte/util/UUID.cpp (100%) rename {regxmllib/src => src}/main/cpp/com/sandflow/smpte/util/UUID.h (100%) rename {regxmllib/src => src}/main/cpp/com/sandflow/util/CountingStreamBuf.h (100%) rename {regxmllib/src => src}/main/cpp/com/sandflow/util/DOMHelper.cpp (69%) rename {regxmllib/src => src}/main/cpp/com/sandflow/util/DOMHelper.h (73%) rename {regxmllib/src => src}/main/cpp/com/sandflow/util/events/Event.h (99%) rename {regxmllib/src => src}/main/cpp/com/sandflow/util/events/EventHandler.h (100%) rename {regxmllib/src => src}/main/cpp/com/sandflow/util/events/NullEventHandler.cpp (100%) rename {regxmllib/src => src}/main/cpp/com/sandflow/util/events/NullEventHandler.h (100%) rename {regxmllib/src => src}/main/cpp/com/sandflow/util/membuf.h (100%) rename {regxmllib/src => src}/main/cpp/com/sandflow/util/optional.h (100%) rename {regxmllib/src => src}/main/cpp/com/sandflow/util/scoped_ptr.h (100%) rename {regxmllib/src => src}/main/cpp/com/sandflow/util/strformat.cpp (100%) rename {regxmllib/src => src}/main/cpp/com/sandflow/util/strformat.h (100%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/klv/Group.java (100%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/klv/KLVInputStream.java (93%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/klv/LocalSet.java (92%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/klv/LocalTagRegister.java (84%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/klv/MemoryTriplet.java (91%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/klv/Triplet.java (94%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/klv/adapters/TripletValueAdapter.java (97%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/klv/adapters/ULValueAdapter.java (97%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/klv/exceptions/KLVException.java (97%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/klv/exceptions/TripletLengthException.java (97%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/klv/package-info.java (98%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/mxf/FillItem.java (97%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/mxf/MXFFiles.java (100%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/mxf/MXFInputStream.java (83%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/mxf/PartitionPack.java (95%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/mxf/PrimerPack.java (95%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/mxf/RandomIndexPack.java (96%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/mxf/Set.java (96%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/mxf/package-info.java (98%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/register/ElementsRegister.java (96%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/register/GroupsRegister.java (96%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/register/LabelsRegister.java (96%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/register/QualifiedSymbol.java (97%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/register/TypesRegister.java (96%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/register/brown_sauce/GroupsRegisterModel.java (96%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/register/brown_sauce/package-info.java (97%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/register/catsup/ElementsRegisterModel.java (96%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/register/catsup/GroupsRegisterModel.java (96%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/register/catsup/LabelsRegisterModel.java (96%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/register/catsup/TypesRegisterModel.java (96%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/register/catsup/package-info.java (97%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/register/exceptions/DuplicateEntryException.java (97%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/register/exceptions/InvalidEntryException.java (100%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/register/package-info.java (97%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/regxml/FragmentBuilder.java (79%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/regxml/MXFFragmentBuilder.java (95%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/regxml/XMLSchemaBuilder.java (97%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/regxml/dict/DefinitionResolver.java (97%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/regxml/dict/MetaDictionary.java (97%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/regxml/dict/MetaDictionaryCollection.java (97%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/regxml/dict/definitions/CharacterTypeDefinition.java (97%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/regxml/dict/definitions/ClassDefinition.java (97%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/regxml/dict/definitions/Definition.java (97%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/regxml/dict/definitions/DefinitionVisitor.java (97%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/regxml/dict/definitions/EnumerationTypeDefinition.java (97%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/regxml/dict/definitions/ExtendibleEnumerationTypeDefinition.java (97%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/regxml/dict/definitions/FixedArrayTypeDefinition.java (97%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/regxml/dict/definitions/FloatTypeDefinition.java (97%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/regxml/dict/definitions/IndirectTypeDefinition.java (97%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/regxml/dict/definitions/IntegerTypeDefinition.java (97%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/regxml/dict/definitions/LensSerialFloatTypeDefinition.java (97%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/regxml/dict/definitions/NullDefinitionVisitor.java (97%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/regxml/dict/definitions/OpaqueTypeDefinition.java (97%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/regxml/dict/definitions/PropertyAliasDefinition.java (97%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/regxml/dict/definitions/PropertyDefinition.java (96%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/regxml/dict/definitions/RecordTypeDefinition.java (97%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/regxml/dict/definitions/RenameTypeDefinition.java (97%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/regxml/dict/definitions/SetTypeDefinition.java (97%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/regxml/dict/definitions/StreamTypeDefinition.java (97%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/regxml/dict/definitions/StringTypeDefinition.java (97%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/regxml/dict/definitions/StrongReferenceTypeDefinition.java (96%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/regxml/dict/definitions/VariableArrayTypeDefinition.java (97%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/regxml/dict/definitions/WeakReferenceTypeDefinition.java (97%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/regxml/dict/definitions/package-info.java (97%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/regxml/dict/exceptions/DuplicateSymbolException.java (97%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/regxml/dict/exceptions/IllegalDefinitionException.java (97%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/regxml/dict/exceptions/IllegalDictionaryException.java (97%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/regxml/dict/importers/RegisterImporter.java (94%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/regxml/dict/package-info.java (97%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/regxml/package-info.java (100%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/tools/BuildVersionSingleton.java (97%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/tools/GenerateDictionaryXMLSchema.java (97%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/tools/GenerateXMLSchemaDocuments.java (97%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/tools/RegXMLDump.java (91%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/tools/XMLRegistersToDict.java (97%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/util/AUID.java (96%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/util/CountingInputStream.java (96%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/util/ExcelCSVParser.java (96%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/util/HalfFloat.java (97%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/util/IDAU.java (100%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/util/UL.java (87%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/util/UMID.java (95%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/util/UUID.java (96%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/util/xml/AUIDAdapter.java (97%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/util/xml/HexBinaryByteAdapter.java (97%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/util/xml/HexBinaryLongAdapter.java (97%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/util/xml/ULAdapter.java (97%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/util/xml/UUIDAdapter.java (97%) rename {regxmllib/src => src}/main/java/com/sandflow/smpte/util/xml/package-info.java (98%) rename {regxmllib/src => src}/main/java/com/sandflow/util/events/BasicEvent.java (100%) rename {regxmllib/src => src}/main/java/com/sandflow/util/events/Event.java (100%) rename {regxmllib/src => src}/main/java/com/sandflow/util/events/EventHandler.java (100%) rename {regxmllib/src => src}/main/resources/reg.xsd (97%) rename {regxmllib/src => src}/test/cpp/com/sandflow/smpte/dict/MetaDictionaryTest.cpp (56%) rename {regxmllib/src => src}/test/cpp/com/sandflow/smpte/util/AUIDTest.cpp (100%) rename {regxmllib/src => src}/test/java/com/sandflow/smpte/mxf/MXFFilesTest.java (89%) rename {regxmllib/src => src}/test/java/com/sandflow/smpte/register/model2016/GroupsRegisterTest.java (98%) rename {regxmllib/src => src}/test/java/com/sandflow/smpte/regxml/MXFFragmentBuilderTest.java (74%) create mode 100644 src/test/java/com/sandflow/smpte/regxml/XMLSchemaBuilderTest.java create mode 100644 src/test/java/com/sandflow/smpte/tools/RegXMLDumpTest.java rename {regxmllib/src => src}/test/java/com/sandflow/smpte/util/HalfFloatTest.java (97%) create mode 100644 src/test/java/com/sandflow/smpte/util/UMIDTest.java rename {regxmllib/src/test/resources/sample-files => src/test/resources/mxf-files}/audio1.mxf (100%) rename {regxmllib/src/test/resources/sample-files => src/test/resources/mxf-files}/audio2.mxf (100%) create mode 100644 src/test/resources/mxf-files/class14.mxf create mode 100644 src/test/resources/mxf-files/escape-chars.mxf rename {regxmllib/src/test/resources/sample-files => src/test/resources/mxf-files}/indirect.mxf (100%) rename {regxmllib/src/test/resources/sample-files => src/test/resources/mxf-files}/open-incomplete-header.mxf (100%) rename {regxmllib/src/test/resources/sample-files => src/test/resources/mxf-files}/utf8_embedded_text.mxf (100%) rename {regxmllib/src/test/resources/sample-files => src/test/resources/mxf-files}/video1.mxf (100%) rename {regxmllib/src/test/resources/sample-files => src/test/resources/mxf-files}/video2.mxf (100%) rename {regxmllib/src => src}/test/resources/registers/brown_sauce/Elements.xml (100%) rename {regxmllib/src => src}/test/resources/registers/brown_sauce/Groups.xml (100%) rename {regxmllib/src => src}/test/resources/registers/brown_sauce/Labels.xml (100%) rename {regxmllib/src => src}/test/resources/registers/brown_sauce/Types.xml (100%) rename {regxmllib/src => src}/test/resources/registers/catsup/Elements.xml (100%) rename {regxmllib/src => src}/test/resources/registers/catsup/Groups.xml (100%) rename {regxmllib/src => src}/test/resources/registers/catsup/Labels.xml (100%) rename {regxmllib/src => src}/test/resources/registers/catsup/Types.xml (100%) create mode 100644 src/test/resources/registers/ponzu/Elements.xml create mode 100644 src/test/resources/registers/ponzu/Groups.xml create mode 100644 src/test/resources/registers/ponzu/Labels.xml create mode 100644 src/test/resources/registers/ponzu/Types.xml create mode 100644 src/test/resources/registers/snapshot/Elements.xml create mode 100644 src/test/resources/registers/snapshot/Groups.xml create mode 100644 src/test/resources/registers/snapshot/Labels.xml create mode 100644 src/test/resources/registers/snapshot/Types.xml rename {regxmllib/src => src}/test/resources/regxml-dicts/www-ebu-ch-metadata-schemas-ebucore-smpte-class13-element.xml (99%) rename {regxmllib/src => src}/test/resources/regxml-dicts/www-ebu-ch-metadata-schemas-ebucore-smpte-class13-group.xml (99%) rename {regxmllib/src => src}/test/resources/regxml-dicts/www-ebu-ch-metadata-schemas-ebucore-smpte-class13-type.xml (99%) rename {regxmllib/src => src}/test/resources/regxml-dicts/www-smpte-ra-org-reg-2003-2012-13-1-amwa-as11.xml (97%) rename {regxmllib/src => src}/test/resources/regxml-dicts/www-smpte-ra-org-reg-2003-2012-13-1-amwa-as12.xml (84%) rename {regxmllib/src => src}/test/resources/regxml-dicts/www-smpte-ra-org-reg-2003-2012-13-12-as11.xml (95%) rename {regxmllib/src => src}/test/resources/regxml-dicts/www-smpte-ra-org-reg-2003-2012-13-4-archive.xml (85%) rename {regxmllib/src => src}/test/resources/regxml-dicts/www-smpte-ra-org-reg-2003-2012.xml (98%) rename {regxmllib/src => src}/test/resources/regxml-dicts/www-smpte-ra-org-reg-335-2012-13-1-aaf.xml (97%) rename {regxmllib/src => src}/test/resources/regxml-dicts/www-smpte-ra-org-reg-335-2012-13-1-amwa-as10.xml (97%) rename {regxmllib/src => src}/test/resources/regxml-dicts/www-smpte-ra-org-reg-335-2012-13-1-amwa-as11.xml (98%) rename {regxmllib/src => src}/test/resources/regxml-dicts/www-smpte-ra-org-reg-335-2012-13-1-amwa-as12.xml (93%) rename {regxmllib/src => src}/test/resources/regxml-dicts/www-smpte-ra-org-reg-335-2012-13-1-amwa-rules.xml (89%) rename {regxmllib/src => src}/test/resources/regxml-dicts/www-smpte-ra-org-reg-335-2012-13-12-as11.xml (99%) rename {regxmllib/src => src}/test/resources/regxml-dicts/www-smpte-ra-org-reg-335-2012-13-13.xml (97%) rename {regxmllib/src => src}/test/resources/regxml-dicts/www-smpte-ra-org-reg-335-2012-13-4-archive.xml (99%) create mode 100644 src/test/resources/regxml-dicts/www-smpte-ra-org-reg-335-2012-14-9.xml rename {regxmllib/src => src}/test/resources/regxml-dicts/www-smpte-ra-org-reg-335-2012.xml (86%) rename {regxmllib/src => src}/test/resources/regxml-dicts/www-smpte-ra-org-reg-395-2014-13-1-aaf.xml (95%) rename {regxmllib/src => src}/test/resources/regxml-dicts/www-smpte-ra-org-reg-395-2014-13-1-amwa-as-common.xml (84%) rename {regxmllib/src => src}/test/resources/regxml-dicts/www-smpte-ra-org-reg-395-2014-13-1-amwa-as10.xml (84%) rename {regxmllib/src => src}/test/resources/regxml-dicts/www-smpte-ra-org-reg-395-2014-13-1-amwa-as11.xml (89%) rename {regxmllib/src => src}/test/resources/regxml-dicts/www-smpte-ra-org-reg-395-2014-13-1-amwa-as12.xml (89%) rename {regxmllib/src => src}/test/resources/regxml-dicts/www-smpte-ra-org-reg-395-2014-13-12-as11.xml (84%) rename {regxmllib/src => src}/test/resources/regxml-dicts/www-smpte-ra-org-reg-395-2014-13-13.xml (85%) rename {regxmllib/src => src}/test/resources/regxml-dicts/www-smpte-ra-org-reg-395-2014-13-4-archive.xml (94%) create mode 100644 src/test/resources/regxml-dicts/www-smpte-ra-org-reg-395-2014-14-9.xml create mode 100644 src/test/resources/regxml-dicts/www-smpte-ra-org-reg-395-2014.xml rename {regxmllib/src/test/resources/reference-files => src/test/resources/regxml-files}/audio1.xml (95%) rename {regxmllib/src/test/resources/reference-files => src/test/resources/regxml-files}/audio2.xml (94%) create mode 100644 src/test/resources/regxml-files/class14.xml create mode 100644 src/test/resources/regxml-files/escape-chars.xml rename {regxmllib/src/test/resources/reference-files => src/test/resources/regxml-files}/indirect.xml (99%) rename {regxmllib/src/test/resources/reference-files => src/test/resources/regxml-files}/utf8_embedded_text.xml (99%) rename {regxmllib/src/test/resources/reference-files => src/test/resources/regxml-files}/video1.xml (95%) rename {regxmllib/src/test/resources/reference-files => src/test/resources/regxml-files}/video2.xml (95%) diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..aa9d277 --- /dev/null +++ b/.gitignore @@ -0,0 +1,12 @@ +build/ +dist/ +nbproject/private/ +target/ +cmake/ +pom.xml.asc +CMakeSettings.json +.vs/ +.project +.settings +.vscode/ +.classpath \ No newline at end of file diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..55ce3d0 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,21 @@ +matrix: + include: + - language: cpp + addons: + apt: + packages: + - libxerces-c-dev + - valgrind + + script: + - mkdir build + - cd build + - cmake .. + - cmake --build . + - ctest . + - ctest -T memcheck . + - sudo make install + + - language: java + jdk: + - openjdk8 diff --git a/regxmllib/CMakeLists.txt b/CMakeLists.txt similarity index 90% rename from regxmllib/CMakeLists.txt rename to CMakeLists.txt index 9d80c2b..e84cb6c 100644 --- a/regxmllib/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,6 +16,13 @@ message(STATUS "*** LIB_TYPE is ${LIB_TYPE}") include(FindXercesC) find_package(XercesC REQUIRED) +if(NOT XercesC_LIBRARY_DEBUG) + if (XercesC_LIBRARY_RELEASE) + set(XercesC_LIBRARY_DEBUG ${XercesC_LIBRARY_RELEASE}) + message(WARNING "XercesC_LIBRARY_DEBUG library not found, setting XercesC_LIBRARY_DEBUG = XercesC_LIBRARY_RELEASE") + endif() +endif() + include_directories( ${XercesC_INCLUDE_DIR} src/main/cpp ) @@ -86,11 +93,12 @@ install(FILES "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${PROJECT_NAME}Config.cmake" DESTINATION "${INSTALL_CMAKE_DIR}" COMPONENT dev) - #unit tests enable_testing() +#include(CTest) + file( GLOB_RECURSE UNIT_TESTS src/test/cpp/*.cpp ) file(COPY "src/test/resources" DESTINATION "${CMAKE_BINARY_DIR}") @@ -103,6 +111,4 @@ foreach( UNIT_TEST_PATH ${UNIT_TESTS} ) add_test(${UNIT_TEST_NAME} ${UNIT_TEST_NAME} WORKINGDIRECTORY "${CMAKE_BINARY_DIR}") endforeach( UNIT_TEST_PATH ${UNIT_TESTS} ) -#add_executable(AUIDTest src/test/cpp/com/sandflow/smpte/util/AUIDTest.cpp) -#target_link_libraries(AUIDTest regxmllibc) -#add_test(AUIDTest AUIDTest) +#install(DIRECTORY src/main/cpp/com DESTINATION include FILES_MATCHING PATTERN "*.h") diff --git a/CONTRIBUTING.txt b/CONTRIBUTING.txt new file mode 100644 index 0000000..eb6870e --- /dev/null +++ b/CONTRIBUTING.txt @@ -0,0 +1,11 @@ +By making a contribution to this project, I certify that: + +(a) The contribution was created in whole or in part by me and I have the right to submit it under the open source license indicated in the file; or + +(b) The contribution is based upon previous work that, to the best of my knowledge, is covered under an appropriate open source license and I have the right under that license to submit that work with modifications, whether created in whole or in part by me, under the same open source license (unless I am permitted to submit under a different license), as indicated in the file; or + +(c) The contribution was provided directly to me by some other person who certified (a), (b) or (c) and I have not modified it. + +(d) I understand and agree that this project and the contribution are public and that a record of the contribution (including all personal information I submit with it, including my sign-off) is maintained indefinitely and may be redistributed consistent with this project or the open source license(s) involved. + +Only contributions with a license compatible with the license at LICENSE.txt can be accepted. \ No newline at end of file diff --git a/CTestConfig.cmake b/CTestConfig.cmake new file mode 100644 index 0000000..48f8be8 --- /dev/null +++ b/CTestConfig.cmake @@ -0,0 +1 @@ +set(MEMORYCHECK_COMMAND_OPTIONS "--show-leak-kinds=definite --leak-check=full --error-exitcode=1") diff --git a/README.txt b/README.txt index 02abba4..92c24fc 100644 --- a/README.txt +++ b/README.txt @@ -10,7 +10,7 @@ regxmllib is a collection of tools and libraries for the creation of RegXML (SMPTE ST 2001-1) representations of MXF header metadata (SMPTE ST 377-1). A RegXML Fragment example can be found at [1] -[1] /regxmllib/src/test/resources/reference-files +[1] src/test/resources/reference-files Two implementations of regxmllib are provided: @@ -45,18 +45,14 @@ REGXMLLIBJ Prerequisites ------------- -Java 7 language and SDK +Java 8 language and SDK -(recommended) Ant +Maven (recommended) Git -(recommended) Netbeans 8.0 - (recommended) SMPTE Metadata Registers (Types, Elements, Groups and Labels) -(optional) GnuPG, Maven and Maven Ant Task to deploy to OSSRH - Quick Start ----------- @@ -64,13 +60,13 @@ Quick Start The following outputs to path PATH_TO_FRAGMENT an XML representation of the header metadata of the MXF file at path PATH_TO_MXF_FILE -* build the 'jar' target using Netbeans or Ant, or run the Maven 'install' goal +* build the 'jar' target using Maven 'package' goal * choose one of the following: * OPTION 1 - * retrieve the four SMPTE Metadata Registers (see [2] above) + * retrieve the four SMPTE Metadata Registers (see [1] above) * build the metadictionaries from the SMPTE registers @@ -81,16 +77,25 @@ of the header metadata of the MXF file at path PATH_TO_MXF_FILE * retrieve metadictionaries from [3] - [3] https://github.com/sandflow/IMF/tree/master/registers + [3] https://github.com/sandflow/IMF/tree/master/dict * generate the RegXML fragment run java -cp com.sandflow.smpte.tools.RegXMLDump -all -d ... - -i PATH_TO_MXF_FILE > PATH_TO_FRAGMENT - -NOTE: Maven is only supported for testing and building the main project artifact, i.e. the JAR. Building -other artifacts requires Ant. - + -i > + +* (optional) generate XSDs for RegXML Fragments + + run java -cp com.sandflow.smpte.tools.GenerateDictionaryXMLSchema -d ... + -o + +* (optional) generate XSDs for SMPTE registers + + run java -cp com.sandflow.smpte.tools.GenerateXMLSchemaDocuments -cp + -d + + where is equal to com.sandflow.smpte.register.catsup.TypesRegisterModel, etc. + Architecture ------------ @@ -139,54 +144,6 @@ XMLRegistersToDict: converts XML-based SMPTE metadata registers to a RegXML meta GenerateXMLSchemaDocuments: generates XSDs for the SMPTE metadata registers GenerateDictionaryXMLSchema: generate XSDs for RegXML Fragments from the RegXML metadictionaries - - -Building Metadictionaries -------------------------- - -RegXML metadictionaries can be built directly from SMPTE metadata registers using the build -system. - -* store all four SMPTE registers at: - - /input/xml-registers/Elements.xml - /input/xml-registers/Types.xml - /input/xml-registers/Labels.xml - /input/xml-registers/Groups.xml - -* run the build-regxml-dict target - -* the metadictionaries are output at - - /output/regxml-dicts - - -Building RegXML XML Schemas ---------------------------- - -XML Schemas for RegXML Fragments can be built directly from SMPTE metadata registers -using the build system. - -* build the RegXML metadictionaries as described in BUILDING METADICTIONARIES - -* run the build-regxml-schemas target - -* the xml schemas are output at - - /output/regxml-schemas - - -Building Metadata Register Schemas ----------------------------------- - -The build-register-schemas build target can be used to generate XML Schemas for -SMPTE Metadata Registers directly from the classes at com.sandflow.smpte.register. - -* build the build-register-schemas target - -* the Metadata Register schemas are output at - - /output/register-schemas Unit Test @@ -196,12 +153,14 @@ Unit testing is performed by generating RegXML fragments from sample files locat at [1] and registers located at [2]. The resulting RegXML fragments are compared to reference RegXML fragments located at [3]. -Reference RegXML fragments can regenerated using by building the build-reference-test-files target. +[1] src/test/mxf-files +[2] src/test/registers +[3] src/test/regxml-files -[1] /regxmllib/src/test/sample-files -[2] /regxmllib/src/test/registers -[3] /regxmllib/src/test/reference-files +Reference RegXML fragments can regenerated by running the package goal with the build-reference-test-files profile: + mvn package -Pbuild-reference-files + Maven Artifacts --------------- @@ -239,7 +198,7 @@ regxmllibc generally follows the architecture and idioms of regxmllibj. Applications will typically call FragmentBuilder::fromTriplet() or MXFFragmentBuilder::fromInputStream(), and the unit test at [1] provides an example. -[1] /regxmllib/src/test/cpp/com/sandflow/smpte/dict/MetaDictionaryTest.cpp +[1] src/test/cpp/com/sandflow/smpte/dict/MetaDictionaryTest.cpp regxmllibc does not however support the conversion of the SMPTE Metadata Registers to RegXML metadictionaries, and instead relies on the metadictionaries generated by @@ -253,72 +212,43 @@ As with regxmllibj, unit testing is performed by generating RegXML fragments fro at [1] and reference metadictionaries located at [2]. The resulting RegXML fragments are compared to reference RegXML fragments located at [3]. -[1] /regxmllib/src/test/sample-files -[2] /regxmllib/src/test/regxml-dicts -[3] /regxmllib/src/test/reference-files +[1] src/test/mxf-files +[2] src/test/regxml-dicts +[3] src/test/regxml-files DIRECTORIES AND NOTABLE FILES ============================= -/regxmllib Source code and build artifacts - -/regxmllib/build.xml Build script (Ant) - -/regxmllib/pom.xml Maven POM file (for building and deployment to OSSRH) - -/regxmllib/CMakeLists.txt CMake build file +build.xml Helper script (Ant) -/regxmllib/build.properties Constants, e.g. directory paths, used - by the build script +pom.xml Maven POM file -/regxmllib/nbproject Netbeans project files +CMakeLists.txt CMake build file -/regxmllib/build Output of the Ant build process - -/regxmllib/dist Location of the JAR output from the Ant build - process - -/regxmllib/target Output of the Maven build process, including the - JAR +target Output of the Maven build process, including the JAR -/regxmllib/src/java regxmllibj codebase +src/java regxmllibj codebase -/regxmllib/src/cpp regxmllibc codebase +src/cpp regxmllibc codebase -/regxmllib/src/main/config/repoversion.properties - Template Java properties file used to host the - a unique source code version generated using - git by the build system +src/main/config/repoversion.properties + Template Java properties file used to host the + a unique source code version generated using + git by the build system -/regxmllib/src/main/resources/reg.xsd - Common XML Schema definitions used when generating - XML Schemas for RegXML Fragments +src/main/resources/reg.xsd + Common XML Schema definitions used when generating + XML Schemas for RegXML Fragments -/regxmllib/src/test/resources/reference-files - Reference RegXML fragment used for unit testing +src/test/resources/regxml-files + Reference RegXML fragment used for unit testing -/regxmllib/src/test/resources/registers - Reference SMPTE registers used for unit testing +src/test/resources/registers + Reference SMPTE registers used for unit testing -/regxmllib/src/test/resources/sample-files - Sample MXF files used for unit testing +src/test/resources/mxf-files + Sample MXF files used for unit testing -/regxmllib/src/test/resources/regxml-dicts - Reference metadictionaries used for unit testing - -/output/register-schemas Stub directory containing XML Schemas - generated by the build system for the - SMPTE Metadata Registers - -/output/regxml-dicts Stub directory containing the RegXML metadictionaries - generated by the build system, from the SMPTE Metadata - Registers in /input/xml-registers - -/output/regxml-schemas Stub directory containing XML Schemas for RegXML Fragments - generated by the library from the RegXML metadictionaries - in /output/regxml-dicts - -/input/xml-registers Stub directory containing the (optional) - SMPTE Metadata Registers used to build - the metadictionaries +src/test/resources/regxml-dicts + Reference metadictionaries used for unit testing diff --git a/build.xml b/build.xml new file mode 100644 index 0000000..0c30fbe --- /dev/null +++ b/build.xml @@ -0,0 +1,95 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/input/.gitignore b/input/.gitignore deleted file mode 100644 index 466022a..0000000 --- a/input/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -* -!.gitignore -!xml-registers/ \ No newline at end of file diff --git a/input/xml-registers/.gitignore b/input/xml-registers/.gitignore deleted file mode 100644 index a3a0c8b..0000000 --- a/input/xml-registers/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore \ No newline at end of file diff --git a/log4j.properties b/log4j.properties new file mode 100644 index 0000000..e5f1c83 --- /dev/null +++ b/log4j.properties @@ -0,0 +1 @@ +com.sandflow=SEVERE \ No newline at end of file diff --git a/output/register-schemas/.gitignore b/output/register-schemas/.gitignore deleted file mode 100644 index a3a0c8b..0000000 --- a/output/register-schemas/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore \ No newline at end of file diff --git a/output/regxml-dicts/.gitignore b/output/regxml-dicts/.gitignore deleted file mode 100644 index a3a0c8b..0000000 --- a/output/regxml-dicts/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore \ No newline at end of file diff --git a/output/regxml-schemas/.gitignore b/output/regxml-schemas/.gitignore deleted file mode 100644 index a3a0c8b..0000000 --- a/output/regxml-schemas/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..1321ce4 --- /dev/null +++ b/pom.xml @@ -0,0 +1,215 @@ + + 4.0.0 + + com.sandflow + regxmllib + 1.1.4-SNAPSHOT + jar + + + 1.8 + 1.8 + UTF-8 + ${basedir}/src/main/config + ${basedir}/src/main/resources + ${basedir}/src/test/resources + + + regxmllib + https://github.com/sandflow/regxmllib + Tools and libraries for the creation of RegXML (SMPTE ST 2001-1) representations of MXF header metadata (SMPTE ST 377-1). + + + + BSD 2-clause "Simplified" License + http://choosealicense.com/licenses/bsd-2-clause/ + repo + + + + + + Pierre-Anthony Lemieux + pal@palemieux.com + + + + + scm:git:https://github.com/sandflow/regxmllib.git + scm:git:https://github.com/sandflow/regxmllib.git + https://github.com/sandflow/regxmllib.git + + + + Sandflow Consulting LLC + http://www.sandflow.com + + + + + junit + junit + 4.12 + test + + + + + + + org.codehaus.mojo + buildnumber-maven-plugin + 1.4 + + + + create + + + + + + maven-surefire-plugin + 3.0.0-M1 + + + log4j.properties + + + + + + + config + ${com.sandflow.config.dir} + true + + + resources + ${com.sandflow.resources.dir} + + + + + + + build-reference-files + + true + + + + javax.xml.bind + jaxb-api + 2.3.1 + runtime + + + com.sun.xml.bind + jaxb-impl + 2.3.1 + runtime + + + com.sun.xml.bind + jaxb-core + 2.3.0.1 + runtime + + + + + + maven-antrun-plugin + 1.8 + + + package + + + + + + + + + run + + + + + + + + + release + + + ossrh + https://oss.sonatype.org/content/repositories/snapshots + + + ossrh + https://oss.sonatype.org/service/local/staging/deploy/maven2/ + + + + + + org.apache.maven.plugins + maven-source-plugin + 2.2.1 + + + attach-sources + + jar-no-fork + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.9.1 + + + attach-javadocs + + jar + + + + + + org.apache.maven.plugins + maven-gpg-plugin + 1.5 + + + sign-artifacts + verify + + sign + + + + + + org.sonatype.plugins + nexus-staging-maven-plugin + 1.6.7 + true + + ossrh + https://oss.sonatype.org/ + true + + + + + + + + \ No newline at end of file diff --git a/regxmllib/.gitignore b/regxmllib/.gitignore deleted file mode 100644 index 766a5d9..0000000 --- a/regxmllib/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -/build/ -/dist/ -/nbproject/private/ -/target/ -/cmake/ -pom.xml.asc -CMakeSettings.json -/.vs/ \ No newline at end of file diff --git a/regxmllib/build.properties b/regxmllib/build.properties deleted file mode 100644 index 362545a..0000000 --- a/regxmllib/build.properties +++ /dev/null @@ -1,13 +0,0 @@ -register.dir=../input/xml-registers -elements.register=${register.dir}/Elements.xml -types.register=${register.dir}/Types.xml -labels.register=${register.dir}/Labels.xml -groups.register=${register.dir}/Groups.xml -register.schema.dir=../output/register-schemas -dict.schema.dir=../output/regxml-schemas -dict.dir=../output/regxml-dicts -main.config.dir=src/main/config -main.resources.dir=src/main/resources -test.resources.dir=src/test/resources -repoversion.dir=${main.config.dir} -repoversion.name=repoversion.properties \ No newline at end of file diff --git a/regxmllib/build.xml b/regxmllib/build.xml deleted file mode 100644 index 35529e9..0000000 --- a/regxmllib/build.xml +++ /dev/null @@ -1,397 +0,0 @@ - - - - - - - - - - - - Build scripts for regxmllib - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/regxmllib/nbproject/build-impl.xml b/regxmllib/nbproject/build-impl.xml deleted file mode 100644 index d8b64c8..0000000 --- a/regxmllib/nbproject/build-impl.xml +++ /dev/null @@ -1,1413 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set src.java.dir - Must set test.java.dir - Must set build.dir - Must set dist.dir - Must set build.classes.dir - Must set dist.javadoc.dir - Must set build.test.classes.dir - Must set build.test.results.dir - Must set build.classes.excludes - Must set dist.jar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - No tests executed. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set JVM to use for profiling in profiler.info.jvm - Must set profiler agent JVM arguments in profiler.info.jvmargs.agent - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - To run this application from the command line without Ant, try: - - java -jar "${dist.jar.resolved}" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set run.class - - - - Must select one file in the IDE or set run.class - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set debug.class - - - - - Must select one file in the IDE or set debug.class - - - - - Must set fix.includes - - - - - - - - - - This target only works when run from inside the NetBeans IDE. - - - - - - - - - Must select one file in the IDE or set profile.class - This target only works when run from inside the NetBeans IDE. - - - - - - - - - This target only works when run from inside the NetBeans IDE. - - - - - - - - - - - - - This target only works when run from inside the NetBeans IDE. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set run.class - - - - - - Must select some files in the IDE or set test.includes - - - - - Must select one file in the IDE or set run.class - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.includes - - - - - - - - - - - - - - - - - - - - Some tests failed; see details above. - - - - - - - - - Must select some files in the IDE or set test.includes - - - - Some tests failed; see details above. - - - - Must select some files in the IDE or set test.class - Must select some method in the IDE or set test.method - - - - Some tests failed; see details above. - - - - - Must select one file in the IDE or set test.class - - - - Must select one file in the IDE or set test.class - Must select some method in the IDE or set test.method - - - - - - - - - - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/regxmllib/nbproject/genfiles.properties b/regxmllib/nbproject/genfiles.properties deleted file mode 100644 index a8904af..0000000 --- a/regxmllib/nbproject/genfiles.properties +++ /dev/null @@ -1,8 +0,0 @@ -build.xml.data.CRC32=7d96b106 -build.xml.script.CRC32=ca51d1c4 -build.xml.stylesheet.CRC32=8064a381@1.75.2.48 -# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. -# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. -nbproject/build-impl.xml.data.CRC32=a6d704c1 -nbproject/build-impl.xml.script.CRC32=73756721 -nbproject/build-impl.xml.stylesheet.CRC32=876e7a8f@1.75.2.48 diff --git a/regxmllib/nbproject/project.properties b/regxmllib/nbproject/project.properties deleted file mode 100644 index ccf65fa..0000000 --- a/regxmllib/nbproject/project.properties +++ /dev/null @@ -1,100 +0,0 @@ -annotation.processing.enabled=true -annotation.processing.enabled.in.editor=false -annotation.processing.processors.list= -annotation.processing.run.all.processors=true -annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output -application.title=regxmllib -application.vendor=pal -auxiliary.com-junichi11-netbeans-changelf.use-global=false -auxiliary.com-junichi11-netbeans-changelf.use-project=true -auxiliary.org-netbeans-spi-editor-hints-projects.perProjectHintSettingsFile=nbproject/cfg_hints.xml -build.classes.dir=${build.dir}/classes -build.classes.excludes=**/*.java,**/*.form -# This directory is removed when the project is cleaned: -build.dir=build -build.generated.dir=${build.dir}/generated -build.generated.sources.dir=${build.dir}/generated-sources -# Only compile against the classpath explicitly listed here: -build.sysclasspath=ignore -build.test.classes.dir=${build.dir}/test/classes -build.test.results.dir=${build.dir}/test/results -# Uncomment to specify the preferred debugger connection transport: -#debug.transport=dt_socket -debug.classpath=\ - ${run.classpath} -debug.test.classpath=\ - ${run.test.classpath} -# Files in build.classes.dir which should be excluded from distribution jar -dist.archive.excludes= -# This directory is removed when the project is cleaned: -dist.dir=dist -dist.jar=${dist.dir}/regxmllib.jar -dist.javadoc.dir=${dist.dir}/javadoc -endorsed.classpath=\ - ${libs.JAXB-ENDORSED.classpath} -excludes= -file.reference.src-test=src/test -includes=** -jar.archive.disabled=${jnlp.enabled} -jar.compress=false -jar.index=${jnlp.enabled} -javac.classpath= -# Space-separated list of extra javac options -javac.compilerargs=-Xlint:unchecked -javac.deprecation=false -javac.processorpath=\ - ${javac.classpath} -javac.source=1.7 -javac.target=1.7 -javac.test.classpath=\ - ${javac.classpath}:\ - ${build.classes.dir}:\ - ${libs.junit.classpath} -javac.test.processorpath=\ - ${javac.test.classpath} -javadoc.additionalparam= -javadoc.author=false -javadoc.encoding=${source.encoding} -javadoc.noindex=false -javadoc.nonavbar=false -javadoc.notree=false -javadoc.private=false -javadoc.splitindex=true -javadoc.use=true -javadoc.version=false -javadoc.windowtitle= -jaxbwiz.gensrc.classpath=${libs.jaxb.classpath} -jaxbwiz.xjcdef.classpath=${libs.jaxb.classpath} -jaxbwiz.xjcrun.classpath=${libs.jaxb.classpath} -jnlp.codebase.type=no.codebase -jnlp.descriptor=application -jnlp.enabled=false -jnlp.mixed.code=default -jnlp.offline-allowed=false -jnlp.signed=false -jnlp.signing= -jnlp.signing.alias= -jnlp.signing.keystore= -# Optional override of default Codebase manifest attribute, use to prevent RIAs from being repurposed -manifest.custom.codebase= -# Optional override of default Permissions manifest attribute (supported values: sandbox, all-permissions) -manifest.custom.permissions= -meta.inf.dir=${src.dir}/META-INF -mkdist.disabled=true -platform.active=default_platform -project.license=bsd -run.classpath=\ - ${javac.classpath}:\ - ${build.classes.dir} -# Space-separated list of JVM arguments used when running the project. -# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value. -# To set system properties for unit tests define test-sys-prop.name=value: -run.jvmargs= -run.test.classpath=\ - ${javac.test.classpath}:\ - ${build.test.classes.dir}:\ - ${file.reference.src-test} -source.encoding=UTF-8 -main.class=com.sandflow.smpte.tools.RegXMLDump -src.java.dir=src\\main\\java -test.java.dir=src\\test\\java diff --git a/regxmllib/nbproject/project.xml b/regxmllib/nbproject/project.xml deleted file mode 100644 index 3f8e40e..0000000 --- a/regxmllib/nbproject/project.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - org.netbeans.modules.java.j2seproject - - - - regxmllib - - - - - - - - - diff --git a/regxmllib/pom.xml b/regxmllib/pom.xml deleted file mode 100644 index 67f630b..0000000 --- a/regxmllib/pom.xml +++ /dev/null @@ -1,91 +0,0 @@ - - 4.0.0 - - com.sandflow - regxmllib - 1.1.2-SNAPSHOT - jar - - - 1.7 - 1.7 - UTF-8 - - - regxmllib - https://github.com/sandflow/regxmllib - Tools and libraries for the creation of RegXML (SMPTE ST 2001-1) representations of MXF header metadata (SMPTE ST 377-1). - - - - BSD 2-clause "Simplified" License - http://choosealicense.com/licenses/bsd-2-clause/ - repo - - - - - - Pierre-Anthony Lemieux - pal@sandflow.com - Sandflow Consulting LLC - http://www.sandflow.com - - - - - scm:git:https://github.com/sandflow/regxmllib.git - scm:git:https://github.com/sandflow/regxmllib.git - https://github.com/sandflow/regxmllib.git - - - - Sandflow Consulting LLC - http://www.sandflow.com - - - - - junit - junit - 3.8.2 - test - - - - - - - org.codehaus.mojo - buildnumber-maven-plugin - 1.1 - - - - create - - - - - - - - config - ${basedir}/src/main/config - true - - - resources - ${basedir}/src/main/resources - - - - - resources - ${basedir}/src/test/resources - - - - - \ No newline at end of file diff --git a/regxmllib/src/test/resources/regxml-dicts/www-smpte-ra-org-reg-395-2014.xml b/regxmllib/src/test/resources/regxml-dicts/www-smpte-ra-org-reg-395-2014.xml deleted file mode 100644 index afff397..0000000 --- a/regxmllib/src/test/resources/regxml-dicts/www-smpte-ra-org-reg-395-2014.xml +++ /dev/null @@ -1,28 +0,0 @@ - - -urn:uuid:3c1f888d-e658-5f03-7fe0-c96d7c354c75 -http://www.smpte-ra.org/reg/395/2014 - - -urn:smpte:ul:060e2b34.027f0101.0c020101.01010000 -LensUnitAcquisitionMetadata -Lens Unit Acquisition Metadata -Lens Unit Acquisition Metadata -true - - -urn:smpte:ul:060e2b34.027f0101.0c020101.02010000 -CameraUnitAcquisitionMetadata -Camera Unit Acquisition Metadata -Camera Unit Acquisition Metadata -true - - -urn:smpte:ul:060e2b34.027f0101.0c020101.7f010000 -UserDefinedAcquisitionMetadata -UserDefinedAcquisitionMetadata -UserDefinedAcquisitionMetadata -true - - - diff --git a/regxmllib/regxmllibcConfig.cmake.in b/regxmllibcConfig.cmake.in similarity index 100% rename from regxmllib/regxmllibcConfig.cmake.in rename to regxmllibcConfig.cmake.in diff --git a/regxmllib/src/main/config/repoversion.properties b/src/main/config/repoversion.properties similarity index 100% rename from regxmllib/src/main/config/repoversion.properties rename to src/main/config/repoversion.properties diff --git a/regxmllib/src/main/cpp/com/sandflow/smpte/klv/Group.h b/src/main/cpp/com/sandflow/smpte/klv/Group.h similarity index 100% rename from regxmllib/src/main/cpp/com/sandflow/smpte/klv/Group.h rename to src/main/cpp/com/sandflow/smpte/klv/Group.h diff --git a/regxmllib/src/main/cpp/com/sandflow/smpte/klv/KLVException.h b/src/main/cpp/com/sandflow/smpte/klv/KLVException.h similarity index 100% rename from regxmllib/src/main/cpp/com/sandflow/smpte/klv/KLVException.h rename to src/main/cpp/com/sandflow/smpte/klv/KLVException.h diff --git a/regxmllib/src/main/cpp/com/sandflow/smpte/klv/KLVStream.cpp b/src/main/cpp/com/sandflow/smpte/klv/KLVStream.cpp similarity index 99% rename from regxmllib/src/main/cpp/com/sandflow/smpte/klv/KLVStream.cpp rename to src/main/cpp/com/sandflow/smpte/klv/KLVStream.cpp index 2e8a6bd..a49676a 100644 --- a/regxmllib/src/main/cpp/com/sandflow/smpte/klv/KLVStream.cpp +++ b/src/main/cpp/com/sandflow/smpte/klv/KLVStream.cpp @@ -102,7 +102,7 @@ namespace rxml { throw std::ios_base::failure("Max BER length exceeded"); } - unsigned char *buf = new unsigned char[bersz]; + unsigned char buf[8]; this->read((char*)buf, bersz); diff --git a/regxmllib/src/main/cpp/com/sandflow/smpte/klv/KLVStream.h b/src/main/cpp/com/sandflow/smpte/klv/KLVStream.h similarity index 100% rename from regxmllib/src/main/cpp/com/sandflow/smpte/klv/KLVStream.h rename to src/main/cpp/com/sandflow/smpte/klv/KLVStream.h diff --git a/regxmllib/src/main/cpp/com/sandflow/smpte/klv/LocalSet.cpp b/src/main/cpp/com/sandflow/smpte/klv/LocalSet.cpp similarity index 95% rename from regxmllib/src/main/cpp/com/sandflow/smpte/klv/LocalSet.cpp rename to src/main/cpp/com/sandflow/smpte/klv/LocalSet.cpp index 7ed1a0c..510640d 100644 --- a/regxmllib/src/main/cpp/com/sandflow/smpte/klv/LocalSet.cpp +++ b/src/main/cpp/com/sandflow/smpte/klv/LocalSet.cpp @@ -61,14 +61,14 @@ namespace rxml { if (!t.getKey().isUL()) { - throw new KLVException("Triplet key " + rxml::to_string(t.getKey()) + " is not a UL"); + throw KLVException("Triplet key " + rxml::to_string(t.getKey()) + " is not a UL"); } UL ul = t.getKey().asUL(); if (!ul.isLocalSet()) { - throw new KLVException("Triplet with key " + rxml::to_string(t.getKey()) + " is not a Local Set"); + throw KLVException("Triplet with key " + rxml::to_string(t.getKey()) + " is not a Local Set"); } membuf mb((char*)t.getValue(), (char*)t.getValue() + t.getLength()); diff --git a/regxmllib/src/main/cpp/com/sandflow/smpte/klv/LocalSet.h b/src/main/cpp/com/sandflow/smpte/klv/LocalSet.h similarity index 100% rename from regxmllib/src/main/cpp/com/sandflow/smpte/klv/LocalSet.h rename to src/main/cpp/com/sandflow/smpte/klv/LocalSet.h diff --git a/regxmllib/src/main/cpp/com/sandflow/smpte/klv/LocalTagRegister.h b/src/main/cpp/com/sandflow/smpte/klv/LocalTagRegister.h similarity index 100% rename from regxmllib/src/main/cpp/com/sandflow/smpte/klv/LocalTagRegister.h rename to src/main/cpp/com/sandflow/smpte/klv/LocalTagRegister.h diff --git a/regxmllib/src/main/cpp/com/sandflow/smpte/klv/MemoryTriplet.cpp b/src/main/cpp/com/sandflow/smpte/klv/MemoryTriplet.cpp similarity index 100% rename from regxmllib/src/main/cpp/com/sandflow/smpte/klv/MemoryTriplet.cpp rename to src/main/cpp/com/sandflow/smpte/klv/MemoryTriplet.cpp diff --git a/regxmllib/src/main/cpp/com/sandflow/smpte/klv/MemoryTriplet.h b/src/main/cpp/com/sandflow/smpte/klv/MemoryTriplet.h similarity index 100% rename from regxmllib/src/main/cpp/com/sandflow/smpte/klv/MemoryTriplet.h rename to src/main/cpp/com/sandflow/smpte/klv/MemoryTriplet.h diff --git a/regxmllib/src/main/cpp/com/sandflow/smpte/klv/Triplet.h b/src/main/cpp/com/sandflow/smpte/klv/Triplet.h similarity index 100% rename from regxmllib/src/main/cpp/com/sandflow/smpte/klv/Triplet.h rename to src/main/cpp/com/sandflow/smpte/klv/Triplet.h diff --git a/regxmllib/src/main/cpp/com/sandflow/smpte/mxf/FillItem.cpp b/src/main/cpp/com/sandflow/smpte/mxf/FillItem.cpp similarity index 100% rename from regxmllib/src/main/cpp/com/sandflow/smpte/mxf/FillItem.cpp rename to src/main/cpp/com/sandflow/smpte/mxf/FillItem.cpp diff --git a/regxmllib/src/main/cpp/com/sandflow/smpte/mxf/FillItem.h b/src/main/cpp/com/sandflow/smpte/mxf/FillItem.h similarity index 100% rename from regxmllib/src/main/cpp/com/sandflow/smpte/mxf/FillItem.h rename to src/main/cpp/com/sandflow/smpte/mxf/FillItem.h diff --git a/regxmllib/src/main/cpp/com/sandflow/smpte/mxf/MXFException.h b/src/main/cpp/com/sandflow/smpte/mxf/MXFException.h similarity index 100% rename from regxmllib/src/main/cpp/com/sandflow/smpte/mxf/MXFException.h rename to src/main/cpp/com/sandflow/smpte/mxf/MXFException.h diff --git a/regxmllib/src/main/cpp/com/sandflow/smpte/mxf/MXFStream.cpp b/src/main/cpp/com/sandflow/smpte/mxf/MXFStream.cpp similarity index 100% rename from regxmllib/src/main/cpp/com/sandflow/smpte/mxf/MXFStream.cpp rename to src/main/cpp/com/sandflow/smpte/mxf/MXFStream.cpp diff --git a/regxmllib/src/main/cpp/com/sandflow/smpte/mxf/MXFStream.h b/src/main/cpp/com/sandflow/smpte/mxf/MXFStream.h similarity index 100% rename from regxmllib/src/main/cpp/com/sandflow/smpte/mxf/MXFStream.h rename to src/main/cpp/com/sandflow/smpte/mxf/MXFStream.h diff --git a/regxmllib/src/main/cpp/com/sandflow/smpte/mxf/PartitionPack.cpp b/src/main/cpp/com/sandflow/smpte/mxf/PartitionPack.cpp similarity index 95% rename from regxmllib/src/main/cpp/com/sandflow/smpte/mxf/PartitionPack.cpp rename to src/main/cpp/com/sandflow/smpte/mxf/PartitionPack.cpp index 77488c5..0ca610d 100644 --- a/regxmllib/src/main/cpp/com/sandflow/smpte/mxf/PartitionPack.cpp +++ b/src/main/cpp/com/sandflow/smpte/mxf/PartitionPack.cpp @@ -34,7 +34,7 @@ namespace rxml { if (!t.getKey().isUL()) { - throw new MXFException("Triplet key " + rxml::to_string(t.getKey()) + " is not a UL"); + throw MXFException("Triplet key " + rxml::to_string(t.getKey()) + " is not a UL"); } UL ul = t.getKey().asUL(); @@ -112,7 +112,7 @@ namespace rxml { this->essenceContainers = kis.readBatch(); } catch (std::exception e) { - throw new MXFException("Error reading partition pack"); + throw MXFException("Error reading partition pack"); } } diff --git a/regxmllib/src/main/cpp/com/sandflow/smpte/mxf/PartitionPack.h b/src/main/cpp/com/sandflow/smpte/mxf/PartitionPack.h similarity index 100% rename from regxmllib/src/main/cpp/com/sandflow/smpte/mxf/PartitionPack.h rename to src/main/cpp/com/sandflow/smpte/mxf/PartitionPack.h diff --git a/regxmllib/src/main/cpp/com/sandflow/smpte/mxf/PrimerPack.cpp b/src/main/cpp/com/sandflow/smpte/mxf/PrimerPack.cpp similarity index 97% rename from regxmllib/src/main/cpp/com/sandflow/smpte/mxf/PrimerPack.cpp rename to src/main/cpp/com/sandflow/smpte/mxf/PrimerPack.cpp index 94c96ae..08fcd94 100644 --- a/regxmllib/src/main/cpp/com/sandflow/smpte/mxf/PrimerPack.cpp +++ b/src/main/cpp/com/sandflow/smpte/mxf/PrimerPack.cpp @@ -39,7 +39,7 @@ namespace rxml { unsigned long itemcount = kis.readUnsignedLong(); - unsigned long itemlength = kis.readUnsignedLong(); + kis.readUnsignedLong(); // item length for (unsigned long i = 0; i < itemcount; i++) { @@ -79,4 +79,4 @@ namespace rxml { return key.isUL() && KEY.equals(key.asUL(), UL::IGNORE_VERSION); } -} \ No newline at end of file +} diff --git a/regxmllib/src/main/cpp/com/sandflow/smpte/mxf/PrimerPack.h b/src/main/cpp/com/sandflow/smpte/mxf/PrimerPack.h similarity index 100% rename from regxmllib/src/main/cpp/com/sandflow/smpte/mxf/PrimerPack.h rename to src/main/cpp/com/sandflow/smpte/mxf/PrimerPack.h diff --git a/regxmllib/src/main/cpp/com/sandflow/smpte/mxf/Set.cpp b/src/main/cpp/com/sandflow/smpte/mxf/Set.cpp similarity index 97% rename from regxmllib/src/main/cpp/com/sandflow/smpte/mxf/Set.cpp rename to src/main/cpp/com/sandflow/smpte/mxf/Set.cpp index 37c3ffd..d19d00f 100644 --- a/regxmllib/src/main/cpp/com/sandflow/smpte/mxf/Set.cpp +++ b/src/main/cpp/com/sandflow/smpte/mxf/Set.cpp @@ -48,7 +48,7 @@ namespace rxml { if (!hasInstanceUID(g)) { - throw new MXFException("Group is missing an instance ID property"); + throw MXFException("Group is missing an instance ID property"); } diff --git a/regxmllib/src/main/cpp/com/sandflow/smpte/mxf/Set.h b/src/main/cpp/com/sandflow/smpte/mxf/Set.h similarity index 100% rename from regxmllib/src/main/cpp/com/sandflow/smpte/mxf/Set.h rename to src/main/cpp/com/sandflow/smpte/mxf/Set.h diff --git a/regxmllib/src/main/cpp/com/sandflow/smpte/regxml/FragmentBuilder.cpp b/src/main/cpp/com/sandflow/smpte/regxml/FragmentBuilder.cpp similarity index 84% rename from regxmllib/src/main/cpp/com/sandflow/smpte/regxml/FragmentBuilder.cpp rename to src/main/cpp/com/sandflow/smpte/regxml/FragmentBuilder.cpp index a4bc46a..3098e53 100644 --- a/regxmllib/src/main/cpp/com/sandflow/smpte/regxml/FragmentBuilder.cpp +++ b/src/main/cpp/com/sandflow/smpte/regxml/FragmentBuilder.cpp @@ -26,6 +26,9 @@ #include "FragmentBuilder.h" #include "com/sandflow/smpte/util/IDAU.h" +#include +#include +#include namespace rxml { @@ -55,8 +58,10 @@ namespace rxml { const std::string FragmentBuilder::REGXML_NS = "http://sandflow.com/ns/SMPTEST2001-1/baseline"; const std::string FragmentBuilder::XMLNS_NS = "http://www.w3.org/2000/xmlns/"; + const std::string FragmentBuilder::ACTUALTYPE_ATTR = "actualType"; const std::string FragmentBuilder::UID_ATTR = "uid"; + const std::string FragmentBuilder::ESCAPE_ATTR = "escape"; const Definition * FragmentBuilder::findBaseTypeDefinition(const Definition * definition, const DefinitionResolver & defresolver) { @@ -110,9 +115,9 @@ namespace rxml { FragmentBuilder::FragmentBuilder(const DefinitionResolver & defresolver, const std::map& setresolver, const AUIDNameResolver * anameresolver, EventHandler * evthandler) : defresolver(defresolver), setresolver(setresolver), anameresolver(anameresolver), evthandler(evthandler) { } - DOMDocumentFragment * FragmentBuilder::fromTriplet(const Group & group, DOMDocument & document) { + xercesc::DOMDocumentFragment * FragmentBuilder::fromTriplet(const Group & group, xercesc::DOMDocument & document) { - DOMDocumentFragment *df = NULL; + xercesc::DOMDocumentFragment *df = NULL; try { @@ -125,7 +130,7 @@ namespace rxml { /* NOTE: Hack to clean-up namespace prefixes */ for (std::map::const_iterator it = this->nsprefixes.begin(); it != this->nsprefixes.end(); it++) { - ((DOMElement*)df->getFirstChild())->setAttributeNS(DOMHelper::fromUTF8(XMLNS_NS), DOMHelper::fromUTF8("xmlns:" + it->second), DOMHelper::fromUTF8(it->first)); + ((xercesc::DOMElement*)df->getFirstChild())->setAttributeNS(DOMHelper::fromUTF8(XMLNS_NS), DOMHelper::fromUTF8("xmlns:" + it->second), DOMHelper::fromUTF8(it->first)); } @@ -176,11 +181,11 @@ namespace rxml { } - void FragmentBuilder::addInformativeComment(DOMElement *element, std::string comment) { + void FragmentBuilder::addInformativeComment(xercesc::DOMElement *element, std::string comment) { element->appendChild(element->getOwnerDocument()->createComment(DOMHelper::fromUTF8(comment))); } - void FragmentBuilder::appendCommentWithAUIDName(AUID auid, DOMElement* elem) { + void FragmentBuilder::appendCommentWithAUIDName(AUID auid, xercesc::DOMElement* elem) { if (this->anameresolver != NULL) { const std::string *ename = this->anameresolver->getLocalName(auid); @@ -192,7 +197,7 @@ namespace rxml { } } - void FragmentBuilder::applyRule3(DOMNode * node, const Group & group) { + void FragmentBuilder::applyRule3(xercesc::DOMNode * node, const Group & group) { const Definition *definition = defresolver.getDefinition(group.getKey()); @@ -235,7 +240,7 @@ namespace rxml { /* create the element */ - DOMElement *objelem = node->getOwnerDocument()->createElementNS( + xercesc::DOMElement *objelem = node->getOwnerDocument()->createElementNS( DOMHelper::fromUTF8(definition->ns), DOMHelper::fromUTF8(definition->symbol) ); @@ -291,7 +296,7 @@ namespace rxml { } - DOMElement *elem = node->getOwnerDocument()->createElementNS( + xercesc::DOMElement *elem = node->getOwnerDocument()->createElementNS( DOMHelper::fromUTF8(itemdef->ns), DOMHelper::fromUTF8(itemdef->symbol) ); @@ -316,22 +321,22 @@ namespace rxml { const XMLCh* iid = objelem->getLastChild()->getTextContent(); /* look for identical instanceID in parent elements */ - DOMNode *parent = node; + xercesc::DOMNode *parent = node; - while (parent->getNodeType() == DOMNode::ELEMENT_NODE) { + while (parent->getNodeType() == xercesc::DOMNode::ELEMENT_NODE) { - for (DOMNode *n = parent->getFirstChild(); n != NULL; n = n->getNextSibling()) { + for (xercesc::DOMNode *n = parent->getFirstChild(); n != NULL; n = n->getNextSibling()) { - if (n->getNodeType() == DOMNode::ELEMENT_NODE - && XMLString::compareIString(iidname, n->getLocalName()) == 0 - && XMLString::compareIString(iidns, n->getNamespaceURI()) == 0 - && XMLString::compareIString(iid, n->getTextContent()) == 0) { + if (n->getNodeType() == xercesc::DOMNode::ELEMENT_NODE + && xercesc::XMLString::compareIString(iidname, n->getLocalName()) == 0 + && xercesc::XMLString::compareIString(iidns, n->getNamespaceURI()) == 0 + && xercesc::XMLString::compareIString(iid, n->getTextContent()) == 0) { CircularStrongReferenceError err(std::string(DOMHelper::toUTF8(iid)), "Group " + definition->symbol); evthandler->info(err); - addInformativeComment((DOMElement*)n, err.getReason()); + addInformativeComment((xercesc::DOMElement*)n, err.getReason()); return; } @@ -345,7 +350,7 @@ namespace rxml { /* add reg:uid if property is a unique ID */ if (((PropertyDefinition*)itemdef)->uniqueIdentifier.is_valid() && ((PropertyDefinition*)itemdef)->uniqueIdentifier.get()) { - DOMAttr *attr = node->getOwnerDocument()->createAttributeNS( + xercesc::DOMAttr *attr = node->getOwnerDocument()->createAttributeNS( DOMHelper::fromUTF8(REGXML_NS), DOMHelper::fromUTF8(UID_ATTR) ); @@ -361,7 +366,7 @@ namespace rxml { } - void FragmentBuilder::applyRule4(DOMElement * element, MXFInputStream & value, const PropertyDefinition * propdef) { + void FragmentBuilder::applyRule4(xercesc::DOMElement * element, MXFInputStream & value, const PropertyDefinition * propdef) { try { @@ -387,7 +392,7 @@ namespace rxml { addInformativeComment(element, err.getReason()); } else { - throw new FragmentBuilder::UnknownByteOrderError(ByteOrder_UL.to_string()); + throw FragmentBuilder::UnknownByteOrderError(ByteOrder_UL.to_string()); } } else { @@ -553,7 +558,7 @@ namespace rxml { } - void FragmentBuilder::applyRule5(DOMElement * element, MXFInputStream & value, const Definition * definition) { + void FragmentBuilder::applyRule5(xercesc::DOMElement * element, MXFInputStream & value, const Definition * definition) { try { @@ -661,7 +666,7 @@ namespace rxml { } - void FragmentBuilder::readCharacters(DOMElement * element, MXFInputStream & value, const CharacterTypeDefinition * definition, bool isSingleChar) { + void FragmentBuilder::readCharacters(xercesc::DOMElement * element, MXFInputStream & value, const CharacterTypeDefinition * definition, bool isSingleChar) { std::vector sb; @@ -715,32 +720,73 @@ namespace rxml { ) ); - /*evthandler->error(err); + } - addInformativeComment(element, err.getReason()); + xercesc::TranscodeFromStr mxfchars((XMLByte*) sb.data(), sb.size(), codec.c_str()); + std::vector xmlchar; - return;*/ + /* do we need to use the escape mechanism specified in ST 2001-1? */ + bool isescaped = false; + + for (int i = 0; i < mxfchars.length(); i++) { + + XMLCh c = mxfchars.str()[i]; + + /* terminate on the first null character unless we are parsing a single character type */ + + if (c == 0 && (!isSingleChar)) break; + + if (c == 0x09 + || c == 0x0A + || (c >= 0x20 && c <= 0x23) + || c >= 0x25) { + + xmlchar.push_back(c); + + } else { + + isescaped = true; + + std::stringstream ss; + + /* c is guaranteed to be less than 0xFF */ + + ss << "$#x" << std::hex << c << ";"; + + std::copy(std::istream_iterator(ss), std::istream_iterator(), std::back_inserter(xmlchar)); + + } } - TranscodeFromStr xmlstr((XMLByte*)sb.data(), sb.size(), codec.c_str()); + if (isescaped) { - /* return if there is not text to add */ - if (xmlstr.length() == 0) return; + xercesc::DOMAttr *attr = element->getOwnerDocument()->createAttributeNS( + DOMHelper::fromUTF8(REGXML_NS), + DOMHelper::fromUTF8(ESCAPE_ATTR) + ); + + attr->setPrefix(DOMHelper::fromUTF8(getElementNSPrefix(REGXML_NS))); + attr->setTextContent(DOMHelper::fromUTF8("true")); + element->setAttributeNodeNS(attr); + + } + + xmlchar.push_back(0); - element->setTextContent(xmlstr.str()); + element->setTextContent(&(xmlchar[0])); } - void FragmentBuilder::applyRule5_1(DOMElement * element, MXFInputStream & value, const CharacterTypeDefinition * definition) { + void FragmentBuilder::applyRule5_1(xercesc::DOMElement * element, MXFInputStream & value, const CharacterTypeDefinition * definition) { - readCharacters(element, value, definition, false /* do not remove trailing zeroes for a single char */); + readCharacters(element, value, definition, true /* do not remove trailing zeroes for a single char */); } - void FragmentBuilder::applyRule5_2(DOMElement * element, MXFInputStream & value, const EnumerationTypeDefinition * definition) { + void FragmentBuilder::applyRule5_2(xercesc::DOMElement * element, MXFInputStream & value, const EnumerationTypeDefinition * definition) { const Definition *bdef = findBaseDefinition(defresolver.getDefinition(definition->elementType)); @@ -856,7 +902,7 @@ namespace rxml { } - void FragmentBuilder::applyRule5_3(DOMElement * element, MXFInputStream & value, const ExtendibleEnumerationTypeDefinition * definition) { + void FragmentBuilder::applyRule5_3(xercesc::DOMElement * element, MXFInputStream & value, const ExtendibleEnumerationTypeDefinition * definition) { UL ul = value.readUL(); @@ -868,7 +914,7 @@ namespace rxml { } - void FragmentBuilder::applyRule5_4(DOMElement * element, MXFInputStream & value, const FixedArrayTypeDefinition * definition) { + void FragmentBuilder::applyRule5_4(xercesc::DOMElement * element, MXFInputStream & value, const FixedArrayTypeDefinition * definition) { if (definition->identification.equals(UUID_UL)) { @@ -885,7 +931,7 @@ namespace rxml { } } - void FragmentBuilder::applyCoreRule5_4(DOMElement * element, MXFInputStream & value, const Definition * tdef, unsigned long elementcount) { + void FragmentBuilder::applyCoreRule5_4(xercesc::DOMElement * element, MXFInputStream & value, const Definition * tdef, unsigned long elementcount) { for (unsigned long i = 0; i < elementcount; i++) { @@ -897,7 +943,7 @@ namespace rxml { } else { /* Rule 5.4.2 */ - DOMElement *elem = element->getOwnerDocument()->createElementNS( + xercesc::DOMElement *elem = element->getOwnerDocument()->createElementNS( DOMHelper::fromUTF8(tdef->ns), DOMHelper::fromUTF8(tdef->symbol) ); @@ -912,7 +958,7 @@ namespace rxml { } } - void FragmentBuilder::applyRule5_5(DOMElement * element, MXFInputStream & value, const IndirectTypeDefinition * definition) { + void FragmentBuilder::applyRule5_5(xercesc::DOMElement * element, MXFInputStream & value, const IndirectTypeDefinition * definition) { /* see https://github.com/sandflow/regxmllib/issues/74 for a discussion on Indirect Type */ KLVStream::ByteOrder bo; @@ -957,7 +1003,7 @@ namespace rxml { } // create reg:actualType attribute - DOMAttr *attr = element->getOwnerDocument()->createAttributeNS( + xercesc::DOMAttr *attr = element->getOwnerDocument()->createAttributeNS( DOMHelper::fromUTF8(REGXML_NS), DOMHelper::fromUTF8(ACTUALTYPE_ATTR) ); @@ -971,7 +1017,7 @@ namespace rxml { } - void FragmentBuilder::applyRule5_6(DOMElement * element, MXFInputStream & value, const IntegerTypeDefinition * definition) { + void FragmentBuilder::applyRule5_6(xercesc::DOMElement * element, MXFInputStream & value, const IntegerTypeDefinition * definition) { switch (definition->size) { @@ -1064,7 +1110,7 @@ namespace rxml { } - void FragmentBuilder::applyRule5_7(DOMElement * element, MXFInputStream & value, const OpaqueTypeDefinition * definition) { + void FragmentBuilder::applyRule5_7(xercesc::DOMElement * element, MXFInputStream & value, const OpaqueTypeDefinition * definition) { /* NOTE: Opaque Types are not used in MXF */ throw FragmentBuilder::Exception("Opaque types are not supported."); @@ -1101,7 +1147,7 @@ namespace rxml { return sb.str(); } - void FragmentBuilder::applyRule5_8(DOMElement * element, MXFInputStream & value, const RecordTypeDefinition * definition) { + void FragmentBuilder::applyRule5_8(xercesc::DOMElement * element, MXFInputStream & value, const RecordTypeDefinition * definition) { if (definition->identification.equals(AUID_UL)) { @@ -1180,7 +1226,7 @@ namespace rxml { const Definition *itemdef = findBaseDefinition(defresolver.getDefinition(it->type)); - DOMElement *elem = element->getOwnerDocument()->createElementNS( + xercesc::DOMElement *elem = element->getOwnerDocument()->createElementNS( DOMHelper::fromUTF8(definition->ns), DOMHelper::fromUTF8(it->name) ); @@ -1197,7 +1243,7 @@ namespace rxml { } - void FragmentBuilder::applyRule5_9(DOMElement * element, MXFInputStream & value, const RenameTypeDefinition * definition) { + void FragmentBuilder::applyRule5_9(xercesc::DOMElement * element, MXFInputStream & value, const RenameTypeDefinition * definition) { const Definition *rdef = defresolver.getDefinition(definition->renamedType); @@ -1205,24 +1251,24 @@ namespace rxml { } - void FragmentBuilder::applyRule5_10(DOMElement * element, MXFInputStream & value, const SetTypeDefinition * definition) { + void FragmentBuilder::applyRule5_10(xercesc::DOMElement * element, MXFInputStream & value, const SetTypeDefinition * definition) { const Definition* tdef = findBaseDefinition(defresolver.getDefinition(definition->elementType)); unsigned long itemcount = value.readUnsignedLong(); - unsigned long itemlength = value.readUnsignedLong(); + value.readUnsignedLong(); // item length applyCoreRule5_4(element, value, tdef, (unsigned long)itemcount); } - void FragmentBuilder::applyRule5_11(DOMElement * element, MXFInputStream & value, const StreamTypeDefinition * definition) { + void FragmentBuilder::applyRule5_11(xercesc::DOMElement * element, MXFInputStream & value, const StreamTypeDefinition * definition) { throw FragmentBuilder::Exception("Rule 5.11 is not supported yet."); } - void FragmentBuilder::applyRule5_12(DOMElement * element, MXFInputStream & value, const StringTypeDefinition * definition) { + void FragmentBuilder::applyRule5_12(xercesc::DOMElement * element, MXFInputStream & value, const StringTypeDefinition * definition) { /* Rule 5.12 */ const Definition *chrdef = findBaseDefinition(defresolver.getDefinition(definition->elementType)); @@ -1246,12 +1292,12 @@ namespace rxml { element, value, (CharacterTypeDefinition*)chrdef, - true /* remove trailing zeroes */ + false /* remove trailing zeroes */ ); } - void FragmentBuilder::applyRule5_13(DOMElement * element, MXFInputStream & value, const StrongReferenceTypeDefinition * definition) { + void FragmentBuilder::applyRule5_13(xercesc::DOMElement * element, MXFInputStream & value, const StrongReferenceTypeDefinition * definition) { const Definition *tdef = findBaseDefinition(defresolver.getDefinition(definition->referencedType)); @@ -1289,7 +1335,7 @@ namespace rxml { } - void FragmentBuilder::applyRule5_beta(DOMElement * element, MXFInputStream & value, const LensSerialFloatTypeDefinition * definition) { + void FragmentBuilder::applyRule5_beta(xercesc::DOMElement * element, MXFInputStream & value, const LensSerialFloatTypeDefinition * definition) { throw FragmentBuilder::Exception("Lens serial floats not supported."); @@ -1318,7 +1364,7 @@ namespace rxml { return props; } - void FragmentBuilder::applyRule5_14(DOMElement * element, MXFInputStream & value, const VariableArrayTypeDefinition * definition) { + void FragmentBuilder::applyRule5_14(xercesc::DOMElement * element, MXFInputStream & value, const VariableArrayTypeDefinition * definition) { const Definition *tdef = findBaseDefinition(defresolver.getDefinition(definition->elementType)); @@ -1350,7 +1396,7 @@ namespace rxml { } else { unsigned long itemcount = value.readLong(); - unsigned long itemlength = value.readLong(); + value.readLong(); // item length applyCoreRule5_4(element, value, tdef, itemcount); } @@ -1359,7 +1405,7 @@ namespace rxml { } - void FragmentBuilder::applyRule5_15(DOMElement * element, MXFInputStream & value, const WeakReferenceTypeDefinition * typedefinition) { + void FragmentBuilder::applyRule5_15(xercesc::DOMElement * element, MXFInputStream & value, const WeakReferenceTypeDefinition * typedefinition) { const ClassDefinition *classdef = (ClassDefinition*)defresolver.getDefinition(typedefinition->referencedType); diff --git a/regxmllib/src/main/cpp/com/sandflow/smpte/regxml/FragmentBuilder.h b/src/main/cpp/com/sandflow/smpte/regxml/FragmentBuilder.h similarity index 82% rename from regxmllib/src/main/cpp/com/sandflow/smpte/regxml/FragmentBuilder.h rename to src/main/cpp/com/sandflow/smpte/regxml/FragmentBuilder.h index ccae0ba..5e61d1d 100644 --- a/regxmllib/src/main/cpp/com/sandflow/smpte/regxml/FragmentBuilder.h +++ b/src/main/cpp/com/sandflow/smpte/regxml/FragmentBuilder.h @@ -65,8 +65,6 @@ #include -XERCES_CPP_NAMESPACE_USE - namespace rxml { class FragmentBuilder { @@ -337,7 +335,7 @@ namespace rxml { * @throws KLVException * @throws com.sandflow.smpte.regxml.FragmentBuilder.RuleException */ - DOMDocumentFragment* fromTriplet(const Group &group, DOMDocument &document); + xercesc::DOMDocumentFragment* fromTriplet(const Group &group, xercesc::DOMDocument &document); private: @@ -371,6 +369,7 @@ namespace rxml { static const std::string XMLNS_NS; static const std::string UID_ATTR; static const std::string ACTUALTYPE_ATTR; + static const std::string ESCAPE_ATTR; /* METHODS */ @@ -386,49 +385,49 @@ namespace rxml { static std::string generateISO8601Date(int year, int month, int day); - void readCharacters(DOMElement *element, MXFInputStream &value, const CharacterTypeDefinition *definition, bool removeTrailingZeroes); + void readCharacters(xercesc::DOMElement *element, MXFInputStream &value, const CharacterTypeDefinition *definition, bool removeTrailingZeroes); - static void addInformativeComment(DOMElement * element, std::string comment); + static void addInformativeComment(xercesc::DOMElement * element, std::string comment); - void appendCommentWithAUIDName(AUID auid, DOMElement * elem); + void appendCommentWithAUIDName(AUID auid, xercesc::DOMElement * elem); - void applyRule3(DOMNode *node, const Group &group); + void applyRule3(xercesc::DOMNode *node, const Group &group); - void applyRule4(DOMElement *element, MXFInputStream &value, const PropertyDefinition *propdef); + void applyRule4(xercesc::DOMElement *element, MXFInputStream &value, const PropertyDefinition *propdef); - void applyRule5(DOMElement *element, MXFInputStream &value, const Definition *definition); + void applyRule5(xercesc::DOMElement *element, MXFInputStream &value, const Definition *definition); - void applyRule5_1(DOMElement *element, MXFInputStream &value, const CharacterTypeDefinition *definition); + void applyRule5_1(xercesc::DOMElement *element, MXFInputStream &value, const CharacterTypeDefinition *definition); - void applyRule5_2(DOMElement *element, MXFInputStream &value, const EnumerationTypeDefinition *definition); + void applyRule5_2(xercesc::DOMElement *element, MXFInputStream &value, const EnumerationTypeDefinition *definition); - void applyRule5_3(DOMElement *element, MXFInputStream &value, const ExtendibleEnumerationTypeDefinition* definition); + void applyRule5_3(xercesc::DOMElement *element, MXFInputStream &value, const ExtendibleEnumerationTypeDefinition* definition); - void applyRule5_4(DOMElement *element, MXFInputStream &value, const FixedArrayTypeDefinition *definition); + void applyRule5_4(xercesc::DOMElement *element, MXFInputStream &value, const FixedArrayTypeDefinition *definition); /* TODO: unsigned int or unsigned long for element count */ - void applyCoreRule5_4(DOMElement* element, MXFInputStream &value, const Definition *tdef, unsigned long elementcount); + void applyCoreRule5_4(xercesc::DOMElement* element, MXFInputStream &value, const Definition *tdef, unsigned long elementcount); - void applyRule5_5(DOMElement* element, MXFInputStream &value, const IndirectTypeDefinition *definition); + void applyRule5_5(xercesc::DOMElement* element, MXFInputStream &value, const IndirectTypeDefinition *definition); - void applyRule5_6(DOMElement *element, MXFInputStream &value, const IntegerTypeDefinition *definition); + void applyRule5_6(xercesc::DOMElement *element, MXFInputStream &value, const IntegerTypeDefinition *definition); - void applyRule5_7(DOMElement *element, MXFInputStream &value, const OpaqueTypeDefinition *definition); + void applyRule5_7(xercesc::DOMElement *element, MXFInputStream &value, const OpaqueTypeDefinition *definition); - void applyRule5_8(DOMElement *element, MXFInputStream &value, const RecordTypeDefinition *definition); + void applyRule5_8(xercesc::DOMElement *element, MXFInputStream &value, const RecordTypeDefinition *definition); - void applyRule5_9(DOMElement *element, MXFInputStream &value, const RenameTypeDefinition *definition); + void applyRule5_9(xercesc::DOMElement *element, MXFInputStream &value, const RenameTypeDefinition *definition); - void applyRule5_10(DOMElement *element, MXFInputStream &value, const SetTypeDefinition *definition); + void applyRule5_10(xercesc::DOMElement *element, MXFInputStream &value, const SetTypeDefinition *definition); - void applyRule5_11(DOMElement *element, MXFInputStream &value, const StreamTypeDefinition *definition); + void applyRule5_11(xercesc::DOMElement *element, MXFInputStream &value, const StreamTypeDefinition *definition); - void applyRule5_12(DOMElement *element, MXFInputStream &value, const StringTypeDefinition *definition); + void applyRule5_12(xercesc::DOMElement *element, MXFInputStream &value, const StringTypeDefinition *definition); - void applyRule5_13(DOMElement *element, MXFInputStream &value, const StrongReferenceTypeDefinition *definition); + void applyRule5_13(xercesc::DOMElement *element, MXFInputStream &value, const StrongReferenceTypeDefinition *definition); - /*void applyRule5_alpha(DOMElement *element, MXFInputStream &value, const FloatTypeDefinition *definition) { + /*void applyRule5_alpha(xercesc::DOMElement *element, MXFInputStream &value, const FloatTypeDefinition *definition) { double val = 0; @@ -452,11 +451,11 @@ namespace rxml { }*/ - void applyRule5_beta(DOMElement *element, MXFInputStream &value, const LensSerialFloatTypeDefinition *definition); + void applyRule5_beta(xercesc::DOMElement *element, MXFInputStream &value, const LensSerialFloatTypeDefinition *definition); - void applyRule5_14(DOMElement *element, MXFInputStream &value, const VariableArrayTypeDefinition *definition); + void applyRule5_14(xercesc::DOMElement *element, MXFInputStream &value, const VariableArrayTypeDefinition *definition); - void applyRule5_15(DOMElement *element, MXFInputStream &value, const WeakReferenceTypeDefinition *typedefinition); + void applyRule5_15(xercesc::DOMElement *element, MXFInputStream &value, const WeakReferenceTypeDefinition *typedefinition); /* MEMBERS */ diff --git a/regxmllib/src/main/cpp/com/sandflow/smpte/regxml/MXFFragmentBuilder.cpp b/src/main/cpp/com/sandflow/smpte/regxml/MXFFragmentBuilder.cpp similarity index 98% rename from regxmllib/src/main/cpp/com/sandflow/smpte/regxml/MXFFragmentBuilder.cpp rename to src/main/cpp/com/sandflow/smpte/regxml/MXFFragmentBuilder.cpp index 7b0a344..9209186 100644 --- a/regxmllib/src/main/cpp/com/sandflow/smpte/regxml/MXFFragmentBuilder.cpp +++ b/src/main/cpp/com/sandflow/smpte/regxml/MXFFragmentBuilder.cpp @@ -146,12 +146,12 @@ namespace rxml { } - DOMDocumentFragment* MXFFragmentBuilder::fromInputStream( + xercesc::DOMDocumentFragment* MXFFragmentBuilder::fromInputStream( std::istream &mxfpartition, const DefinitionResolver &defresolver, const FragmentBuilder::AUIDNameResolver *enumnameresolver, const AUID *rootclasskey, - DOMDocument &document, + xercesc::DOMDocument &document, EventHandler *ev) { static const UL INDEX_TABLE_SEGMENT_UL = "urn:smpte:ul:060e2b34.02530101.0d010201.01100100"; diff --git a/regxmllib/src/main/cpp/com/sandflow/smpte/regxml/MXFFragmentBuilder.h b/src/main/cpp/com/sandflow/smpte/regxml/MXFFragmentBuilder.h similarity index 98% rename from regxmllib/src/main/cpp/com/sandflow/smpte/regxml/MXFFragmentBuilder.h rename to src/main/cpp/com/sandflow/smpte/regxml/MXFFragmentBuilder.h index 6b2a156..44dcc38 100644 --- a/regxmllib/src/main/cpp/com/sandflow/smpte/regxml/MXFFragmentBuilder.h +++ b/src/main/cpp/com/sandflow/smpte/regxml/MXFFragmentBuilder.h @@ -38,8 +38,6 @@ #include "com/sandflow/util/events/Event.h" #include "com/sandflow/util/strformat.h" -XERCES_CPP_NAMESPACE_USE - namespace rxml { @@ -172,12 +170,12 @@ namespace rxml { * * @return Document Fragment containing a single RegXML Fragment */ - static DOMDocumentFragment* fromInputStream( + static xercesc::DOMDocumentFragment* fromInputStream( std::istream &mxfpartition, const DefinitionResolver &defresolver, const FragmentBuilder::AUIDNameResolver *enumnameresolver, const AUID *rootclasskey, - DOMDocument &document, + xercesc::DOMDocument &document, EventHandler *ev = &NULL_EVENTHANDLER); }; diff --git a/regxmllib/src/main/cpp/com/sandflow/smpte/regxml/definitions/CharacterTypeDefinition.h b/src/main/cpp/com/sandflow/smpte/regxml/definitions/CharacterTypeDefinition.h similarity index 100% rename from regxmllib/src/main/cpp/com/sandflow/smpte/regxml/definitions/CharacterTypeDefinition.h rename to src/main/cpp/com/sandflow/smpte/regxml/definitions/CharacterTypeDefinition.h diff --git a/regxmllib/src/main/cpp/com/sandflow/smpte/regxml/definitions/ClassDefinition.h b/src/main/cpp/com/sandflow/smpte/regxml/definitions/ClassDefinition.h similarity index 100% rename from regxmllib/src/main/cpp/com/sandflow/smpte/regxml/definitions/ClassDefinition.h rename to src/main/cpp/com/sandflow/smpte/regxml/definitions/ClassDefinition.h diff --git a/regxmllib/src/main/cpp/com/sandflow/smpte/regxml/definitions/Definition.h b/src/main/cpp/com/sandflow/smpte/regxml/definitions/Definition.h similarity index 98% rename from regxmllib/src/main/cpp/com/sandflow/smpte/regxml/definitions/Definition.h rename to src/main/cpp/com/sandflow/smpte/regxml/definitions/Definition.h index 69af6fc..97ab1d9 100644 --- a/regxmllib/src/main/cpp/com/sandflow/smpte/regxml/definitions/Definition.h +++ b/src/main/cpp/com/sandflow/smpte/regxml/definitions/Definition.h @@ -36,7 +36,7 @@ namespace rxml { class DefinitionVisitor; struct Definition { - + virtual ~Definition() {} virtual void accept(DefinitionVisitor & v) const = 0; std::string symbol; @@ -48,4 +48,4 @@ namespace rxml { }; } -#endif \ No newline at end of file +#endif diff --git a/regxmllib/src/main/cpp/com/sandflow/smpte/regxml/definitions/DefinitionVisitor.h b/src/main/cpp/com/sandflow/smpte/regxml/definitions/DefinitionVisitor.h similarity index 100% rename from regxmllib/src/main/cpp/com/sandflow/smpte/regxml/definitions/DefinitionVisitor.h rename to src/main/cpp/com/sandflow/smpte/regxml/definitions/DefinitionVisitor.h diff --git a/regxmllib/src/main/cpp/com/sandflow/smpte/regxml/definitions/EnumerationTypeDefinition.h b/src/main/cpp/com/sandflow/smpte/regxml/definitions/EnumerationTypeDefinition.h similarity index 100% rename from regxmllib/src/main/cpp/com/sandflow/smpte/regxml/definitions/EnumerationTypeDefinition.h rename to src/main/cpp/com/sandflow/smpte/regxml/definitions/EnumerationTypeDefinition.h diff --git a/regxmllib/src/main/cpp/com/sandflow/smpte/regxml/definitions/ExtendibleEnumerationTypeDefinition.h b/src/main/cpp/com/sandflow/smpte/regxml/definitions/ExtendibleEnumerationTypeDefinition.h similarity index 100% rename from regxmllib/src/main/cpp/com/sandflow/smpte/regxml/definitions/ExtendibleEnumerationTypeDefinition.h rename to src/main/cpp/com/sandflow/smpte/regxml/definitions/ExtendibleEnumerationTypeDefinition.h diff --git a/regxmllib/src/main/cpp/com/sandflow/smpte/regxml/definitions/FixedArrayTypeDefinition.h b/src/main/cpp/com/sandflow/smpte/regxml/definitions/FixedArrayTypeDefinition.h similarity index 100% rename from regxmllib/src/main/cpp/com/sandflow/smpte/regxml/definitions/FixedArrayTypeDefinition.h rename to src/main/cpp/com/sandflow/smpte/regxml/definitions/FixedArrayTypeDefinition.h diff --git a/regxmllib/src/main/cpp/com/sandflow/smpte/regxml/definitions/IndirectTypeDefinition.h b/src/main/cpp/com/sandflow/smpte/regxml/definitions/IndirectTypeDefinition.h similarity index 100% rename from regxmllib/src/main/cpp/com/sandflow/smpte/regxml/definitions/IndirectTypeDefinition.h rename to src/main/cpp/com/sandflow/smpte/regxml/definitions/IndirectTypeDefinition.h diff --git a/regxmllib/src/main/cpp/com/sandflow/smpte/regxml/definitions/IntegerTypeDefinition.h b/src/main/cpp/com/sandflow/smpte/regxml/definitions/IntegerTypeDefinition.h similarity index 100% rename from regxmllib/src/main/cpp/com/sandflow/smpte/regxml/definitions/IntegerTypeDefinition.h rename to src/main/cpp/com/sandflow/smpte/regxml/definitions/IntegerTypeDefinition.h diff --git a/regxmllib/src/main/cpp/com/sandflow/smpte/regxml/definitions/LensSerialFloatTypeDefinition.h b/src/main/cpp/com/sandflow/smpte/regxml/definitions/LensSerialFloatTypeDefinition.h similarity index 100% rename from regxmllib/src/main/cpp/com/sandflow/smpte/regxml/definitions/LensSerialFloatTypeDefinition.h rename to src/main/cpp/com/sandflow/smpte/regxml/definitions/LensSerialFloatTypeDefinition.h diff --git a/regxmllib/src/main/cpp/com/sandflow/smpte/regxml/definitions/OpaqueTypeDefinition.h b/src/main/cpp/com/sandflow/smpte/regxml/definitions/OpaqueTypeDefinition.h similarity index 100% rename from regxmllib/src/main/cpp/com/sandflow/smpte/regxml/definitions/OpaqueTypeDefinition.h rename to src/main/cpp/com/sandflow/smpte/regxml/definitions/OpaqueTypeDefinition.h diff --git a/regxmllib/src/main/cpp/com/sandflow/smpte/regxml/definitions/PropertyAliasDefinition.h b/src/main/cpp/com/sandflow/smpte/regxml/definitions/PropertyAliasDefinition.h similarity index 100% rename from regxmllib/src/main/cpp/com/sandflow/smpte/regxml/definitions/PropertyAliasDefinition.h rename to src/main/cpp/com/sandflow/smpte/regxml/definitions/PropertyAliasDefinition.h diff --git a/regxmllib/src/main/cpp/com/sandflow/smpte/regxml/definitions/PropertyDefinition.h b/src/main/cpp/com/sandflow/smpte/regxml/definitions/PropertyDefinition.h similarity index 100% rename from regxmllib/src/main/cpp/com/sandflow/smpte/regxml/definitions/PropertyDefinition.h rename to src/main/cpp/com/sandflow/smpte/regxml/definitions/PropertyDefinition.h diff --git a/regxmllib/src/main/cpp/com/sandflow/smpte/regxml/definitions/RecordTypeDefinition.h b/src/main/cpp/com/sandflow/smpte/regxml/definitions/RecordTypeDefinition.h similarity index 100% rename from regxmllib/src/main/cpp/com/sandflow/smpte/regxml/definitions/RecordTypeDefinition.h rename to src/main/cpp/com/sandflow/smpte/regxml/definitions/RecordTypeDefinition.h diff --git a/regxmllib/src/main/cpp/com/sandflow/smpte/regxml/definitions/RenameTypeDefinition.h b/src/main/cpp/com/sandflow/smpte/regxml/definitions/RenameTypeDefinition.h similarity index 100% rename from regxmllib/src/main/cpp/com/sandflow/smpte/regxml/definitions/RenameTypeDefinition.h rename to src/main/cpp/com/sandflow/smpte/regxml/definitions/RenameTypeDefinition.h diff --git a/regxmllib/src/main/cpp/com/sandflow/smpte/regxml/definitions/SetTypeDefinition.h b/src/main/cpp/com/sandflow/smpte/regxml/definitions/SetTypeDefinition.h similarity index 100% rename from regxmllib/src/main/cpp/com/sandflow/smpte/regxml/definitions/SetTypeDefinition.h rename to src/main/cpp/com/sandflow/smpte/regxml/definitions/SetTypeDefinition.h diff --git a/regxmllib/src/main/cpp/com/sandflow/smpte/regxml/definitions/StreamTypeDefinition.h b/src/main/cpp/com/sandflow/smpte/regxml/definitions/StreamTypeDefinition.h similarity index 100% rename from regxmllib/src/main/cpp/com/sandflow/smpte/regxml/definitions/StreamTypeDefinition.h rename to src/main/cpp/com/sandflow/smpte/regxml/definitions/StreamTypeDefinition.h diff --git a/regxmllib/src/main/cpp/com/sandflow/smpte/regxml/definitions/StringTypeDefinition.h b/src/main/cpp/com/sandflow/smpte/regxml/definitions/StringTypeDefinition.h similarity index 100% rename from regxmllib/src/main/cpp/com/sandflow/smpte/regxml/definitions/StringTypeDefinition.h rename to src/main/cpp/com/sandflow/smpte/regxml/definitions/StringTypeDefinition.h diff --git a/regxmllib/src/main/cpp/com/sandflow/smpte/regxml/definitions/StrongReferenceTypeDefinition.h b/src/main/cpp/com/sandflow/smpte/regxml/definitions/StrongReferenceTypeDefinition.h similarity index 100% rename from regxmllib/src/main/cpp/com/sandflow/smpte/regxml/definitions/StrongReferenceTypeDefinition.h rename to src/main/cpp/com/sandflow/smpte/regxml/definitions/StrongReferenceTypeDefinition.h diff --git a/regxmllib/src/main/cpp/com/sandflow/smpte/regxml/definitions/VariableArrayTypeDefinition.h b/src/main/cpp/com/sandflow/smpte/regxml/definitions/VariableArrayTypeDefinition.h similarity index 100% rename from regxmllib/src/main/cpp/com/sandflow/smpte/regxml/definitions/VariableArrayTypeDefinition.h rename to src/main/cpp/com/sandflow/smpte/regxml/definitions/VariableArrayTypeDefinition.h diff --git a/regxmllib/src/main/cpp/com/sandflow/smpte/regxml/definitions/WeakReferenceTypeDefinition.h b/src/main/cpp/com/sandflow/smpte/regxml/definitions/WeakReferenceTypeDefinition.h similarity index 100% rename from regxmllib/src/main/cpp/com/sandflow/smpte/regxml/definitions/WeakReferenceTypeDefinition.h rename to src/main/cpp/com/sandflow/smpte/regxml/definitions/WeakReferenceTypeDefinition.h diff --git a/regxmllib/src/main/cpp/com/sandflow/smpte/regxml/dict/DefinitionResolver.h b/src/main/cpp/com/sandflow/smpte/regxml/dict/DefinitionResolver.h similarity index 100% rename from regxmllib/src/main/cpp/com/sandflow/smpte/regxml/dict/DefinitionResolver.h rename to src/main/cpp/com/sandflow/smpte/regxml/dict/DefinitionResolver.h diff --git a/regxmllib/src/main/cpp/com/sandflow/smpte/regxml/dict/MetaDictionary.cpp b/src/main/cpp/com/sandflow/smpte/regxml/dict/MetaDictionary.cpp similarity index 92% rename from regxmllib/src/main/cpp/com/sandflow/smpte/regxml/dict/MetaDictionary.cpp rename to src/main/cpp/com/sandflow/smpte/regxml/dict/MetaDictionary.cpp index 19b1c69..548bb67 100644 --- a/regxmllib/src/main/cpp/com/sandflow/smpte/regxml/dict/MetaDictionary.cpp +++ b/src/main/cpp/com/sandflow/smpte/regxml/dict/MetaDictionary.cpp @@ -95,6 +95,10 @@ namespace rxml { meta_dictionary.subclassesOf[parentauid].insert(def.identification); } + } else { + + delete def_copy; + } } @@ -111,6 +115,11 @@ namespace rxml { const AUID parentauid = MetaDictionary::createNormalizedAUID(def.memberOf); meta_dictionary.membersOf[parentauid].insert(def.identification); + + } else { + + delete def_copy; + } @@ -118,72 +127,69 @@ namespace rxml { virtual void visit(const PropertyAliasDefinition & def) { - Definition *def_copy = new PropertyAliasDefinition(def); - const AUID parentauid = MetaDictionary::createNormalizedAUID(def.memberOf); meta_dictionary.membersOf[parentauid].insert(def.identification); - } virtual void visit(const EnumerationTypeDefinition &def) { Definition *def_copy = new EnumerationTypeDefinition(def); - _visit(def_copy); + if (! _visit(def_copy)) delete def_copy; } virtual void visit(const CharacterTypeDefinition &def) { Definition *def_copy = new CharacterTypeDefinition(def); - _visit(def_copy); + if (!_visit(def_copy)) delete def_copy; } virtual void visit(const RenameTypeDefinition & def) { Definition *def_copy = new RenameTypeDefinition(def); - _visit(def_copy); + if (!_visit(def_copy)) delete def_copy; } virtual void visit(const RecordTypeDefinition & def) { Definition *def_copy = new RecordTypeDefinition(def); - _visit(def_copy); + if (!_visit(def_copy)) delete def_copy; } virtual void visit(const StringTypeDefinition & def) { Definition *def_copy = new StringTypeDefinition(def); - _visit(def_copy); + if (!_visit(def_copy)) delete def_copy; } virtual void visit(const LensSerialFloatTypeDefinition & def) { Definition *def_copy = new LensSerialFloatTypeDefinition(def); - _visit(def_copy); + if (!_visit(def_copy)) delete def_copy; } virtual void visit(const IntegerTypeDefinition & def) { Definition *def_copy = new IntegerTypeDefinition(def); - _visit(def_copy); + if (!_visit(def_copy)) delete def_copy; } virtual void visit(const StrongReferenceTypeDefinition & def) { Definition *def_copy = new StrongReferenceTypeDefinition(def); - _visit(def_copy); + if (!_visit(def_copy)) delete def_copy; } virtual void visit(const WeakReferenceTypeDefinition & def) { Definition *def_copy = new WeakReferenceTypeDefinition(def); - _visit(def_copy); + if (!_visit(def_copy)) delete def_copy; } virtual void visit(const ExtendibleEnumerationTypeDefinition & def) { Definition *def_copy = new ExtendibleEnumerationTypeDefinition(def); - _visit(def_copy); + if (!_visit(def_copy)) delete def_copy; } virtual void visit(const VariableArrayTypeDefinition & def) { @@ -195,31 +201,31 @@ namespace rxml { virtual void visit(const FixedArrayTypeDefinition & def) { Definition *def_copy = new FixedArrayTypeDefinition(def); - _visit(def_copy); + if (!_visit(def_copy)) delete def_copy; } virtual void visit(const OpaqueTypeDefinition & def) { Definition *def_copy = new OpaqueTypeDefinition(def); - _visit(def_copy); + if (!_visit(def_copy)) delete def_copy; } virtual void visit(const IndirectTypeDefinition & def) { Definition *def_copy = new IndirectTypeDefinition(def); - _visit(def_copy); + if (!_visit(def_copy)) delete def_copy; } virtual void visit(const StreamTypeDefinition & def) { Definition *def_copy = new StreamTypeDefinition(def); - _visit(def_copy); + if (!_visit(def_copy)) delete def_copy; } virtual void visit(const SetTypeDefinition & def) { Definition *def_copy = new SetTypeDefinition(def); - _visit(def_copy); + if (!_visit(def_copy)) delete def_copy; } private: diff --git a/regxmllib/src/main/cpp/com/sandflow/smpte/regxml/dict/MetaDictionary.h b/src/main/cpp/com/sandflow/smpte/regxml/dict/MetaDictionary.h similarity index 100% rename from regxmllib/src/main/cpp/com/sandflow/smpte/regxml/dict/MetaDictionary.h rename to src/main/cpp/com/sandflow/smpte/regxml/dict/MetaDictionary.h diff --git a/regxmllib/src/main/cpp/com/sandflow/smpte/regxml/dict/MetaDictionaryCollection.cpp b/src/main/cpp/com/sandflow/smpte/regxml/dict/MetaDictionaryCollection.cpp similarity index 100% rename from regxmllib/src/main/cpp/com/sandflow/smpte/regxml/dict/MetaDictionaryCollection.cpp rename to src/main/cpp/com/sandflow/smpte/regxml/dict/MetaDictionaryCollection.cpp diff --git a/regxmllib/src/main/cpp/com/sandflow/smpte/regxml/dict/MetaDictionaryCollection.h b/src/main/cpp/com/sandflow/smpte/regxml/dict/MetaDictionaryCollection.h similarity index 100% rename from regxmllib/src/main/cpp/com/sandflow/smpte/regxml/dict/MetaDictionaryCollection.h rename to src/main/cpp/com/sandflow/smpte/regxml/dict/MetaDictionaryCollection.h diff --git a/regxmllib/src/main/cpp/com/sandflow/smpte/regxml/dict/importers/XMLImporter.cpp b/src/main/cpp/com/sandflow/smpte/regxml/dict/importers/XMLImporter.cpp similarity index 81% rename from regxmllib/src/main/cpp/com/sandflow/smpte/regxml/dict/importers/XMLImporter.cpp rename to src/main/cpp/com/sandflow/smpte/regxml/dict/importers/XMLImporter.cpp index aea9d2e..b859a94 100644 --- a/regxmllib/src/main/cpp/com/sandflow/smpte/regxml/dict/importers/XMLImporter.cpp +++ b/src/main/cpp/com/sandflow/smpte/regxml/dict/importers/XMLImporter.cpp @@ -95,7 +95,7 @@ namespace rxml { * @throws XMLImporter::Exception */ template void _readPropertyOfElement( - DOMElement *parent, + xercesc::DOMElement *parent, const char *namespaceURI, const char *localName, T& field, @@ -118,7 +118,7 @@ namespace rxml { } template void _readPropertyOfElement( - DOMElement *parent, + xercesc::DOMElement *parent, const char *namespaceURI, const char *localName, Optional& field, @@ -139,7 +139,7 @@ namespace rxml { } - void _readDefinition(DOMElement *element, Definition &def) { + void _readDefinition(xercesc::DOMElement *element, Definition &def) { _readPropertyOfElement(element, XML_NS.c_str(), "Identification", def.identification); @@ -149,7 +149,7 @@ namespace rxml { } - void _readClassDefinition(DOMElement *element, ClassDefinition &def) { + void _readClassDefinition(xercesc::DOMElement *element, ClassDefinition &def) { _readDefinition(element, def); @@ -158,14 +158,10 @@ namespace rxml { } - void _readPropertyDefinition(DOMElement *element, PropertyDefinition &def) { + void _readPropertyDefinition(xercesc::DOMElement *element, PropertyDefinition &def) { _readDefinition(element, def); - if (def.symbol == "FormatVersion") { - int b = 0; - } - _readPropertyOfElement(element, XML_NS.c_str(), "Type", def.type); _readPropertyOfElement(element, XML_NS.c_str(), "MemberOf", def.memberOf); _readPropertyOfElement(element, XML_NS.c_str(), "LocalIdentification", def.localIdentification); @@ -174,7 +170,7 @@ namespace rxml { } - void _readPropertyAliasDefinition(DOMElement *element, PropertyAliasDefinition &def) { + void _readPropertyAliasDefinition(xercesc::DOMElement *element, PropertyAliasDefinition &def) { _readPropertyDefinition(element, def); @@ -182,7 +178,7 @@ namespace rxml { } - void _readIntegerTypeDefinition(DOMElement *element, IntegerTypeDefinition &def) { + void _readIntegerTypeDefinition(xercesc::DOMElement *element, IntegerTypeDefinition &def) { _readDefinition(element, def); @@ -192,7 +188,7 @@ namespace rxml { } - void _readRenameTypeDefinition(DOMElement *element, RenameTypeDefinition &def) { + void _readRenameTypeDefinition(xercesc::DOMElement *element, RenameTypeDefinition &def) { _readDefinition(element, def); @@ -200,7 +196,7 @@ namespace rxml { } - void _readSetTypeDefinition(DOMElement *element, SetTypeDefinition &def) { + void _readSetTypeDefinition(xercesc::DOMElement *element, SetTypeDefinition &def) { _readDefinition(element, def); @@ -208,7 +204,7 @@ namespace rxml { } - void _readStringTypeDefinition(DOMElement *element, StringTypeDefinition &def) { + void _readStringTypeDefinition(xercesc::DOMElement *element, StringTypeDefinition &def) { _readDefinition(element, def); @@ -217,7 +213,7 @@ namespace rxml { } - void _readStrongReferenceTypeDefinition(DOMElement *element, StrongReferenceTypeDefinition &def) { + void _readStrongReferenceTypeDefinition(xercesc::DOMElement *element, StrongReferenceTypeDefinition &def) { _readDefinition(element, def); @@ -225,7 +221,7 @@ namespace rxml { } - void _readVariableTypeDefinition(DOMElement *element, VariableArrayTypeDefinition &def) { + void _readVariableTypeDefinition(xercesc::DOMElement *element, VariableArrayTypeDefinition &def) { _readDefinition(element, def); @@ -233,13 +229,13 @@ namespace rxml { } - void _readTypeDefinitionCharacter(DOMElement *element, CharacterTypeDefinition &def) { + void _readTypeDefinitionCharacter(xercesc::DOMElement *element, CharacterTypeDefinition &def) { _readDefinition(element, def); } - void _readFixedArrayTypeDefinition(DOMElement *element, FixedArrayTypeDefinition &def) { + void _readFixedArrayTypeDefinition(xercesc::DOMElement *element, FixedArrayTypeDefinition &def) { _readDefinition(element, def); @@ -248,14 +244,14 @@ namespace rxml { } - void _readRecordTypeDefinition(DOMElement *element, RecordTypeDefinition &def) { + void _readRecordTypeDefinition(xercesc::DOMElement *element, RecordTypeDefinition &def) { _readDefinition(element, def); /* read Members */ - DOMElement *membersElem = DOMHelper::getElementByTagNameNS( + xercesc::DOMElement *membersElem = DOMHelper::getElementByTagNameNS( element, DOMHelper::fromUTF8(XML_NS), DOMHelper::fromUTF8("Members") @@ -263,23 +259,23 @@ namespace rxml { if (!membersElem) { - throw new XMLImporter::Exception("Elements property missing"); + throw XMLImporter::Exception("Elements property missing"); } - DOMElement *memberElem = membersElem->getFirstElementChild(); + xercesc::DOMElement *memberElem = membersElem->getFirstElementChild(); while (memberElem) { - if (XMLString::compareIString(DOMHelper::fromUTF8("Name"), memberElem->getLocalName()) == 0) { + if (xercesc::XMLString::compareIString(DOMHelper::fromUTF8("Name"), memberElem->getLocalName()) == 0) { def.members.resize(def.members.size() + 1); xmlAdapter(DOMHelper::toUTF8(memberElem->getTextContent()), def.members.back().name); - } else if (XMLString::compareIString(DOMHelper::fromUTF8("Type"), memberElem->getLocalName()) == 0) { + } else if (xercesc::XMLString::compareIString(DOMHelper::fromUTF8("Type"), memberElem->getLocalName()) == 0) { xmlAdapter(DOMHelper::toUTF8(memberElem->getTextContent()), def.members.back().type); @@ -292,13 +288,13 @@ namespace rxml { } - void _readWeakReferenceTypeDefinition(DOMElement *element, WeakReferenceTypeDefinition &def) { + void _readWeakReferenceTypeDefinition(xercesc::DOMElement *element, WeakReferenceTypeDefinition &def) { _readDefinition(element, def); _readPropertyOfElement(element, XML_NS.c_str(), "ReferencedType", def.referencedType); - DOMElement *tsetelem = DOMHelper::getElementByTagNameNS( + xercesc::DOMElement *tsetelem = DOMHelper::getElementByTagNameNS( element, DOMHelper::fromUTF8(XML_NS), DOMHelper::fromUTF8("TargetSet") @@ -313,7 +309,7 @@ namespace rxml { /* check if there is any text content */ /* xerces fails on transcoding zero-length streams in some versions */ - if (XMLString::stringLen(tsetelem->getTextContent()) != 0) { + if (xercesc::XMLString::stringLen(tsetelem->getTextContent()) != 0) { std::istringstream ss(DOMHelper::toUTF8(tsetelem->getTextContent()).c_str()); @@ -327,7 +323,7 @@ namespace rxml { } - void _readEnumerationTypeDefinition(DOMElement *element, EnumerationTypeDefinition &def) { + void _readEnumerationTypeDefinition(xercesc::DOMElement *element, EnumerationTypeDefinition &def) { _readDefinition(element, def); @@ -336,7 +332,7 @@ namespace rxml { /* read Elements */ - DOMElement *elementsElem = DOMHelper::getElementByTagNameNS( + xercesc::DOMElement *elementsElem = DOMHelper::getElementByTagNameNS( element, DOMHelper::fromUTF8(XML_NS), DOMHelper::fromUTF8("Elements") @@ -344,27 +340,27 @@ namespace rxml { if (!elementsElem) { - throw new XMLImporter::Exception("Elements property missing"); + throw XMLImporter::Exception("Elements property missing"); } - DOMElement *elementElem = elementsElem->getFirstElementChild(); + xercesc::DOMElement *elementElem = elementsElem->getFirstElementChild(); while (elementElem) { - if (XMLString::compareIString(DOMHelper::fromUTF8("Name"), elementElem->getLocalName()) == 0) { + if (xercesc::XMLString::compareIString(DOMHelper::fromUTF8("Name"), elementElem->getLocalName()) == 0) { def.elements.resize(def.elements.size() + 1); xmlAdapter(DOMHelper::toUTF8(elementElem->getTextContent()), def.elements.back().name); - } else if (XMLString::compareIString(DOMHelper::fromUTF8("Value"), elementElem->getLocalName()) == 0) { + } else if (xercesc::XMLString::compareIString(DOMHelper::fromUTF8("Value"), elementElem->getLocalName()) == 0) { xmlAdapter(DOMHelper::toUTF8(elementElem->getTextContent()), def.elements.back().value); - } else if (XMLString::compareIString(DOMHelper::fromUTF8("Description"), elementElem->getLocalName()) == 0) { + } else if (xercesc::XMLString::compareIString(DOMHelper::fromUTF8("Description"), elementElem->getLocalName()) == 0) { xmlAdapter(DOMHelper::toUTF8(elementElem->getTextContent()), def.elements.back().description); @@ -377,9 +373,9 @@ namespace rxml { } - void XMLImporter::fromDOM(DOMDocument & dom, MetaDictionary &md, EventHandler * ev) + void XMLImporter::fromDOM(xercesc::DOMDocument & dom, MetaDictionary &md, EventHandler * ev) { - DOMElement *root = dom.getDocumentElement(); + xercesc::DOMElement *root = dom.getDocumentElement(); if (NAME != DOMHelper::toUTF8(root->getLocalName()).c_str() || XML_NS != DOMHelper::toUTF8(root->getNamespaceURI()).c_str()) { @@ -388,7 +384,7 @@ namespace rxml { /* read SchemeID */ - DOMElement *schemeIDElement = DOMHelper::getElementByTagNameNS(root, + xercesc::DOMElement *schemeIDElement = DOMHelper::getElementByTagNameNS(root, DOMHelper::fromUTF8(XML_NS), DOMHelper::fromUTF8("SchemeID") ); @@ -399,13 +395,13 @@ namespace rxml { return; } - AUID schemeID = TranscodeToStr(schemeIDElement->getTextContent(), "utf-8").str(); + AUID schemeID = xercesc::TranscodeToStr(schemeIDElement->getTextContent(), "utf-8").str(); md.setSchemeID(schemeID); /* read SchemeURI */ - DOMElement *schemeURIElement = DOMHelper::getElementByTagNameNS( + xercesc::DOMElement *schemeURIElement = DOMHelper::getElementByTagNameNS( root, DOMHelper::fromUTF8(XML_NS), DOMHelper::fromUTF8("SchemeURI") @@ -423,7 +419,7 @@ namespace rxml { /* read and index definitions */ - DOMElement *definitions = DOMHelper::getElementByTagNameNS( + xercesc::DOMElement *definitions = DOMHelper::getElementByTagNameNS( root, DOMHelper::fromUTF8(XML_NS), DOMHelper::fromUTF8("MetaDefinitions") @@ -435,7 +431,7 @@ namespace rxml { return; } - DOMElement *curelement = definitions->getFirstElementChild(); + xercesc::DOMElement *curelement = definitions->getFirstElementChild(); while (curelement) { diff --git a/regxmllib/src/main/cpp/com/sandflow/smpte/regxml/dict/importers/XMLImporter.h b/src/main/cpp/com/sandflow/smpte/regxml/dict/importers/XMLImporter.h similarity index 93% rename from regxmllib/src/main/cpp/com/sandflow/smpte/regxml/dict/importers/XMLImporter.h rename to src/main/cpp/com/sandflow/smpte/regxml/dict/importers/XMLImporter.h index c66b118..7ee1a50 100644 --- a/regxmllib/src/main/cpp/com/sandflow/smpte/regxml/dict/importers/XMLImporter.h +++ b/src/main/cpp/com/sandflow/smpte/regxml/dict/importers/XMLImporter.h @@ -32,8 +32,6 @@ #include #include -XERCES_CPP_NAMESPACE_USE - namespace rxml { class XMLImporter { @@ -47,7 +45,7 @@ namespace rxml { Exception(const char* reason) : std::runtime_error(reason) {} }; - static void fromDOM(DOMDocument &dom, MetaDictionary& md, EventHandler *ev = &NULL_EVENTHANDLER); + static void fromDOM(xercesc::DOMDocument &dom, MetaDictionary& md, EventHandler *ev = &NULL_EVENTHANDLER); }; diff --git a/regxmllib/src/main/cpp/com/sandflow/smpte/util/AUID.cpp b/src/main/cpp/com/sandflow/smpte/util/AUID.cpp similarity index 96% rename from regxmllib/src/main/cpp/com/sandflow/smpte/util/AUID.cpp rename to src/main/cpp/com/sandflow/smpte/util/AUID.cpp index b8ea7fb..107d961 100644 --- a/regxmllib/src/main/cpp/com/sandflow/smpte/util/AUID.cpp +++ b/src/main/cpp/com/sandflow/smpte/util/AUID.cpp @@ -98,7 +98,7 @@ namespace rxml { UL AUID::asUL() const { if (!isUL()) { - throw new std::invalid_argument("AUID is not a UL"); + throw std::invalid_argument("AUID is not a UL"); } return UL(this->value); @@ -107,7 +107,7 @@ namespace rxml { UUID AUID::asUUID() const { if (!isUUID()) { - throw new std::invalid_argument("AUID is not a UUID"); + throw std::invalid_argument("AUID is not a UUID"); } unsigned char tmp[16]; diff --git a/regxmllib/src/main/cpp/com/sandflow/smpte/util/AUID.h b/src/main/cpp/com/sandflow/smpte/util/AUID.h similarity index 100% rename from regxmllib/src/main/cpp/com/sandflow/smpte/util/AUID.h rename to src/main/cpp/com/sandflow/smpte/util/AUID.h diff --git a/regxmllib/src/main/cpp/com/sandflow/smpte/util/IDAU.cpp b/src/main/cpp/com/sandflow/smpte/util/IDAU.cpp similarity index 100% rename from regxmllib/src/main/cpp/com/sandflow/smpte/util/IDAU.cpp rename to src/main/cpp/com/sandflow/smpte/util/IDAU.cpp diff --git a/regxmllib/src/main/cpp/com/sandflow/smpte/util/IDAU.h b/src/main/cpp/com/sandflow/smpte/util/IDAU.h similarity index 100% rename from regxmllib/src/main/cpp/com/sandflow/smpte/util/IDAU.h rename to src/main/cpp/com/sandflow/smpte/util/IDAU.h diff --git a/regxmllib/src/main/cpp/com/sandflow/smpte/util/UL.cpp b/src/main/cpp/com/sandflow/smpte/util/UL.cpp similarity index 100% rename from regxmllib/src/main/cpp/com/sandflow/smpte/util/UL.cpp rename to src/main/cpp/com/sandflow/smpte/util/UL.cpp diff --git a/regxmllib/src/main/cpp/com/sandflow/smpte/util/UL.h b/src/main/cpp/com/sandflow/smpte/util/UL.h similarity index 100% rename from regxmllib/src/main/cpp/com/sandflow/smpte/util/UL.h rename to src/main/cpp/com/sandflow/smpte/util/UL.h diff --git a/regxmllib/src/main/cpp/com/sandflow/smpte/util/UMID.cpp b/src/main/cpp/com/sandflow/smpte/util/UMID.cpp similarity index 100% rename from regxmllib/src/main/cpp/com/sandflow/smpte/util/UMID.cpp rename to src/main/cpp/com/sandflow/smpte/util/UMID.cpp diff --git a/regxmllib/src/main/cpp/com/sandflow/smpte/util/UMID.h b/src/main/cpp/com/sandflow/smpte/util/UMID.h similarity index 100% rename from regxmllib/src/main/cpp/com/sandflow/smpte/util/UMID.h rename to src/main/cpp/com/sandflow/smpte/util/UMID.h diff --git a/regxmllib/src/main/cpp/com/sandflow/smpte/util/UUID.cpp b/src/main/cpp/com/sandflow/smpte/util/UUID.cpp similarity index 100% rename from regxmllib/src/main/cpp/com/sandflow/smpte/util/UUID.cpp rename to src/main/cpp/com/sandflow/smpte/util/UUID.cpp diff --git a/regxmllib/src/main/cpp/com/sandflow/smpte/util/UUID.h b/src/main/cpp/com/sandflow/smpte/util/UUID.h similarity index 100% rename from regxmllib/src/main/cpp/com/sandflow/smpte/util/UUID.h rename to src/main/cpp/com/sandflow/smpte/util/UUID.h diff --git a/regxmllib/src/main/cpp/com/sandflow/util/CountingStreamBuf.h b/src/main/cpp/com/sandflow/util/CountingStreamBuf.h similarity index 100% rename from regxmllib/src/main/cpp/com/sandflow/util/CountingStreamBuf.h rename to src/main/cpp/com/sandflow/util/CountingStreamBuf.h diff --git a/regxmllib/src/main/cpp/com/sandflow/util/DOMHelper.cpp b/src/main/cpp/com/sandflow/util/DOMHelper.cpp similarity index 69% rename from regxmllib/src/main/cpp/com/sandflow/util/DOMHelper.cpp rename to src/main/cpp/com/sandflow/util/DOMHelper.cpp index 47e3451..2e9a871 100644 --- a/regxmllib/src/main/cpp/com/sandflow/util/DOMHelper.cpp +++ b/src/main/cpp/com/sandflow/util/DOMHelper.cpp @@ -29,17 +29,17 @@ namespace rxml { - DOMElement * DOMHelper::getElementByTagNameNS(DOMElement * parent, const XMLCh * namespaceURI, const XMLCh * localName) { + xercesc::DOMElement * DOMHelper::getElementByTagNameNS(xercesc::DOMElement * parent, const XMLCh * namespaceURI, const XMLCh * localName) { - DOMNode *child = parent->getFirstElementChild(); + xercesc::DOMNode *child = parent->getFirstElementChild(); while (child) { - if (child->getNodeType() == DOMNode::ELEMENT_NODE && - XMLString::compareIString(child->getNodeName(), localName) == 0 && - XMLString::compareIString(child->getNamespaceURI(), namespaceURI) == 0) { + if (child->getNodeType() == xercesc::DOMNode::ELEMENT_NODE && + xercesc::XMLString::compareIString(child->getNodeName(), localName) == 0 && + xercesc::XMLString::compareIString(child->getNamespaceURI(), namespaceURI) == 0) { - return (DOMElement*)child; + return (xercesc::DOMElement*)child; } @@ -50,8 +50,8 @@ namespace rxml { return NULL; } - const XMLCh * DOMHelper::getElementTextContentByTagNameNS(DOMElement * parent, const XMLCh * namespaceURI, const XMLCh * localName) { - DOMElement* e = getElementByTagNameNS(parent, namespaceURI, localName); + const XMLCh * DOMHelper::getElementTextContentByTagNameNS(xercesc::DOMElement * parent, const XMLCh * namespaceURI, const XMLCh * localName) { + xercesc::DOMElement* e = getElementByTagNameNS(parent, namespaceURI, localName); if (e) { diff --git a/regxmllib/src/main/cpp/com/sandflow/util/DOMHelper.h b/src/main/cpp/com/sandflow/util/DOMHelper.h similarity index 73% rename from regxmllib/src/main/cpp/com/sandflow/util/DOMHelper.h rename to src/main/cpp/com/sandflow/util/DOMHelper.h index bcaecae..3e2f8f1 100644 --- a/regxmllib/src/main/cpp/com/sandflow/util/DOMHelper.h +++ b/src/main/cpp/com/sandflow/util/DOMHelper.h @@ -31,17 +31,15 @@ #include #include -XERCES_CPP_NAMESPACE_USE - namespace rxml { namespace DOMHelper { - class XMLChStr : public TranscodeFromStr { + class XMLChStr : public xercesc::TranscodeFromStr { public: - XMLChStr(const char *str) : TranscodeFromStr((XMLByte*)str, strlen(str), "utf-8"), src(str) {} + XMLChStr(const char *str) : xercesc::TranscodeFromStr((XMLByte*)str, strlen(str), "utf-8"), src(str) {} const std::string& ostr() const { return this->src; } @@ -53,12 +51,12 @@ namespace rxml { }; - class fromUTF8 : public TranscodeFromStr { + class fromUTF8 : public xercesc::TranscodeFromStr { public: - fromUTF8(const char *str) : TranscodeFromStr((XMLByte*)str, strlen(str), "utf-8"), src(str) {} - fromUTF8(const std::string &str) : TranscodeFromStr((XMLByte*)str.c_str(), str.size(), "utf-8"), src(str) {} + fromUTF8(const char *str) : xercesc::TranscodeFromStr((XMLByte*)str, strlen(str), "utf-8"), src(str) {} + fromUTF8(const std::string &str) : xercesc::TranscodeFromStr((XMLByte*)str.c_str(), str.size(), "utf-8"), src(str) {} const std::string& ostr() const { return this->src; } @@ -72,11 +70,11 @@ namespace rxml { }; - class toUTF8 : public TranscodeToStr { + class toUTF8 : public xercesc::TranscodeToStr { public: - toUTF8(const XMLCh *str) : TranscodeToStr(str, "utf-8"), src(str) {} + toUTF8(const XMLCh *str) : xercesc::TranscodeToStr(str, "utf-8"), src(str) {} const XMLCh* ostr() const { return this->src; } @@ -91,10 +89,10 @@ namespace rxml { }; - DOMElement* getElementByTagNameNS(DOMElement *parent, const XMLCh *namespaceURI, const XMLCh *localName); + xercesc::DOMElement* getElementByTagNameNS(xercesc::DOMElement *parent, const XMLCh *namespaceURI, const XMLCh *localName); - const XMLCh* getElementTextContentByTagNameNS(DOMElement *parent, const XMLCh *namespaceURI, const XMLCh *localName); + const XMLCh* getElementTextContentByTagNameNS(xercesc::DOMElement *parent, const XMLCh *namespaceURI, const XMLCh *localName); } diff --git a/regxmllib/src/main/cpp/com/sandflow/util/events/Event.h b/src/main/cpp/com/sandflow/util/events/Event.h similarity index 99% rename from regxmllib/src/main/cpp/com/sandflow/util/events/Event.h rename to src/main/cpp/com/sandflow/util/events/Event.h index 7613d3f..b9c4ed6 100644 --- a/regxmllib/src/main/cpp/com/sandflow/util/events/Event.h +++ b/src/main/cpp/com/sandflow/util/events/Event.h @@ -34,8 +34,8 @@ namespace rxml { class Event : public std::runtime_error { const std::string reason; - const std::string code; const std::string where; + const std::string code; public: Event(const std::string & code, const std::string & reason, const std::string & where) : @@ -63,4 +63,4 @@ namespace rxml { } -#endif \ No newline at end of file +#endif diff --git a/regxmllib/src/main/cpp/com/sandflow/util/events/EventHandler.h b/src/main/cpp/com/sandflow/util/events/EventHandler.h similarity index 100% rename from regxmllib/src/main/cpp/com/sandflow/util/events/EventHandler.h rename to src/main/cpp/com/sandflow/util/events/EventHandler.h diff --git a/regxmllib/src/main/cpp/com/sandflow/util/events/NullEventHandler.cpp b/src/main/cpp/com/sandflow/util/events/NullEventHandler.cpp similarity index 100% rename from regxmllib/src/main/cpp/com/sandflow/util/events/NullEventHandler.cpp rename to src/main/cpp/com/sandflow/util/events/NullEventHandler.cpp diff --git a/regxmllib/src/main/cpp/com/sandflow/util/events/NullEventHandler.h b/src/main/cpp/com/sandflow/util/events/NullEventHandler.h similarity index 100% rename from regxmllib/src/main/cpp/com/sandflow/util/events/NullEventHandler.h rename to src/main/cpp/com/sandflow/util/events/NullEventHandler.h diff --git a/regxmllib/src/main/cpp/com/sandflow/util/membuf.h b/src/main/cpp/com/sandflow/util/membuf.h similarity index 100% rename from regxmllib/src/main/cpp/com/sandflow/util/membuf.h rename to src/main/cpp/com/sandflow/util/membuf.h diff --git a/regxmllib/src/main/cpp/com/sandflow/util/optional.h b/src/main/cpp/com/sandflow/util/optional.h similarity index 100% rename from regxmllib/src/main/cpp/com/sandflow/util/optional.h rename to src/main/cpp/com/sandflow/util/optional.h diff --git a/regxmllib/src/main/cpp/com/sandflow/util/scoped_ptr.h b/src/main/cpp/com/sandflow/util/scoped_ptr.h similarity index 100% rename from regxmllib/src/main/cpp/com/sandflow/util/scoped_ptr.h rename to src/main/cpp/com/sandflow/util/scoped_ptr.h diff --git a/regxmllib/src/main/cpp/com/sandflow/util/strformat.cpp b/src/main/cpp/com/sandflow/util/strformat.cpp similarity index 100% rename from regxmllib/src/main/cpp/com/sandflow/util/strformat.cpp rename to src/main/cpp/com/sandflow/util/strformat.cpp diff --git a/regxmllib/src/main/cpp/com/sandflow/util/strformat.h b/src/main/cpp/com/sandflow/util/strformat.h similarity index 100% rename from regxmllib/src/main/cpp/com/sandflow/util/strformat.h rename to src/main/cpp/com/sandflow/util/strformat.h diff --git a/regxmllib/src/main/java/com/sandflow/smpte/klv/Group.java b/src/main/java/com/sandflow/smpte/klv/Group.java similarity index 100% rename from regxmllib/src/main/java/com/sandflow/smpte/klv/Group.java rename to src/main/java/com/sandflow/smpte/klv/Group.java diff --git a/regxmllib/src/main/java/com/sandflow/smpte/klv/KLVInputStream.java b/src/main/java/com/sandflow/smpte/klv/KLVInputStream.java similarity index 93% rename from regxmllib/src/main/java/com/sandflow/smpte/klv/KLVInputStream.java rename to src/main/java/com/sandflow/smpte/klv/KLVInputStream.java index 37b4b1c..0c3f1e2 100644 --- a/regxmllib/src/main/java/com/sandflow/smpte/klv/KLVInputStream.java +++ b/src/main/java/com/sandflow/smpte/klv/KLVInputStream.java @@ -1,392 +1,402 @@ -/* - * Copyright (c) 2014, Pierre-Anthony Lemieux (pal@sandflow.com) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package com.sandflow.smpte.klv; - -import com.sandflow.smpte.klv.exceptions.KLVException; -import static com.sandflow.smpte.klv.exceptions.KLVException.MAX_LENGTH_EXCEEED; -import com.sandflow.smpte.util.UL; -import java.io.DataInput; -import java.io.DataInputStream; -import java.io.EOFException; -import java.io.FilterInputStream; -import java.io.IOException; -import java.io.InputStream; - -/** - * KLVInputStream allows KLV data structures to be read from an InputStream - */ -public class KLVInputStream extends InputStream implements DataInput { - - /** - * Possible byte ordering of a KLV packet - */ - public enum ByteOrder { - LITTLE_ENDIAN, - BIG_ENDIAN - } - - private DataInputStream dis; - private ByteOrder byteorder; - - /** - * Assumes big endian byte ordering. - * - * @param is InputStream to read from - */ - public KLVInputStream(InputStream is) { - this(is, ByteOrder.BIG_ENDIAN); - } - - /** - * Allows the byte ordering to be specified. - * - * @param is InputStream to read from - * @param byteorder Byte ordering of the file - */ - public KLVInputStream(InputStream is, ByteOrder byteorder) { - - if (is == null) throw new NullPointerException(); - - dis = new DataInputStream(is); - this.byteorder = byteorder; - } - - /** - * Byte order of the stream. - * - * @return Byte order of the stream - */ - public ByteOrder getByteorder() { - return byteorder; - } - - /** - * Reads a single UL. - * - * @return UL - * @throws IOException - * @throws EOFException - */ - public UL readUL() throws IOException, EOFException { - byte[] ul = new byte[16]; - - readFully(ul); - - return new UL(ul); - } - - /** - * Reads a single BER-encoded length. The maximum length of the encoded length is 8 bytes. - * - * @return Length - * @throws EOFException - * @throws IOException - * @throws KLVException - */ - public long readBERLength() throws EOFException, IOException, KLVException { - - long val = 0; - - int b = read(); - - if (b <= 0) { - throw new EOFException(); - } - - if ((b & 0x80) == 0) { - return b; - } - - int bersz = (b & 0x0f); - - if (bersz > 8) { - throw new KLVException(MAX_LENGTH_EXCEEED); - } - - byte[] octets = new byte[bersz]; - - if (read(octets) < bersz) { - throw new EOFException(); - } - - for (int i = 0; i < bersz; i++) { - int tmp = (((int) octets[i]) & 0xFF); - val = (val << 8) + tmp; - - if (val > Integer.MAX_VALUE) { - throw new KLVException(MAX_LENGTH_EXCEEED); - } - } - - return val; - } - - /** - * Reads a single KLV triplet. - * - * @return KLV Triplet - * @throws IOException - * @throws EOFException - * @throws KLVException - */ - public Triplet readTriplet() throws IOException, EOFException, KLVException { - UL ul = readUL(); - - long len = readBERLength(); - - if (len > Integer.MAX_VALUE) { - throw new KLVException(MAX_LENGTH_EXCEEED); - } - - byte[] value = new byte[(int) len]; - - if (len != read(value)) { - throw new EOFException("EOF reached while reading Value."); - } - - return new MemoryTriplet(ul, value); - } - - @Override - public final int read(byte[] bytes) throws IOException { - return dis.read(bytes); - } - - @Override - public final int read(byte[] bytes, int i, int i1) throws IOException { - return dis.read(bytes, i, i1); - } - - @Override - public final void readFully(byte[] bytes) throws IOException { - dis.readFully(bytes); - } - - @Override - public final void readFully(byte[] bytes, int i, int i1) throws IOException { - dis.readFully(bytes, i, i1); - } - - @Override - public final int skipBytes(int i) throws IOException { - return dis.skipBytes(i); - } - - @Override - public final boolean readBoolean() throws IOException { - return dis.readBoolean(); - } - - @Override - public final byte readByte() throws IOException { - return dis.readByte(); - } - - @Override - public final int readUnsignedByte() throws IOException { - return dis.readUnsignedByte(); - } - - @Override - public final short readShort() throws IOException { - - if (byteorder == ByteOrder.BIG_ENDIAN) { - - return dis.readShort(); - - } else { - - int lo = readUnsignedByte(); - int hi = readUnsignedByte(); - - return (short) (lo + (hi << 8)); - - } - } - - @Override - public final int readUnsignedShort() throws IOException { - - if (byteorder == ByteOrder.BIG_ENDIAN) { - - return dis.readUnsignedShort(); - - } else { - - int lo = readUnsignedByte(); - int hi = readUnsignedByte(); - - return lo + hi << 8; - - } - } - - @Override - public final char readChar() throws IOException { - return dis.readChar(); - } - - @Override - public final int readInt() throws IOException { - - if (byteorder == ByteOrder.BIG_ENDIAN) { - - return dis.readInt(); - - } else { - - int b0 = readUnsignedByte(); - int b1 = readUnsignedByte(); - int b2 = readUnsignedByte(); - int b3 = readUnsignedByte(); - - return b0 + (b1 << 8) + (b2 << 16) + (b3 << 24); - - } - - } - - public long readUnsignedInt() throws IOException, EOFException { - - if (byteorder == ByteOrder.BIG_ENDIAN) { - - return ((long) dis.readInt()) & 0xFFFF; - - } else { - - int b0 = readUnsignedByte(); - int b1 = readUnsignedByte(); - int b2 = readUnsignedByte(); - int b3 = readUnsignedByte(); - - return ((long) b0 + (b1 << 8) + (b2 << 16) + (b3 << 24)) & 0xFFFF; - - } - - } - - @Override - public final long readLong() throws IOException { - - if (byteorder == ByteOrder.BIG_ENDIAN) { - - return dis.readLong(); - - } else { - - int b0 = readUnsignedByte(); - int b1 = readUnsignedByte(); - int b2 = readUnsignedByte(); - int b3 = readUnsignedByte(); - int b4 = readUnsignedByte(); - int b5 = readUnsignedByte(); - int b6 = readUnsignedByte(); - int b7 = readUnsignedByte(); - - return b0 + (b1 << 8) + (b2 << 16) + (b3 << 24) + (b4 << 32) + (b5 << 40) + (b6 << 48) + (b7 << 56); - - } - } - - @Override - public final float readFloat() throws IOException { - return dis.readFloat(); - } - - @Override - public final double readDouble() throws IOException { - return dis.readDouble(); - } - - @Override - public final String readLine() throws IOException { - return dis.readLine(); - } - - @Override - public final String readUTF() throws IOException { - return dis.readUTF(); - } - - public static final String readUTF(DataInput di) throws IOException { - return DataInputStream.readUTF(di); - } - - @Override - public int read() throws IOException { - return dis.read(); - } - - @Override - public long skip(long l) throws IOException { - return dis.skip(l); - } - - @Override - public int available() throws IOException { - return dis.available(); - } - - @Override - public void close() throws IOException { - dis.close(); - } - - @Override - public synchronized void mark(int i) { - dis.mark(i); - } - - @Override - public synchronized void reset() throws IOException { - dis.reset(); - } - - @Override - public boolean markSupported() { - return dis.markSupported(); - } - - protected static final void swap(byte[] array, int i, int j) { - byte tmp = array[i]; - array[i] = array[j]; - array[j] = tmp; - } - - protected static final void uuidLEtoBE(byte[] uuid) { - /* swap the 32-bit word of the UUID */ - swap(uuid, 0, 3); - swap(uuid, 1, 2); - - /* swap the first 16-bit word of the UUID */ - swap(uuid, 4, 5); - - /* swap the second 16-bit word of the UUID */ - swap(uuid, 6, 7); - - } - -} +/* + * Copyright (c) 2014, Pierre-Anthony Lemieux (pal@sandflow.com) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +package com.sandflow.smpte.klv; + +import com.sandflow.smpte.klv.exceptions.KLVException; +import static com.sandflow.smpte.klv.exceptions.KLVException.MAX_LENGTH_EXCEEED; +import com.sandflow.smpte.util.AUID; +import com.sandflow.smpte.util.UL; +import java.io.DataInput; +import java.io.DataInputStream; +import java.io.EOFException; +import java.io.IOException; +import java.io.InputStream; + +/** + * KLVInputStream allows KLV data structures to be read from an InputStream + */ +public class KLVInputStream extends InputStream implements DataInput { + + /** + * Possible byte ordering of a KLV packet + */ + public enum ByteOrder { + LITTLE_ENDIAN, + BIG_ENDIAN + } + + private DataInputStream dis; + private ByteOrder byteorder; + + /** + * Assumes big endian byte ordering. + * + * @param is InputStream to read from + */ + public KLVInputStream(InputStream is) { + this(is, ByteOrder.BIG_ENDIAN); + } + + /** + * Allows the byte ordering to be specified. + * + * @param is InputStream to read from + * @param byteorder Byte ordering of the file + */ + public KLVInputStream(InputStream is, ByteOrder byteorder) { + + if (is == null) throw new NullPointerException(); + + dis = new DataInputStream(is); + this.byteorder = byteorder; + } + + /** + * Byte order of the stream. + * + * @return Byte order of the stream + */ + public ByteOrder getByteOrder() { + return byteorder; + } + + /** + * Reads a single UL. + * + * @return UL + * @throws IOException + * @throws EOFException + */ + public UL readUL() throws IOException, EOFException { + byte[] ul = new byte[16]; + + readFully(ul); + + return new UL(ul); + } + + /** + * Reads a single AUID. + * @return AUID + * @throws IOException + * @throws EOFException + */ + public AUID readAUID() throws IOException, EOFException { + byte[] auid = new byte[16]; + + readFully(auid); + + return new AUID(auid); + } + + /** + * Reads a single BER-encoded length. The maximum length of the encoded length is 8 bytes. + * + * @return Length + * @throws EOFException + * @throws IOException + * @throws KLVException + */ + public long readBERLength() throws EOFException, IOException, KLVException { + + long val = 0; + + int b = read(); + + if (b <= 0) { + throw new EOFException(); + } + + if ((b & 0x80) == 0) { + return b; + } + + int bersz = (b & 0x0f); + + if (bersz > 8) { + throw new KLVException(MAX_LENGTH_EXCEEED); + } + + byte[] octets = new byte[bersz]; + + readFully(octets); + + for (int i = 0; i < bersz; i++) { + int tmp = (((int) octets[i]) & 0xFF); + val = (val << 8) + tmp; + + if (val > Integer.MAX_VALUE) { + throw new KLVException(MAX_LENGTH_EXCEEED); + } + } + + return val; + } + + /** + * Reads a single KLV triplet. + * + * @return KLV Triplet + * @throws IOException + * @throws EOFException + * @throws KLVException + */ + public Triplet readTriplet() throws IOException, EOFException, KLVException { + AUID auid = readAUID(); + + long len = readBERLength(); + + if (len > Integer.MAX_VALUE) { + throw new KLVException(MAX_LENGTH_EXCEEED); + } + + byte[] value = new byte[(int) len]; + + readFully(value); + + return new MemoryTriplet(auid, value); + } + + @Override + public final int read(byte[] bytes) throws IOException { + return dis.read(bytes); + } + + @Override + public final int read(byte[] bytes, int i, int i1) throws IOException { + return dis.read(bytes, i, i1); + } + + @Override + public final void readFully(byte[] bytes) throws IOException { + dis.readFully(bytes); + } + + @Override + public final void readFully(byte[] bytes, int i, int i1) throws IOException { + dis.readFully(bytes, i, i1); + } + + @Override + public final int skipBytes(int i) throws IOException { + return dis.skipBytes(i); + } + + @Override + public final boolean readBoolean() throws IOException { + return dis.readBoolean(); + } + + @Override + public final byte readByte() throws IOException { + return dis.readByte(); + } + + @Override + public final int readUnsignedByte() throws IOException { + return dis.readUnsignedByte(); + } + + @Override + public final short readShort() throws IOException { + + if (byteorder == ByteOrder.BIG_ENDIAN) { + + return dis.readShort(); + + } else { + + int lo = readUnsignedByte(); + int hi = readUnsignedByte(); + + return (short) (lo + (hi << 8)); + + } + } + + @Override + public final int readUnsignedShort() throws IOException { + + if (byteorder == ByteOrder.BIG_ENDIAN) { + + return dis.readUnsignedShort(); + + } else { + + int lo = readUnsignedByte(); + int hi = readUnsignedByte(); + + return lo + hi << 8; + + } + } + + @Override + public final char readChar() throws IOException { + return dis.readChar(); + } + + @Override + public final int readInt() throws IOException { + + if (byteorder == ByteOrder.BIG_ENDIAN) { + + return dis.readInt(); + + } else { + + int b0 = readUnsignedByte(); + int b1 = readUnsignedByte(); + int b2 = readUnsignedByte(); + int b3 = readUnsignedByte(); + + return b0 + (b1 << 8) + (b2 << 16) + (b3 << 24); + + } + + } + + public long readUnsignedInt() throws IOException, EOFException { + + if (byteorder == ByteOrder.BIG_ENDIAN) { + + return ((long) dis.readInt()) & 0xFFFF; + + } else { + + int b0 = readUnsignedByte(); + int b1 = readUnsignedByte(); + int b2 = readUnsignedByte(); + int b3 = readUnsignedByte(); + + return ((long) b0 + (b1 << 8) + (b2 << 16) + (b3 << 24)) & 0xFFFF; + + } + + } + + @Override + public final long readLong() throws IOException { + + if (byteorder == ByteOrder.BIG_ENDIAN) { + + return dis.readLong(); + + } else { + + int b0 = readUnsignedByte(); + int b1 = readUnsignedByte(); + int b2 = readUnsignedByte(); + int b3 = readUnsignedByte(); + int b4 = readUnsignedByte(); + int b5 = readUnsignedByte(); + int b6 = readUnsignedByte(); + int b7 = readUnsignedByte(); + + return b0 + (b1 << 8) + (b2 << 16) + (b3 << 24) + (b4 << 32) + (b5 << 40) + (b6 << 48) + (b7 << 56); + + } + } + + @Override + public final float readFloat() throws IOException { + return dis.readFloat(); + } + + @Override + public final double readDouble() throws IOException { + return dis.readDouble(); + } + + @Override + public final String readLine() throws IOException { + return dis.readLine(); + } + + @Override + public final String readUTF() throws IOException { + return dis.readUTF(); + } + + public static final String readUTF(DataInput di) throws IOException { + return DataInputStream.readUTF(di); + } + + @Override + public int read() throws IOException { + return dis.read(); + } + + @Override + public long skip(long l) throws IOException { + return dis.skip(l); + } + + @Override + public int available() throws IOException { + return dis.available(); + } + + @Override + public void close() throws IOException { + dis.close(); + } + + @Override + public synchronized void mark(int i) { + dis.mark(i); + } + + @Override + public synchronized void reset() throws IOException { + dis.reset(); + } + + @Override + public boolean markSupported() { + return dis.markSupported(); + } + + protected static final void swap(byte[] array, int i, int j) { + byte tmp = array[i]; + array[i] = array[j]; + array[j] = tmp; + } + + protected static final void uuidLEtoBE(byte[] uuid) { + /* swap the 32-bit word of the UUID */ + swap(uuid, 0, 3); + swap(uuid, 1, 2); + + /* swap the first 16-bit word of the UUID */ + swap(uuid, 4, 5); + + /* swap the second 16-bit word of the UUID */ + swap(uuid, 6, 7); + + } + +} diff --git a/regxmllib/src/main/java/com/sandflow/smpte/klv/LocalSet.java b/src/main/java/com/sandflow/smpte/klv/LocalSet.java similarity index 92% rename from regxmllib/src/main/java/com/sandflow/smpte/klv/LocalSet.java rename to src/main/java/com/sandflow/smpte/klv/LocalSet.java index 71ec64a..9a973a6 100644 --- a/regxmllib/src/main/java/com/sandflow/smpte/klv/LocalSet.java +++ b/src/main/java/com/sandflow/smpte/klv/LocalSet.java @@ -1,161 +1,163 @@ -/* - * Copyright (c) 2014, Pierre-Anthony Lemieux (pal@sandflow.com) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package com.sandflow.smpte.klv; - -import com.sandflow.smpte.klv.exceptions.KLVException; -import com.sandflow.smpte.klv.exceptions.TripletLengthException; -import com.sandflow.smpte.util.CountingInputStream; -import com.sandflow.smpte.util.UL; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collection; - -/** - * LocalSet implements a Local Set as specified in SMPTE ST 336. - */ -public class LocalSet implements Group { - - /** - * Creates a Group from a Local Set using a LocalTagRegister to map Local Tags to Keys - * @param localset Triplet containing a Group encoded as a Local Set - * @param reg LocalTagRegister used to map Local Tags to Keys - * @return Local Set, or null if the input Triplet is not a Local Set - * @throws KLVException - */ - public static LocalSet fromTriplet(Triplet localset, LocalTagRegister reg) throws KLVException { - try { - - if (!localset.getKey().isLocalSet()) { - return null; - } - - CountingInputStream cis = new CountingInputStream(localset.getValueAsStream()); - - KLVInputStream kis = new KLVInputStream(cis); - - LocalSet set = new LocalSet(localset.getKey()); - - while(cis.getCount() < localset.getLength()) { - - long localtag = 0; - - /* read local tag */ - switch (localset.getKey().getRegistryDesignator() >> 3 & 3) { - - /* 1 byte length field */ - case 0: - localtag = kis.readUnsignedByte(); - break; - - /* ASN.1 OID BER length field */ - case 1: - localtag = kis.readBERLength(); - break; - - /* 2 byte length field */ - case 2: - localtag = kis.readUnsignedShort(); - break; - - /* 4 byte length field */ - case 3: - localtag = kis.readUnsignedInt(); - break; - } - - long locallen = 0; - - /* read local length */ - switch (localset.getKey().getRegistryDesignator() >> 5 & 3) { - - /* ASN.1 OID BER length field */ - case 0: - locallen = kis.readBERLength(); - break; - - /* 1 byte length field */ - case 1: - locallen = kis.readUnsignedByte(); - break; - - /* 2 byte length field */ - case 2: - locallen = kis.readUnsignedShort(); - break; - - /* 4 byte length field */ - case 3: - locallen = kis.readUnsignedInt(); - break; - } - - if (locallen > Integer.MAX_VALUE) { - throw new TripletLengthException(); - } - - byte[] localval = new byte[(int) locallen]; - - kis.readFully(localval); - - if (reg.get(localtag) == null) { - throw new KLVException("Local tag not found: " + localtag + " in Local Set " + localset.getKey()); - } - - set.addItem(new MemoryTriplet(reg.get(localtag), localval)); - - } - - return set; - - } catch (IOException e) { - throw new KLVException("Error parsing Local Set: " + localset.getKey(), e); - } - - } - - private final ArrayList items = new ArrayList<>(); - - private final UL key; - - private LocalSet(UL key) { - this.key = key; - } - - @Override - public UL getKey() { - return key; - } - - @Override - public Collection getItems() { - return items; - } - - private void addItem(Triplet triplet) { - items.add(triplet); - } - -} +/* + * Copyright (c) 2014, Pierre-Anthony Lemieux (pal@sandflow.com) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +package com.sandflow.smpte.klv; + +import com.sandflow.smpte.klv.exceptions.KLVException; +import com.sandflow.smpte.klv.exceptions.TripletLengthException; +import com.sandflow.smpte.util.CountingInputStream; +import com.sandflow.smpte.util.UL; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collection; + +/** + * LocalSet implements a Local Set as specified in SMPTE ST 336. + */ +public class LocalSet implements Group { + + /** + * Creates a Group from a Local Set using a LocalTagRegister to map Local Tags to Keys + * @param localset Triplet containing a Group encoded as a Local Set + * @param reg LocalTagRegister used to map Local Tags to Keys + * @return Local Set, or null if the input Triplet is not a Local Set + * @throws KLVException + */ + public static LocalSet fromTriplet(Triplet localset, LocalTagRegister reg) throws KLVException { + try { + + if (!(localset.getKey().isUL() && localset.getKey().asUL().isLocalSet())) { + return null; + } + + UL lskey = localset.getKey().asUL(); + + CountingInputStream cis = new CountingInputStream(localset.getValueAsStream()); + + KLVInputStream kis = new KLVInputStream(cis); + + LocalSet set = new LocalSet(lskey); + + while(cis.getCount() < localset.getLength()) { + + long localtag = 0; + + /* read local tag */ + switch (lskey.getRegistryDesignator() >> 3 & 3) { + + /* 1 byte length field */ + case 0: + localtag = kis.readUnsignedByte(); + break; + + /* ASN.1 OID BER length field */ + case 1: + localtag = kis.readBERLength(); + break; + + /* 2 byte length field */ + case 2: + localtag = kis.readUnsignedShort(); + break; + + /* 4 byte length field */ + case 3: + localtag = kis.readUnsignedInt(); + break; + } + + long locallen = 0; + + /* read local length */ + switch (lskey.getRegistryDesignator() >> 5 & 3) { + + /* ASN.1 OID BER length field */ + case 0: + locallen = kis.readBERLength(); + break; + + /* 1 byte length field */ + case 1: + locallen = kis.readUnsignedByte(); + break; + + /* 2 byte length field */ + case 2: + locallen = kis.readUnsignedShort(); + break; + + /* 4 byte length field */ + case 3: + locallen = kis.readUnsignedInt(); + break; + } + + if (locallen > Integer.MAX_VALUE) { + throw new TripletLengthException(); + } + + byte[] localval = new byte[(int) locallen]; + + kis.readFully(localval); + + if (reg.get(localtag) == null) { + throw new KLVException("Local tag not found: " + localtag + " in Local Set " + localset.getKey()); + } + + set.addItem(new MemoryTriplet(reg.get(localtag), localval)); + + } + + return set; + + } catch (IOException e) { + throw new KLVException("Error parsing Local Set: " + localset.getKey(), e); + } + + } + + private final ArrayList items = new ArrayList<>(); + + private final UL key; + + private LocalSet(UL key) { + this.key = key; + } + + @Override + public UL getKey() { + return key; + } + + @Override + public Collection getItems() { + return items; + } + + private void addItem(Triplet triplet) { + items.add(triplet); + } + +} diff --git a/regxmllib/src/main/java/com/sandflow/smpte/klv/LocalTagRegister.java b/src/main/java/com/sandflow/smpte/klv/LocalTagRegister.java similarity index 84% rename from regxmllib/src/main/java/com/sandflow/smpte/klv/LocalTagRegister.java rename to src/main/java/com/sandflow/smpte/klv/LocalTagRegister.java index 5539a67..42b567a 100644 --- a/regxmllib/src/main/java/com/sandflow/smpte/klv/LocalTagRegister.java +++ b/src/main/java/com/sandflow/smpte/klv/LocalTagRegister.java @@ -1,72 +1,72 @@ -/* - * Copyright (c) 2014, Pierre-Anthony Lemieux (pal@sandflow.com) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package com.sandflow.smpte.klv; - -import com.sandflow.smpte.util.UL; -import java.util.HashMap; -import java.util.Map; - -/** - * LocalTagRegister maps Local Tags found in a Local Set to UL Keys - */ -public class LocalTagRegister { - - private final HashMap entries = new HashMap<>(); - - /** - * Instantiates an empty LocalTagRegister - */ - public LocalTagRegister() { } - - /** - * Instantiates a LocalTagRegister with an initial set of mappings from Local Tag values to UL Keys - * @param entries Initial set of mappings - */ - public LocalTagRegister(Map entries) { - this.entries.putAll(entries); - } - - /** - * Returns the Key corresponding to a Local Tag - * @param localtag Local Tag - * @return Key, or null if no Key exists for the Local Tag - */ - public UL get(long localtag) { - return entries.get(localtag); - } - - /** - * Adds a Local Tag to the registry. - * @param localtag Local Tag - * @param key Key with which the Local Tag is associated - * @return The Key is the Local Tag was already present in the registry, or null otherwise. - */ - public UL add(long localtag, UL key) { - return entries.put(localtag, key); - } - - -} +/* + * Copyright (c) 2014, Pierre-Anthony Lemieux (pal@sandflow.com) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +package com.sandflow.smpte.klv; + +import com.sandflow.smpte.util.AUID; +import java.util.HashMap; +import java.util.Map; + +/** + * LocalTagRegister maps Local Tags found in a Local Set to AUID Keys + */ +public class LocalTagRegister { + + private final HashMap entries = new HashMap<>(); + + /** + * Instantiates an empty LocalTagRegister + */ + public LocalTagRegister() { } + + /** + * Instantiates a LocalTagRegister with an initial set of mappings from Local Tag values to AUID Keys + * @param entries Initial set of mappings + */ + public LocalTagRegister(Map entries) { + this.entries.putAll(entries); + } + + /** + * Returns the Key corresponding to a Local Tag + * @param localtag Local Tag + * @return Key, or null if no Key exists for the Local Tag + */ + public AUID get(long localtag) { + return entries.get(localtag); + } + + /** + * Adds a Local Tag to the registry. + * @param localtag Local Tag + * @param key Key with which the Local Tag is associated + * @return The Key is the Local Tag was already present in the registry, or null otherwise. + */ + public AUID add(long localtag, AUID key) { + return entries.put(localtag, key); + } + + +} diff --git a/regxmllib/src/main/java/com/sandflow/smpte/klv/MemoryTriplet.java b/src/main/java/com/sandflow/smpte/klv/MemoryTriplet.java similarity index 91% rename from regxmllib/src/main/java/com/sandflow/smpte/klv/MemoryTriplet.java rename to src/main/java/com/sandflow/smpte/klv/MemoryTriplet.java index ec0bb15..bc8a32d 100644 --- a/regxmllib/src/main/java/com/sandflow/smpte/klv/MemoryTriplet.java +++ b/src/main/java/com/sandflow/smpte/klv/MemoryTriplet.java @@ -1,74 +1,74 @@ -/* - * Copyright (c) 2014, Pierre-Anthony Lemieux (pal@sandflow.com) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package com.sandflow.smpte.klv; - -import com.sandflow.smpte.util.UL; -import java.io.ByteArrayInputStream; -import java.io.InputStream; -import java.security.InvalidParameterException; - -/** - * In-memory KLV Triplet - */ -public class MemoryTriplet implements Triplet { - - final private UL key; - final private byte[] value; - - /** - * Creates a Triplet from a Key and an array of bytes as the Value - * @param key Triplet Key - * @param value Triplet Value - */ - public MemoryTriplet(UL key, byte[] value) { - - if (key == null || value == null) throw new InvalidParameterException("Triplet muse have key and value."); - - this.key = key; - this.value = value; - } - - @Override - public UL getKey() { - return key; - } - - @Override - public long getLength() { - return value.length; - } - - @Override - public byte[] getValue() { - return value; - } - - @Override - public InputStream getValueAsStream() { - return new ByteArrayInputStream(value); - } - -} +/* + * Copyright (c) 2014, Pierre-Anthony Lemieux (pal@sandflow.com) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +package com.sandflow.smpte.klv; + +import com.sandflow.smpte.util.AUID; +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.security.InvalidParameterException; + +/** + * In-memory KLV Triplet + */ +public class MemoryTriplet implements Triplet { + + final private AUID key; + final private byte[] value; + + /** + * Creates a Triplet from a Key and an array of bytes as the Value + * @param key Triplet Key + * @param value Triplet Value + */ + public MemoryTriplet(AUID key, byte[] value) { + + if (key == null || value == null) throw new InvalidParameterException("Triplet muse have key and value."); + + this.key = key; + this.value = value; + } + + @Override + public AUID getKey() { + return key; + } + + @Override + public long getLength() { + return value.length; + } + + @Override + public byte[] getValue() { + return value; + } + + @Override + public InputStream getValueAsStream() { + return new ByteArrayInputStream(value); + } + +} diff --git a/regxmllib/src/main/java/com/sandflow/smpte/klv/Triplet.java b/src/main/java/com/sandflow/smpte/klv/Triplet.java similarity index 94% rename from regxmllib/src/main/java/com/sandflow/smpte/klv/Triplet.java rename to src/main/java/com/sandflow/smpte/klv/Triplet.java index 07f4afc..a0a067d 100644 --- a/regxmllib/src/main/java/com/sandflow/smpte/klv/Triplet.java +++ b/src/main/java/com/sandflow/smpte/klv/Triplet.java @@ -1,61 +1,61 @@ -/* - * Copyright (c) 2014, Pierre-Anthony Lemieux (pal@sandflow.com) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -package com.sandflow.smpte.klv; - -import com.sandflow.smpte.util.UL; -import java.io.InputStream; - -/** - * Abstract class representing a KLV Triplet per SMPTE ST 336 - */ -public interface Triplet { - - /** - * Returns the Key of the KLV Triplet - * @return Triplet Key - */ - UL getKey(); - - /** - * Returns the Length of the KLV Triplet - * @return Triplet Length - */ - long getLength(); - - /** - * Return the Value of the KLV Triplet as a byte array - * @return Triplet Value - */ - byte[] getValue(); - - /** - * Return the Value of the KLV Triplet as an Input Stream - * @return Triplet Value - */ - InputStream getValueAsStream(); - -} +/* + * Copyright (c) 2014, Pierre-Anthony Lemieux (pal@sandflow.com) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +package com.sandflow.smpte.klv; + +import com.sandflow.smpte.util.AUID; +import java.io.InputStream; + +/** + * Abstract class representing a KLV Triplet per SMPTE ST 336 + */ +public interface Triplet { + + /** + * Returns the Key of the KLV Triplet + * @return Triplet Key + */ + AUID getKey(); + + /** + * Returns the Length of the KLV Triplet + * @return Triplet Length + */ + long getLength(); + + /** + * Return the Value of the KLV Triplet as a byte array + * @return Triplet Value + */ + byte[] getValue(); + + /** + * Return the Value of the KLV Triplet as an Input Stream + * @return Triplet Value + */ + InputStream getValueAsStream(); + +} diff --git a/regxmllib/src/main/java/com/sandflow/smpte/klv/adapters/TripletValueAdapter.java b/src/main/java/com/sandflow/smpte/klv/adapters/TripletValueAdapter.java similarity index 97% rename from regxmllib/src/main/java/com/sandflow/smpte/klv/adapters/TripletValueAdapter.java rename to src/main/java/com/sandflow/smpte/klv/adapters/TripletValueAdapter.java index a55c0be..783a3e9 100644 --- a/regxmllib/src/main/java/com/sandflow/smpte/klv/adapters/TripletValueAdapter.java +++ b/src/main/java/com/sandflow/smpte/klv/adapters/TripletValueAdapter.java @@ -1,50 +1,50 @@ -/* - * Copyright (c) 2014, Pierre-Anthony Lemieux (pal@sandflow.com) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package com.sandflow.smpte.klv.adapters; - -/** - * TripletValueAdapter is an abstract class defining the conversion of KLV Triplet - * values to Java types. - * @param Type to which the Triplet Value will be converted to/from - */ -public class TripletValueAdapter { - - /** - * Converts a KLV Triplet Value to a Java object. - * @param Java object type - * @param value KLV Triplet Value - * @return Java object - */ - public static W fromValue(byte[] value) { return null;} - - /** - * Converts a Java object to a KLV Triplet Value. - * @param Java object type - * @param obj Java object - * @return KLV Triplet Value - */ - public static byte[] toValue(W obj) {return null;} -} +/* + * Copyright (c) 2014, Pierre-Anthony Lemieux (pal@sandflow.com) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +package com.sandflow.smpte.klv.adapters; + +/** + * TripletValueAdapter is an abstract class defining the conversion of KLV Triplet + * values to Java types. + * @param Type to which the Triplet Value will be converted to/from + */ +public class TripletValueAdapter { + + /** + * Converts a KLV Triplet Value to a Java object. + * @param Java object type + * @param value KLV Triplet Value + * @return Java object + */ + public static W fromValue(byte[] value) { return null;} + + /** + * Converts a Java object to a KLV Triplet Value. + * @param Java object type + * @param obj Java object + * @return KLV Triplet Value + */ + public static byte[] toValue(W obj) {return null;} +} diff --git a/regxmllib/src/main/java/com/sandflow/smpte/klv/adapters/ULValueAdapter.java b/src/main/java/com/sandflow/smpte/klv/adapters/ULValueAdapter.java similarity index 97% rename from regxmllib/src/main/java/com/sandflow/smpte/klv/adapters/ULValueAdapter.java rename to src/main/java/com/sandflow/smpte/klv/adapters/ULValueAdapter.java index 5c3a45a..006a5c3 100644 --- a/regxmllib/src/main/java/com/sandflow/smpte/klv/adapters/ULValueAdapter.java +++ b/src/main/java/com/sandflow/smpte/klv/adapters/ULValueAdapter.java @@ -1,53 +1,53 @@ -/* - * Copyright (c) 2014, Pierre-Anthony Lemieux (pal@sandflow.com) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package com.sandflow.smpte.klv.adapters; - -import com.sandflow.smpte.util.UL; - -/** - * ULValueAdapter converts a UL to and from a KLV Triplet Value - */ -public class ULValueAdapter extends TripletValueAdapter { - - /** - * Converts a KLV Triplet Value to a UL. - * @param value KLV Triplet Value - * @return UL - */ - public static UL fromValue(byte[] value) { - return new UL(value); - } - - /** - * Converts a UL to a KLV Triplet Value. - * @param obj UL - * @return KLV Triplet Value - */ - public static byte[] toValue(UL obj) { - return obj.getValue(); - } - -} +/* + * Copyright (c) 2014, Pierre-Anthony Lemieux (pal@sandflow.com) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +package com.sandflow.smpte.klv.adapters; + +import com.sandflow.smpte.util.UL; + +/** + * ULValueAdapter converts a UL to and from a KLV Triplet Value + */ +public class ULValueAdapter extends TripletValueAdapter { + + /** + * Converts a KLV Triplet Value to a UL. + * @param value KLV Triplet Value + * @return UL + */ + public static UL fromValue(byte[] value) { + return new UL(value); + } + + /** + * Converts a UL to a KLV Triplet Value. + * @param obj UL + * @return KLV Triplet Value + */ + public static byte[] toValue(UL obj) { + return obj.getValue(); + } + +} diff --git a/regxmllib/src/main/java/com/sandflow/smpte/klv/exceptions/KLVException.java b/src/main/java/com/sandflow/smpte/klv/exceptions/KLVException.java similarity index 97% rename from regxmllib/src/main/java/com/sandflow/smpte/klv/exceptions/KLVException.java rename to src/main/java/com/sandflow/smpte/klv/exceptions/KLVException.java index 899b5d9..59a5903 100644 --- a/regxmllib/src/main/java/com/sandflow/smpte/klv/exceptions/KLVException.java +++ b/src/main/java/com/sandflow/smpte/klv/exceptions/KLVException.java @@ -1,55 +1,55 @@ -/* - * Copyright (c) 2014, Pierre-Anthony Lemieux (pal@sandflow.com) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package com.sandflow.smpte.klv.exceptions; - -/** - * Exceptions raised when processing KLV packets - */ -public class KLVException extends Exception { - - public static String MAX_LENGTH_EXCEEED = "Maximum in-memory KLV size exceeded."; - public static String INVALID_BER_LENGTH = "Invalid BER encoding."; - public static String MAX_BER_SIZE_EXCEEED = "Maximum BER length exceeded."; - - public KLVException() { - super(); - } - - public KLVException(String msg) { - super(msg); - } - - public KLVException(Exception e) { - super(e); - } - - public KLVException(String string, Throwable thrwbl) { - super(string, thrwbl); - } - - - -} +/* + * Copyright (c) 2014, Pierre-Anthony Lemieux (pal@sandflow.com) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +package com.sandflow.smpte.klv.exceptions; + +/** + * Exceptions raised when processing KLV packets + */ +public class KLVException extends Exception { + + public static String MAX_LENGTH_EXCEEED = "Maximum in-memory KLV size exceeded."; + public static String INVALID_BER_LENGTH = "Invalid BER encoding."; + public static String MAX_BER_SIZE_EXCEEED = "Maximum BER length exceeded."; + + public KLVException() { + super(); + } + + public KLVException(String msg) { + super(msg); + } + + public KLVException(Exception e) { + super(e); + } + + public KLVException(String string, Throwable thrwbl) { + super(string, thrwbl); + } + + + +} diff --git a/regxmllib/src/main/java/com/sandflow/smpte/klv/exceptions/TripletLengthException.java b/src/main/java/com/sandflow/smpte/klv/exceptions/TripletLengthException.java similarity index 97% rename from regxmllib/src/main/java/com/sandflow/smpte/klv/exceptions/TripletLengthException.java rename to src/main/java/com/sandflow/smpte/klv/exceptions/TripletLengthException.java index 1e47846..3c3eace 100644 --- a/regxmllib/src/main/java/com/sandflow/smpte/klv/exceptions/TripletLengthException.java +++ b/src/main/java/com/sandflow/smpte/klv/exceptions/TripletLengthException.java @@ -1,37 +1,37 @@ -/* - * Copyright (c) 2014, Pierre-Anthony Lemieux (pal@sandflow.com) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -package com.sandflow.smpte.klv.exceptions; - -/** - * Raised when the length of a KLV triplet is not valid - */ -public class TripletLengthException extends RuntimeException { - - public TripletLengthException() { - } - -} +/* + * Copyright (c) 2014, Pierre-Anthony Lemieux (pal@sandflow.com) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +package com.sandflow.smpte.klv.exceptions; + +/** + * Raised when the length of a KLV triplet is not valid + */ +public class TripletLengthException extends RuntimeException { + + public TripletLengthException() { + } + +} diff --git a/regxmllib/src/main/java/com/sandflow/smpte/klv/package-info.java b/src/main/java/com/sandflow/smpte/klv/package-info.java similarity index 98% rename from regxmllib/src/main/java/com/sandflow/smpte/klv/package-info.java rename to src/main/java/com/sandflow/smpte/klv/package-info.java index 04147e0..b3ba62b 100644 --- a/regxmllib/src/main/java/com/sandflow/smpte/klv/package-info.java +++ b/src/main/java/com/sandflow/smpte/klv/package-info.java @@ -1,30 +1,30 @@ -/* - * Copyright (c) 2015, Pierre-Anthony Lemieux (pal@sandflow.com) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * Allows the processing of SMPTE KLV data structures, as specified in SMPTE ST 336. - */ -package com.sandflow.smpte.klv; +/* + * Copyright (c) 2015, Pierre-Anthony Lemieux (pal@sandflow.com) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * Allows the processing of SMPTE KLV data structures, as specified in SMPTE ST 336. + */ +package com.sandflow.smpte.klv; diff --git a/regxmllib/src/main/java/com/sandflow/smpte/mxf/FillItem.java b/src/main/java/com/sandflow/smpte/mxf/FillItem.java similarity index 97% rename from regxmllib/src/main/java/com/sandflow/smpte/mxf/FillItem.java rename to src/main/java/com/sandflow/smpte/mxf/FillItem.java index c4283db..21ea372 100644 --- a/regxmllib/src/main/java/com/sandflow/smpte/mxf/FillItem.java +++ b/src/main/java/com/sandflow/smpte/mxf/FillItem.java @@ -1,63 +1,63 @@ -/* - * Copyright (c) 2014, Pierre-Anthony Lemieux (pal@sandflow.com) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package com.sandflow.smpte.mxf; - -import com.sandflow.smpte.klv.Triplet; -import com.sandflow.smpte.klv.exceptions.KLVException; -import com.sandflow.smpte.util.UL; - -/** - * Represents an MXF Fill Item (see SMPTE ST 377-1) - */ -public class FillItem { - - static final UL KEY = new UL(new byte[]{0x06, 0x0e, 0x2b, 0x34, 0x01, 0x01, 0x01, 0x02, 0x03, 0x01, 0x02, 0x10, 0x01, 0x00, 0x00, 0x00}); - - /** - * Creates a Fill Item from a Triplet - * @param triplet Triplet from which to create the Fill Item - * @return FillItem or null if the Triplet is not a FillItem - * @throws KLVException - */ - public static FillItem fromTriplet(Triplet triplet) throws KLVException { - - FillItem fi = new FillItem(); - - if (!getKey().equalsIgnoreVersion(triplet.getKey())) { - return null; - } - - return fi; - } - - /** - * Returns the Fill Item Key - * @return Key - */ - public static UL getKey() { - return KEY; - } -} +/* + * Copyright (c) 2014, Pierre-Anthony Lemieux (pal@sandflow.com) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +package com.sandflow.smpte.mxf; + +import com.sandflow.smpte.klv.Triplet; +import com.sandflow.smpte.klv.exceptions.KLVException; +import com.sandflow.smpte.util.UL; + +/** + * Represents an MXF Fill Item (see SMPTE ST 377-1) + */ +public class FillItem { + + static final UL KEY = new UL(new byte[]{0x06, 0x0e, 0x2b, 0x34, 0x01, 0x01, 0x01, 0x02, 0x03, 0x01, 0x02, 0x10, 0x01, 0x00, 0x00, 0x00}); + + /** + * Creates a Fill Item from a Triplet + * @param triplet Triplet from which to create the Fill Item + * @return FillItem or null if the Triplet is not a FillItem + * @throws KLVException + */ + public static FillItem fromTriplet(Triplet triplet) throws KLVException { + + FillItem fi = new FillItem(); + + if (!getKey().equalsIgnoreVersion(triplet.getKey())) { + return null; + } + + return fi; + } + + /** + * Returns the Fill Item Key + * @return Key + */ + public static UL getKey() { + return KEY; + } +} diff --git a/regxmllib/src/main/java/com/sandflow/smpte/mxf/MXFFiles.java b/src/main/java/com/sandflow/smpte/mxf/MXFFiles.java similarity index 100% rename from regxmllib/src/main/java/com/sandflow/smpte/mxf/MXFFiles.java rename to src/main/java/com/sandflow/smpte/mxf/MXFFiles.java diff --git a/regxmllib/src/main/java/com/sandflow/smpte/mxf/MXFInputStream.java b/src/main/java/com/sandflow/smpte/mxf/MXFInputStream.java similarity index 83% rename from regxmllib/src/main/java/com/sandflow/smpte/mxf/MXFInputStream.java rename to src/main/java/com/sandflow/smpte/mxf/MXFInputStream.java index 6762232..f83b5ed 100644 --- a/regxmllib/src/main/java/com/sandflow/smpte/mxf/MXFInputStream.java +++ b/src/main/java/com/sandflow/smpte/mxf/MXFInputStream.java @@ -1,176 +1,155 @@ -/* - * Copyright (c) 2014, Pierre-Anthony Lemieux (pal@sandflow.com) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package com.sandflow.smpte.mxf; - -import com.sandflow.smpte.klv.KLVInputStream; -import com.sandflow.smpte.klv.adapters.TripletValueAdapter; -import com.sandflow.smpte.klv.exceptions.KLVException; -import com.sandflow.smpte.util.AUID; -import com.sandflow.smpte.util.IDAU; -import com.sandflow.smpte.util.UMID; -import com.sandflow.smpte.util.UUID; -import java.io.EOFException; -import java.io.IOException; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.Collection; - -/** - * MXFInputStream allows MXF data structures to be read from an InputStream - */ -public class MXFInputStream extends KLVInputStream { - - /** - * Assumes big endian byte ordering. - * - * @param is InputStream to read from - */ - public MXFInputStream(InputStream is) { - super(is); - } - - /** - * Allows the byte ordering to be specified. - * - * @param is InputStream to read from - * @param byteorder Byte ordering of the file - */ - public MXFInputStream(InputStream is, ByteOrder byteorder) { - super(is, byteorder); - } - - /** - * Reads a single UUID. - * @return UUID - * @throws IOException - * @throws EOFException - */ - public UUID readUUID() throws IOException, EOFException { - byte[] uuid = new byte[16]; - - if (read(uuid) < uuid.length) { - throw new EOFException(); - } - - if (getByteorder() == ByteOrder.LITTLE_ENDIAN) { - - uuidLEtoBE(uuid); - - } - - return new UUID(uuid); - } - - /** - * Reads a single IDAU. - * @return IDAU - * @throws IOException - * @throws EOFException - */ - public IDAU readIDAU() throws IOException, EOFException { - byte[] idau = new byte[16]; - - if (read(idau) < idau.length) { - throw new EOFException(); - } - - if (getByteorder() == ByteOrder.LITTLE_ENDIAN) { - - uuidLEtoBE(idau); - - } - - return new IDAU(idau); - } - - /** - * Reads a single AUID. - * @return AUID - * @throws IOException - * @throws EOFException - */ - public AUID readAUID() throws IOException, EOFException { - byte[] auid = new byte[16]; - - if (read(auid) < auid.length) { - throw new EOFException(); - } - - return new AUID(auid); - } - - /** - * Reads a single UMID. - * @return UMID - * @throws IOException - * @throws EOFException - */ - public UMID readUMID() throws IOException, EOFException { - byte[] umid = new byte[32]; - - if (read(umid) < umid.length) { - throw new EOFException(); - } - - return new UMID(umid); - } - - /** - * Reads an MXF array into a Java Collection - * - * @param Type of the collection elements - * @param TripletValueAdapter that is used to convert MXF array elements into Java collection elements - * @return Collection of elements of type T - * @throws KLVException - * @throws IOException - */ - public Collection readArray() throws KLVException, IOException { - return readBatch(); - } - - /** - * Reads an MXF batch into a Java Collection - * - * @param Type of the collection elements - * @param TripletValueAdapter that is used to convert MXF batch elements into Java collection elements - * @return Collection of elements of type T - * @throws KLVException - * @throws IOException - */ - public Collection readBatch() throws KLVException, IOException { - ArrayList batch = new ArrayList<>(); - long itemcount = readUnsignedInt(); - long itemlength = readUnsignedInt(); - if (itemlength > Integer.MAX_VALUE) { - throw new KLVException(KLVException.MAX_LENGTH_EXCEEED); - } - for (int i = 0; i < itemcount; i++) { - byte[] value = new byte[(int) itemlength]; - batch.add(W.fromValue(value)); - } - return batch; - } -} +/* + * Copyright (c) 2014, Pierre-Anthony Lemieux (pal@sandflow.com) + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +package com.sandflow.smpte.mxf; + +import com.sandflow.smpte.klv.KLVInputStream; +import com.sandflow.smpte.klv.adapters.TripletValueAdapter; +import com.sandflow.smpte.klv.exceptions.KLVException; +import com.sandflow.smpte.util.AUID; +import com.sandflow.smpte.util.IDAU; +import com.sandflow.smpte.util.UMID; +import com.sandflow.smpte.util.UUID; +import java.io.EOFException; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.Collection; + +/** + * MXFInputStream allows MXF data structures to be read from an InputStream + */ +public class MXFInputStream extends KLVInputStream { + + /** + * Assumes big endian byte ordering. + * + * @param is InputStream to read from + */ + public MXFInputStream(InputStream is) { + super(is); + } + + /** + * Allows the byte ordering to be specified. + * + * @param is InputStream to read from + * @param byteorder Byte ordering of the file + */ + public MXFInputStream(InputStream is, ByteOrder byteorder) { + super(is, byteorder); + } + + /** + * Reads a single UUID. + * @return UUID + * @throws IOException + * @throws EOFException + */ + public UUID readUUID() throws IOException, EOFException { + byte[] uuid = new byte[16]; + + readFully(uuid); + + if (getByteOrder() == ByteOrder.LITTLE_ENDIAN) { + + uuidLEtoBE(uuid); + + } + + return new UUID(uuid); + } + + /** + * Reads a single IDAU. + * @return IDAU + * @throws IOException + * @throws EOFException + */ + public IDAU readIDAU() throws IOException, EOFException { + byte[] idau = new byte[16]; + + readFully(idau); + + if (getByteOrder() == ByteOrder.LITTLE_ENDIAN) { + + uuidLEtoBE(idau); + + } + + return new IDAU(idau); + } + + /** + * Reads a single UMID. + * @return UMID + * @throws IOException + * @throws EOFException + */ + public UMID readUMID() throws IOException, EOFException { + byte[] umid = new byte[32]; + + readFully(umid); + + return new UMID(umid); + } + + /** + * Reads an MXF array into a Java Collection + * + * @param Type of the collection elements + * @param TripletValueAdapter that is used to convert MXF array elements into Java collection elements + * @return Collection of elements of type T + * @throws KLVException + * @throws IOException + */ + public Collection readArray() throws KLVException, IOException { + return readBatch(); + } + + /** + * Reads an MXF batch into a Java Collection + * + * @param Type of the collection elements + * @param TripletValueAdapter that is used to convert MXF batch elements into Java collection elements + * @return Collection of elements of type T + * @throws KLVException + * @throws IOException + */ + public Collection readBatch() throws KLVException, IOException { + ArrayList batch = new ArrayList<>(); + long itemcount = readUnsignedInt(); + long itemlength = readUnsignedInt(); + if (itemlength > Integer.MAX_VALUE) { + throw new KLVException(KLVException.MAX_LENGTH_EXCEEED); + } + for (int i = 0; i < itemcount; i++) { + byte[] value = new byte[(int) itemlength]; + read(value); + batch.add(W.fromValue(value)); + } + return batch; + } +} diff --git a/regxmllib/src/main/java/com/sandflow/smpte/mxf/PartitionPack.java b/src/main/java/com/sandflow/smpte/mxf/PartitionPack.java similarity index 95% rename from regxmllib/src/main/java/com/sandflow/smpte/mxf/PartitionPack.java rename to src/main/java/com/sandflow/smpte/mxf/PartitionPack.java index 7046951..0f09a0a 100644 --- a/regxmllib/src/main/java/com/sandflow/smpte/mxf/PartitionPack.java +++ b/src/main/java/com/sandflow/smpte/mxf/PartitionPack.java @@ -1,283 +1,283 @@ -/* - * Copyright (c) 2014, Pierre-Anthony Lemieux (pal@sandflow.com) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -package com.sandflow.smpte.mxf; - -import com.sandflow.smpte.klv.Triplet; -import com.sandflow.smpte.klv.adapters.ULValueAdapter; -import com.sandflow.smpte.klv.exceptions.KLVException; -import com.sandflow.smpte.util.UL; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collection; - -/** - * Represents a MXF Partition Pack Item (see SMPTE ST 377-1) - */ -public class PartitionPack { - - private static final UL KEY = new UL(new byte[]{0x06, 0x0e, 0x2b, 0x34, 0x02, 0x05, 0x01, 0x01, 0x0d, 0x01, 0x02, 0x01, 0x01, 0x00, 0x00, 0x00}); - - /** - * Returns the Partition Pack Key - * @return Key - */ - public static UL getKey() { - return KEY; - } - - /** - * Creates a Partition Pack from a Triplet - * @param triplet Triplet from which to create the Partition Pack - * @return PartitionPack or null if the Triplet is not a Partition Pack - * @throws KLVException - */ - public static PartitionPack fromTriplet(Triplet triplet) throws KLVException { - PartitionPack pp = new PartitionPack(); - - if (!KEY.equalsWithMask(triplet.getKey(), 0xfef9 /*11111110 11111001*/)) { - return null; - } - - switch (triplet.getKey().getValueOctet(14)) { - case 0x01: - pp.setStatus(Status.OPEN_INCOMPLETE); - break; - case 0x02: - pp.setStatus(Status.CLOSED_INCOMPLETE); - break; - case 0x03: - pp.setStatus(Status.OPEN_COMPLETE); - break; - case 0x04: - pp.setStatus(Status.CLOSED_COMPLETE); - break; - default: - return null; - } - - switch (triplet.getKey().getValueOctet(13)) { - case 0x02: - pp.setKind(Kind.HEADER); - - break; - case 0x03: - pp.setKind(Kind.BODY); - - break; - case 0x04: - pp.setKind(Kind.FOOTER); - if (pp.getStatus() == Status.OPEN_COMPLETE - || pp.getStatus() == Status.OPEN_INCOMPLETE) { - return null; - } - break; - default: - return null; - } - - MXFInputStream kis = new MXFInputStream(triplet.getValueAsStream()); - - try { - - pp.setMajorVersion(kis.readUnsignedShort()); - - pp.setMinorVersion(kis.readUnsignedShort()); - - pp.setKagSize(kis.readUnsignedInt()); - - pp.setThisPartition(kis.readLong()); - - pp.setPreviousPartition(kis.readLong()); - - pp.setFooterPartition(kis.readLong()); - - pp.setHeaderByteCount(kis.readLong()); - - pp.setIndexByteCount(kis.readLong()); - - pp.setIndexSID(kis.readUnsignedInt()); - - pp.setBodyOffset(kis.readLong()); - - pp.setBodySID(kis.readLong()); - - pp.setOperationalPattern(kis.readUL()); - - pp.setEssenceContainers(kis.readBatch()); - - } catch (IOException e) { - throw new KLVException(e); - } - - return pp; - } - - private int majorVersion; - private int minorVersion; - private long kagSize; - private long thisPartition; - private long previousPartition; - private long footerPartition; - private long headerByteCount; - private long indexByteCount; - private long indexSID; - private long bodyOffset; - private long bodySID; - private UL operationalPattern; - private ArrayList