SET(CXX_11_STD "c++11")
endif()
+# special case for a GCC < 4.9, use boost for regex
+IF("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9)
+ SET(USE_BOOST_REGEX "regex")
+ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_BOOST_REGEX")
+else()
+ SET(USE_BOOST_REGEX "")
+endif()
+
SET(CMAKE_C_FLAGS_PROFILING "-O0 -pg")
SET(CMAKE_CXX_FLAGS_PROFILING "-std=${CXX_11_STD} -O0 -pg")
SET(CMAKE_C_FLAGS_DEBUG "-O0 -ggdb")
ADD_DEPENDENCIES(${PROJECT_NAME} Common Logger Config Ipc)
## Link libraries ##############################################################
-FIND_PACKAGE(Boost COMPONENTS system filesystem)
+FIND_PACKAGE(Boost COMPONENTS system filesystem ${USE_BOOST_REGEX})
PKG_CHECK_MODULES(LXCPP_DEPS REQUIRED glib-2.0)
INCLUDE_DIRECTORIES(${LIBS_FOLDER} ${COMMON_FOLDER})
#include "utils/text.hpp"
#include "logger/logger.hpp"
+#ifdef USE_BOOST_REGEX
+#include <boost/regex.hpp>
+namespace rgx = boost;
+#else
#include <regex>
+namespace rgx = std;
+#endif
namespace lxcpp {
DevicePermission& parsePerms(DevicePermission& p,const std::string& line)
{
std::string re = "^([a-z]) ([0-9]+|\\*):([0-9]+|\\*) ([a-z]+)$";
- std::smatch match;
+ rgx::smatch match;
try {
- std::regex rgx(re);
- if (!std::regex_search(line, match, rgx)) {
+ rgx::regex rgex(re);
+ if (!rgx::regex_search(line, match, rgex)) {
throw CGroupException("wrong input: " + line);
}
} catch (CGroupException) {
ADD_DEPENDENCIES(${SERVER_CODENAME} Common Logger Config Ipc)
## Link libraries ##############################################################
-FIND_PACKAGE(Boost COMPONENTS program_options system filesystem regex)
+FIND_PACKAGE(Boost COMPONENTS program_options system filesystem ${USE_BOOST_REGEX})
PKG_CHECK_MODULES(SERVER_DEPS REQUIRED lxc glib-2.0 gio-2.0)
INCLUDE_DIRECTORIES(${COMMON_FOLDER})
#include <unistd.h>
#include <boost/filesystem.hpp>
-#include <boost/regex.hpp>
#include <vector>
#include <functional>
+#ifdef USE_BOOST_REGEX
+#include <boost/regex.hpp>
+namespace rgx = boost;
+#else
+#include <regex>
+namespace rgx = std;
+#endif
+
using namespace utils;
namespace fs = boost::filesystem;
namespace {
-bool isDeviceWithName(const boost::regex& deviceNameRegex,
+bool isDeviceWithName(const rgx::regex& deviceNameRegex,
const fs::directory_entry& directoryEntry)
{
std::string path = directoryEntry.path().string();
}
LOGD("Checking device: " << name);
- if (boost::regex_match(name, deviceNameRegex)) {
+ if (rgx::regex_match(name, deviceNameRegex)) {
LOGI("Device file found under: " << path);
return true;
}
LOGT("Determining, which device node is assigned to '" << device << "'");
using namespace std::placeholders;
fs::directory_iterator end;
- boost::regex deviceNameRegex(".*" + device + ".*");
+ rgx::regex deviceNameRegex(".*" + device + ".*");
const auto it = std::find_if(fs::directory_iterator(DEVICE_DIR),
end,
std::bind(isDeviceWithName, deviceNameRegex, _1));
#include <string>
#include <memory>
#include <thread>
-#include <boost/regex.hpp>
namespace vasum {
#include "api/messages.hpp"
#include <boost/filesystem.hpp>
-#include <boost/regex.hpp>
#include <boost/exception/diagnostic_information.hpp>
#include <cassert>
#include <string>
#include <cctype>
#include <set>
+#ifdef USE_BOOST_REGEX
+#include <boost/regex.hpp>
+namespace rgx = boost;
+#else
+#include <regex>
+namespace rgx = std;
+#endif
namespace vasum {
const std::string HOST_ID = "host";
const std::string ENABLED_FILE_NAME = "enabled";
-const boost::regex ZONE_NAME_REGEX("~NAME~");
-const boost::regex ZONE_IP_THIRD_OCTET_REGEX("~IP~");
+const rgx::regex ZONE_NAME_REGEX("~NAME~");
+const rgx::regex ZONE_IP_THIRD_OCTET_REGEX("~IP~");
const unsigned int ZONE_IP_BASE_THIRD_OCTET = 100;
config::loadFromKVStoreWithJsonFile(mConfig.dbPath, templatePath, dynamicConfig, dbPrefix);
// update mount point path
- dynamicConfig.runMountPoint = boost::regex_replace(dynamicConfig.runMountPoint,
+ dynamicConfig.runMountPoint = rgx::regex_replace(dynamicConfig.runMountPoint,
ZONE_NAME_REGEX,
id);
// generate third IP octet for network config
std::string thirdOctetStr = std::to_string(ZONE_IP_BASE_THIRD_OCTET + freeVT);
LOGD("IP third octet: " << thirdOctetStr);
- dynamicConfig.ipv4Gateway = boost::regex_replace(dynamicConfig.ipv4Gateway,
+ dynamicConfig.ipv4Gateway = rgx::regex_replace(dynamicConfig.ipv4Gateway,
ZONE_IP_THIRD_OCTET_REGEX,
thirdOctetStr);
- dynamicConfig.ipv4 = boost::regex_replace(dynamicConfig.ipv4,
+ dynamicConfig.ipv4 = rgx::regex_replace(dynamicConfig.ipv4,
ZONE_IP_THIRD_OCTET_REGEX,
thirdOctetStr);
}
ENDIF(NOT WITHOUT_SYSTEMD)
## Link libraries ##############################################################
-FIND_PACKAGE (Boost COMPONENTS unit_test_framework system filesystem regex)
+FIND_PACKAGE (Boost COMPONENTS unit_test_framework system filesystem ${USE_BOOST_REGEX})
PKG_CHECK_MODULES(UT_SERVER_DEPS REQUIRED lxc gio-2.0)
INCLUDE_DIRECTORIES(${COMMON_FOLDER} ${SERVER_FOLDER} ${UNIT_TESTS_FOLDER} ${CLIENT_FOLDER}
#include <vector>
#include <map>
+#include <set>
#include <memory>
#include <string>
#include <algorithm>