Skip to content

Commit

Permalink
Added support for UWP
Browse files Browse the repository at this point in the history
  • Loading branch information
esteve committed Feb 21, 2017
1 parent 964ff38 commit 5e9e548
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 143 deletions.
10 changes: 9 additions & 1 deletion src/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,11 @@ configure_file(${PROJECT_SOURCE_DIR}/include/${PROJECT_NAME}/config.h.in
# If Windows, set define for export dll functions
add_definitions(-D${PROJECT_NAME_UPPER}_SOURCE)
if(WIN32)
add_definitions(-D_WIN32_WINNT=0x0601)
if("${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsStore")
add_definitions(-D_WIN32_WINNT=0x0603)
else()
add_definitions(-D_WIN32_WINNT=0x0601)
endif()
endif()
# If INTERNAL_DEBUG = ON, define symbol for extensive debug messages
if(INTERNAL_DEBUG)
Expand Down Expand Up @@ -164,6 +168,10 @@ if(MSVC OR MSVC_IDE)
set_target_properties(${PROJECT_NAME} ${PROJECT_NAME}_static PROPERTIES RELWITHDEBINFO_POSTFIX -${PROJECT_MAJOR_VERSION}.${PROJECT_MINOR_VERSION})
set_target_properties(${PROJECT_NAME} ${PROJECT_NAME}_static PROPERTIES DEBUG_POSTFIX d-${PROJECT_MAJOR_VERSION}.${PROJECT_MINOR_VERSION})

if("${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsStore")
set_target_properties(${PROJECT_NAME} ${PROJECT_NAME}_static PROPERTIES VS_WINRT_COMPONENT "true")
endif()

# Export symbols in DLL library
target_compile_definitions(${PROJECT_NAME} PUBLIC ${PROJECT_NAME_UPPER}_DYN_LINK)

Expand Down
139 changes: 0 additions & 139 deletions src/cpp/fastrtps.rc

This file was deleted.

4 changes: 3 additions & 1 deletion src/cpp/rtps/RTPSDomain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@ RTPSParticipant* RTPSDomain::createParticipant(RTPSParticipantAttributes& PParam

PParam.participantID = ID;
int pid;
#if defined(_WIN32)
#if defined(__cplusplus_winrt)
pid = (int)GetCurrentProcessId();
#elif defined(_WIN32)
pid = (int)_getpid();
#else
pid = (int)getpid();
Expand Down
48 changes: 46 additions & 2 deletions src/cpp/utils/StringMatching.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@

#include <fastrtps/utils/StringMatching.h>

#if defined(_WIN32)
#if defined(__cplusplus_winrt)
#include <algorithm>
#include <regex>
#elif defined(_WIN32)
#include "Shlwapi.h"
#else
#include <fnmatch.h>
Expand All @@ -38,7 +41,48 @@ StringMatching::~StringMatching() {
// TODO Auto-generated destructor stub
}

#if defined(_WIN32)
#if defined(__cplusplus_winrt)
void replace_all(std::string & subject, const std::string & search, const std::string & replace) {
size_t pos = 0;
while ((pos = subject.find(search, pos)) != std::string::npos) {
subject.replace(pos, search.length(), replace);
pos += replace.length();
}
}

bool StringMatching::matchString(const char* str1, const char* str2)
{
std::string path(str1);
std::string spec(str2);

std::string base_path(path);
std::string base_spec(spec);

replace_all(base_spec, "*", ".*");
replace_all(base_spec, "?", ".");

std::regex base_spec_regex(base_spec);
std::smatch base_spec_match;
if (std::regex_match(path, base_spec_match, base_spec_regex))
{
return true;
}

replace_all(base_path, "*", ".*");
replace_all(base_path, "?", ".");

std::regex base_path_regex(base_path);
std::smatch base_path_match;

if (std::regex_match(spec, base_path_match, base_path_regex))
{
return true;
}

return false;
}

#elif defined(_WIN32)
bool StringMatching::matchString(const char* str1, const char* str2)
{
if(PathMatchSpec(str1,str2))
Expand Down

0 comments on commit 5e9e548

Please sign in to comment.