Skip to content

Commit

Permalink
Fix ThirdParty library conflict in global namespace
Browse files Browse the repository at this point in the history
Signed-off-by: Maxime Gervais <[email protected]>
  • Loading branch information
g-maxime committed Apr 17, 2024
1 parent d3393c3 commit ede60e1
Show file tree
Hide file tree
Showing 19 changed files with 66 additions and 21 deletions.
2 changes: 1 addition & 1 deletion Project/GNU/CLI/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ mediaconch_SOURCES = \
../../../Source/Checker/Checker.cpp \
../../../Source/Checker/Path.cpp \
../../../Source/IMSC1/IMSC1Plugin.cpp \
../../../Source/ThirdParty/tfsxml/tfsxml.c
../../../Source/ThirdParty/tfsxml/tfsxml.cpp

#mediaconch_LDFLAGS = -no-undefined -version-info 0:0:0
mediaconch_CPPFLAGS = $(XML_CFLAGS)
Expand Down
2 changes: 1 addition & 1 deletion Project/GNU/Library/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ lib@MediaConchLib_LibName@_la_SOURCES = \
../../../Source/Checker/Checker.cpp \
../../../Source/Checker/Path.cpp \
../../../Source/IMSC1/IMSC1Plugin.cpp \
../../../Source/ThirdParty/tfsxml/tfsxml.c
../../../Source/ThirdParty/tfsxml/tfsxml.cpp

#lib@MediaConchLib_LibName@includedir = $(includedir)/MediaConch
#lib@MediaConchLib_LibName@include_HEADERS = \
Expand Down
2 changes: 1 addition & 1 deletion Project/GNU/Server/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ mediaconchd_SOURCES = \
../../../Source/Checker/Checker.cpp \
../../../Source/Checker/Path.cpp \
../../../Source/IMSC1/IMSC1Plugin.cpp \
../../../Source/ThirdParty/tfsxml/tfsxml.c
../../../Source/ThirdParty/tfsxml/tfsxml.cpp

#mediaconchd_LDFLAGS = -no-undefined -version-info 0:0:0
mediaconchd_CPPFLAGS = $(XML_CFLAGS)
Expand Down
2 changes: 1 addition & 1 deletion Project/MSVC2015/CLI/MediaConch.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
<ClCompile Include="..\..\..\Source\Checker\Checker.cpp" />
<ClCompile Include="..\..\..\Source\Checker\Path.cpp" />
<ClCompile Include="..\..\..\Source\IMSC1\IMSC1Plugin.cpp" />
<ClCompile Include="..\..\..\Source\ThirdParty\tfsxml\tfsxml.c" />
<ClCompile Include="..\..\..\Source\ThirdParty\tfsxml\tfsxml.cpp" />
<ClCompile Include="..\..\..\Source\ThirdParty\sqlite\sqlite3.c" />
</ItemGroup>
<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Project/MSVC2015/GUI/MediaConch_GUI.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@
<ClCompile Include="..\..\..\Source\GUI\Qt\WebKitPage.cpp" />
<ClCompile Include="..\..\..\Source\GUI\Qt\WebKitView.cpp" />
<ClCompile Include="..\..\..\Source\GUI\Qt\workerfiles.cpp" />
<ClCompile Include="..\..\..\Source\ThirdParty\tfsxml\tfsxml.c" />
<ClCompile Include="..\..\..\Source\ThirdParty\tfsxml\tfsxml.cpp" />
<ClCompile Include="..\..\..\Source\ThirdParty\sqlite\sqlite3.c" />
<ClCompile Include="_Automated\moc_commonwebwindow.cpp" />
<ClCompile Include="_Automated\moc_helpwindow.cpp" />
Expand Down
2 changes: 1 addition & 1 deletion Project/MSVC2015/Server/MediaConch-Server.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@
<ClCompile Include="..\..\..\Source\Checker\Checker.cpp" />
<ClCompile Include="..\..\..\Source\Checker\Path.cpp" />
<ClCompile Include="..\..\..\Source\IMSC1\IMSC1Plugin.cpp" />
<ClCompile Include="..\..\..\Source\ThirdParty\tfsxml\tfsxml.c" />
<ClCompile Include="..\..\..\Source\ThirdParty\tfsxml\tfsxml.cpp" />
<ClCompile Include="..\..\..\Source\ThirdParty\sqlite\sqlite3.c" />
</ItemGroup>
<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Project/MSVC2017/CLI/MediaConch.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
<ClCompile Include="..\..\..\Source\Checker\Checker.cpp" />
<ClCompile Include="..\..\..\Source\Checker\Path.cpp" />
<ClCompile Include="..\..\..\Source\IMSC1\IMSC1Plugin.cpp" />
<ClCompile Include="..\..\..\Source\ThirdParty\tfsxml\tfsxml.c" />
<ClCompile Include="..\..\..\Source\ThirdParty\tfsxml\tfsxml.cpp" />
<ClCompile Include="..\..\..\Source\ThirdParty\sqlite\sqlite3.c" />
</ItemGroup>
<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Project/MSVC2017/GUI/MediaConch_GUI.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@
<ClCompile Include="..\..\..\Source\GUI\Qt\WebKitPage.cpp" />
<ClCompile Include="..\..\..\Source\GUI\Qt\WebKitView.cpp" />
<ClCompile Include="..\..\..\Source\GUI\Qt\workerfiles.cpp" />
<ClCompile Include="..\..\..\Source\ThirdParty\tfsxml\tfsxml.c" />
<ClCompile Include="..\..\..\Source\ThirdParty\tfsxml\tfsxml.cpp" />
<ClCompile Include="..\..\..\Source\ThirdParty\sqlite\sqlite3.c" />
<ClCompile Include="_Automated\moc_commonwebwindow.cpp" />
<ClCompile Include="_Automated\moc_helpwindow.cpp" />
Expand Down
2 changes: 1 addition & 1 deletion Project/MSVC2017/Server/MediaConch-Server.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@
<ClCompile Include="..\..\..\Source\Checker\Checker.cpp" />
<ClCompile Include="..\..\..\Source\Checker\Path.cpp" />
<ClCompile Include="..\..\..\Source\IMSC1\IMSC1Plugin.cpp" />
<ClCompile Include="..\..\..\Source\ThirdParty\tfsxml\tfsxml.c" />
<ClCompile Include="..\..\..\Source\ThirdParty\tfsxml\tfsxml.cpp" />
<ClCompile Include="..\..\..\Source\ThirdParty\sqlite\sqlite3.c" />
</ItemGroup>
<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Project/MSVC2019/CLI/MediaConch.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
<ClCompile Include="..\..\..\Source\Checker\Checker.cpp" />
<ClCompile Include="..\..\..\Source\Checker\Path.cpp" />
<ClCompile Include="..\..\..\Source\IMSC1\IMSC1Plugin.cpp" />
<ClCompile Include="..\..\..\Source\ThirdParty\tfsxml\tfsxml.c" />
<ClCompile Include="..\..\..\Source\ThirdParty\tfsxml\tfsxml.cpp" />
<ClCompile Include="..\..\..\Source\ThirdParty\sqlite\sqlite3.c" />
</ItemGroup>
<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Project/MSVC2019/GUI/MediaConch_GUI.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@
<ClCompile Include="..\..\..\Source\GUI\Qt\WebKitPage.cpp" />
<ClCompile Include="..\..\..\Source\GUI\Qt\WebKitView.cpp" />
<ClCompile Include="..\..\..\Source\GUI\Qt\workerfiles.cpp" />
<ClCompile Include="..\..\..\Source\ThirdParty\tfsxml\tfsxml.c" />
<ClCompile Include="..\..\..\Source\ThirdParty\tfsxml\tfsxml.cpp" />
<ClCompile Include="..\..\..\Source\ThirdParty\sqlite\sqlite3.c" />
<ClCompile Include="_Automated\moc_commonwebwindow.cpp" />
<ClCompile Include="_Automated\moc_helpwindow.cpp" />
Expand Down
2 changes: 1 addition & 1 deletion Project/MSVC2019/Server/MediaConch-Server.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@
<ClCompile Include="..\..\..\Source\Checker\Checker.cpp" />
<ClCompile Include="..\..\..\Source\Checker\Path.cpp" />
<ClCompile Include="..\..\..\Source\IMSC1\IMSC1Plugin.cpp" />
<ClCompile Include="..\..\..\Source\ThirdParty\tfsxml\tfsxml.c" />
<ClCompile Include="..\..\..\Source\ThirdParty\tfsxml\tfsxml.cpp" />
<ClCompile Include="..\..\..\Source\ThirdParty\sqlite\sqlite3.c" />
</ItemGroup>
<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Project/Qt/MediaConch.pro
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ SOURCES += ../../Source/Common/MediaConchLib.cpp \
../../Source/Checker/Checker.cpp \
../../Source/Checker/Path.cpp \
../../Source/IMSC1/IMSC1Plugin.cpp \
../../Source/ThirdParty/tfsxml/tfsxml.c \
../../Source/ThirdParty/tfsxml/tfsxml.cpp \
../../Source/GUI/Qt/main.cpp \
../../Source/GUI/Qt/commonwebwindow.cpp \
../../Source/GUI/Qt/helpwindow.cpp \
Expand Down
3 changes: 3 additions & 0 deletions Source/Checker/Checker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
#include <cstring>
#include <sstream>

//---------------------------------------------------------------------------
using namespace tfsxml;

//TODO: mmt
//TODO: reference_file

Expand Down
9 changes: 6 additions & 3 deletions Source/Checker/Checker.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
#ifndef TFSXML_NAMESPACE
#define TFSXML_NAMESPACE 1
#endif // TFSXML_NAMESPACEs
#include "ThirdParty/tfsxml/tfsxml.h"
#include "Path.h"

Expand Down Expand Up @@ -124,9 +127,9 @@ class PolicyChecker
size_t fail_count;
};

RuleElement* parse_rule(tfsxml_string& tfsxml_priv);
PolicyElement* parse_policy(tfsxml_string& tfsxml_priv);
void parse_node(tfsxml_string& tfsxml_priv, std::vector<RuleElement*> rules, size_t level);
RuleElement* parse_rule(tfsxml::tfsxml_string& tfsxml_priv);
PolicyElement* parse_policy(tfsxml::tfsxml_string& tfsxml_priv);
void parse_node(tfsxml::tfsxml_string& tfsxml_priv, std::vector<RuleElement*> rules, size_t level);

std::vector<PolicyElement*> policies;
std::vector<RuleElement*> rules;
Expand Down
3 changes: 3 additions & 0 deletions Source/Checker/Path.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
//---------------------------------------------------------------------------
#include "Path.h"

//---------------------------------------------------------------------------
using namespace tfsxml;

//---------------------------------------------------------------------------
namespace MediaConch {

Expand Down
5 changes: 4 additions & 1 deletion Source/Checker/Path.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
#ifndef TFSXML_NAMESPACE
#define TFSXML_NAMESPACE 1
#endif // TFSXML_NAMESPACE
#include "ThirdParty/tfsxml/tfsxml.h"

#include <string>
Expand All @@ -39,7 +42,7 @@ struct PathElement
};

std::vector<PathElement> parse_path(const std::string& xpath);
bool path_is_matching(tfsxml_string& tfsxml_priv, tfsxml_string& node, PathElement path, size_t& occurrence);
bool path_is_matching(tfsxml::tfsxml_string& tfsxml_priv, tfsxml::tfsxml_string& node, PathElement path, size_t& occurrence);
}

#endif
26 changes: 26 additions & 0 deletions Source/ThirdParty/tfsxml/tfsxml.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/* Copyright (c) MediaArea.net SARL. All Rights Reserved.
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
(zlib license)
*/
#include "tfsxml.h"

namespace tfsxml {
#include "tfsxml.c"
}
15 changes: 11 additions & 4 deletions Source/ThirdParty/tfsxml/tfsxml.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
#ifndef TFSXML_H
#define TFSXML_H

#ifdef __cplusplus
#if defined(__cplusplus) && !defined(TFSXML_NAMESPACE)
extern "C"
{
#endif /* __cplusplus */
#elif defined(__cplusplus) && defined(TFSXML_NAMESPACE)
namespace tfsxml
{
#endif /* defined(__cplusplus) && !defined(TFSXML_NAMESPACE) */

/** -------------------------------------------------------------------------
Splitting of the XML content in blocks
Expand Down Expand Up @@ -130,9 +133,9 @@ int tfsxml_strcmp_charp(tfsxml_string a, const char* b);
*/
tfsxml_string tfsxml_strstr_charp(tfsxml_string a, const char* b);

#ifdef __cplusplus
#if defined(__cplusplus) && !defined(TFSXML_NAMESPACE)
}
#endif /* __cplusplus */
#endif /* defined(__cplusplus) && !defined(TFSXML_NAMESPACE) */

#ifdef __cplusplus
#include <string>
Expand All @@ -155,5 +158,9 @@ static std::string tfsxml_decode(const tfsxml_string& b) { std::string s; tfsxml

#endif /* __cplusplus */

#if defined(__cplusplus) && defined(TFSXML_NAMESPACE)
}
#endif /* defined(__cplusplus) && defined(TFSXML_NAMESPACE) */

#endif

0 comments on commit ede60e1

Please sign in to comment.