# Compiler flags
SET(EXTRA_FLAGS "-Wall -Wextra")
SET(CMAKE_C_FLAGS_PROFILING "-O2 ${EXTRA_FLAGS}")
-SET(CMAKE_CXX_FLAGS_PROFILING "-O2 -std=c++14 ${EXTRA_FLAGS}")
+SET(CMAKE_CXX_FLAGS_PROFILING "-O2 -std=c++17 ${EXTRA_FLAGS}")
SET(CMAKE_C_FLAGS_DEBUG "-O0 -g ${EXTRA_FLAGS}")
-SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -std=c++14 -g ${EXTRA_FLAGS}")
+SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -std=c++17 -g ${EXTRA_FLAGS}")
SET(CMAKE_C_FLAGS_RELEASE "-O2 -g ${EXTRA_FLAGS}")
-SET(CMAKE_CXX_FLAGS_RELEASE "-O2 -std=c++14 -g ${EXTRA_FLAGS}")
-SET(CMAKE_CXX_FLAGS_CCOV "-O0 -std=c++14 -g --coverage ${EXTRA_FLAGS}")
+SET(CMAKE_CXX_FLAGS_RELEASE "-O2 -std=c++17 -g ${EXTRA_FLAGS}")
+SET(CMAKE_CXX_FLAGS_CCOV "-O0 -std=c++17 -g --coverage ${EXTRA_FLAGS}")
# Linker flags
SET(EXTRA_LINKER_FLAGS "-Wl,--as-needed")
PKG_CHECK_MODULES(DLOG_DEPS REQUIRED dlog)
FIND_PACKAGE(GTest REQUIRED)
-FIND_PACKAGE(Boost REQUIRED COMPONENTS system filesystem)
# xmlsec1 - choose crypto library which to use
ADD_DEFINITIONS("-DXMLSEC_CRYPTO_OPENSSL")
Source0: %{name}-%{version}.tar.gz
Source100: %{name}.manifest
-BuildRequires: boost-devel
BuildRequires: cmake
BuildRequires: gtest-devel
BuildRequires: pkgconfig(dlog)
Summary: Manifest parser development files
Group: Application Framework/Package Management
Requires: %{name} = %{version}
-Requires: boost-devel
Provides: manifest-parser-devel
%description devel
#include "delta/delta_parser.h"
+#include <filesystem>
#include <utility>
#include <vector>
return parser_->GetErrorMessage();
}
-bool DeltaParser::ParseManifest(const boost::filesystem::path& path) {
+bool DeltaParser::ParseManifest(const std::filesystem::path& path) {
if (!parser_->ParseManifest(path))
return false;
#ifndef DELTA_DELTA_PARSER_H_
#define DELTA_DELTA_PARSER_H_
-#include <boost/filesystem/path.hpp>
-
+#include <filesystem>
#include <memory>
#include <string>
std::shared_ptr<const parser::ManifestData> GetManifestData(
const std::string& key);
const std::string& GetErrorMessage() const;
- bool ParseManifest(const boost::filesystem::path& path);
+ bool ParseManifest(const std::filesystem::path& path);
private:
std::unique_ptr<parser::ManifestParser> parser_;
# Target - includes
TARGET_INCLUDE_DIRECTORIES(${TARGET_EXAMPLES} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/")
-# Target - deps
-APPLY_PKG_CONFIG(${TARGET_EXAMPLES} PUBLIC
- Boost
-)
-
TARGET_LINK_LIBRARIES(${TARGET_EXAMPLES} PUBLIC ${TARGET_LIBNAME_PARSER})
INSTALL(FILES config.xml DESTINATION ${SHAREDIR}/manifest-parser)
#include <manifest_parser/manifest_parser.h>
// Include manifest handler, which is packaged with manifest parser
-#include <boost/filesystem/path.hpp>
#include <cassert>
+#include <cstring>
#include <memory>
#include "custom_handlers/handler_constants.h"
#include "custom_handlers/item_handler.h"
int main() {
- boost::filesystem::path manifest_path =
+ std::filesystem::path manifest_path =
"/usr/share/manifest-parser/config.xml";
// Create manifest handler registry
# Target - deps
APPLY_PKG_CONFIG(${TARGET_LIBNAME_PARSER} PUBLIC
LIBXML_DEPS
- Boost
)
# Extra
#include "manifest_parser/permission_types.h"
#include "manifest_parser/values.h"
-namespace bf = boost::filesystem;
+namespace fs = std::filesystem;
namespace parser {
return impl_->GetErrorMessage();
}
-bool ManifestParser::ParseManifest(const boost::filesystem::path& path,
+bool ManifestParser::ParseManifest(const std::filesystem::path& path,
std::shared_ptr<ManifestConstraints> constraints) {
return impl_->ParseManifest(path, constraints);
}
#ifndef MANIFEST_PARSER_MANIFEST_PARSER_H_
#define MANIFEST_PARSER_MANIFEST_PARSER_H_
-#include <boost/filesystem/path.hpp>
-
+#include <filesystem>
#include <memory>
#include <string>
virtual const std::string& GetErrorMessage() const;
// Parses manifest file to manfiest_ object
- bool ParseManifest(const boost::filesystem::path& path,
+ bool ParseManifest(const std::filesystem::path& path,
std::shared_ptr<ManifestConstraints> constraints = nullptr);
std::shared_ptr<const ManifestData> GetManifestData(
#include "manifest_parser/manifest_parser_impl.h"
-#include <boost/filesystem/operations.hpp>
-#include <boost/filesystem/path.hpp>
-
+#include <filesystem>
+#include <system_error>
#include <utility>
#include "manifest_parser/manifest_util.h"
#include "manifest_parser/values.h"
#include "manifest_parser/utils/logging.h"
-namespace bf = boost::filesystem;
-namespace bs = boost::system;
+namespace fs = std::filesystem;
namespace {
return error_;
}
-bool ManifestParserImpl::ParseManifest(const bf::path& manifest_path,
+bool ManifestParserImpl::ParseManifest(const fs::path& manifest_path,
std::shared_ptr<ManifestConstraints> constraints) {
error_.clear();
if (manifest_path.empty()) {
SetError(kErrMsgNoPath, &error_);
return false;
}
- bs::error_code ec;
+ std::error_code ec;
if (!exists(manifest_path, ec)) {
SetError(kErrMsgInvalidPath, &error_);
if (ec)
#ifndef MANIFEST_PARSER_MANIFEST_PARSER_IMPL_H_
#define MANIFEST_PARSER_MANIFEST_PARSER_IMPL_H_
-#include <boost/filesystem/path.hpp>
-
+#include <filesystem>
#include <map>
#include <memory>
#include <set>
* @param constraints
* @return true on success
*/
- bool ParseManifest(const boost::filesystem::path& path,
+ bool ParseManifest(const std::filesystem::path& path,
std::shared_ptr<ManifestConstraints> constraints = nullptr);
/**
#include "manifest_parser/manifest_util.h"
-#include <boost/filesystem/operations.hpp>
-
#include <algorithm>
#include <cassert>
+#include <filesystem>
#include <map>
#include <regex>
#include <vector>
#include "manifest_parser/utils/string_util.h"
#include "manifest_parser/values.h"
-namespace bf = boost::filesystem;
+namespace fs = std::filesystem;
namespace {
return std::make_shared<parser::Manifest>(std::move(result));
}
-bf::path ApplicationURLToRelativeFilePath(const std::string& url) {
+fs::path ApplicationURLToRelativeFilePath(const std::string& url) {
std::string url_path = url;
if (url_path.empty() || url_path[0] != '/')
- return bf::path();
+ return fs::path();
std::string file_path = utils::DecodePercentEscapedCharacter(url_path);
if (file_path.empty())
- return bf::path();
+ return fs::path();
- bf::path path(file_path);
+ fs::path path(file_path);
// It's still possible for someone to construct an annoying URL whose path
// would still wind up not being considered relative at this point.
// For example: app://id/c:////foo.html
if (path.is_absolute())
- return bf::path();
+ return fs::path();
return path;
}
#ifndef MANIFEST_PARSER_MANIFEST_UTIL_H_
#define MANIFEST_PARSER_MANIFEST_UTIL_H_
-#include <boost/filesystem/path.hpp>
#include <libxml2/libxml/tree.h>
#include <string>
APPLY_PKG_CONFIG(${TARGET_LIBNAME_UTILS} PUBLIC
LIBIRI_DEPS
DLOG_DEPS
- Boost
)
# Extra
#include "manifest_parser/utils/language_tag_validator.h"
-#include <boost/algorithm/string.hpp>
+#include <algorithm>
+#include <cctype>
+#include <string>
#include <vector>
#include "manifest_parser/utils/w3c_languages.h"
-
-namespace ba = boost::algorithm;
+#include "manifest_parser/utils/string_util.h"
namespace {
-const char kTagDelimiter[] = "-";
+const char kTagDelimiter = '-';
const int kSingletonTagSize = 1;
const int kMaximumExtensionTagSize = 16;
const int kMaximumPrivateTagSize = 8;
std::string Capitalized(const std::string& input) {
std::string output = input;
- ba::to_lower(output);
- output[0] = toupper(output[0]);
+ std::transform(output.begin(), output.end(), output.begin(),
+ [](unsigned char c) { return std::tolower(c); });
+ output[0] = std::toupper(output[0]);
return output;
}
std::string ToLower(const std::string& input) {
std::string output = input;
- ba::to_lower(output);
+ std::transform(output.begin(), output.end(), output.begin(),
+ [](unsigned char c) { return std::tolower(c); });
return output;
}
std::string ToUpper(const std::string& input) {
std::string output = input;
- ba::to_upper(output);
+ std::transform(output.begin(), output.end(), output.begin(),
+ [](unsigned char c) { return std::toupper(c); });
return output;
}
bool CheckSingleton(std::vector<std::string>::iterator * current_item,
*error = "tag is empty";
return false;
}
- boost::split(splitted_tag, tag, boost::is_any_of(kTagDelimiter));
+ parser::utils::Split(splitted_tag, tag, kTagDelimiter);
auto current_item = splitted_tag.begin();
// main language validation
if (current_item != splitted_tag.end() &&
} // namespace w3c_languages
} // namespace utils
-
-
#include "manifest_parser/utils/string_util.h"
+#include <algorithm>
#include <cstdlib>
#include <map>
+#include <string>
+#include <sstream>
+#include <iterator>
#include <vector>
namespace {
return std::string(output.begin(), output.end());
}
+std::string Join(const std::vector<std::string> strings, const char* delim) {
+ std::ostringstream oss;
+ std::copy(strings.begin(), strings.end(),
+ std::ostream_iterator<std::string>(oss, delim));
+
+ std::string result = oss.str();
+ result.pop_back();
+ return result;
+}
+
+// trim from both ends (in place)
+void Trim(std::string &s) {
+ // trim from start (in place)
+ s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](unsigned char ch) {
+ return !std::isspace(ch);
+ }));
+
+ // trim from end (in place)
+ s.erase(std::find_if(s.rbegin(), s.rend(), [](unsigned char ch) {
+ return !std::isspace(ch);
+ }).base(), s.end());
+}
+
+void Split(std::vector<std::string>& tokens, const std::string& str,
+ const char delim) {
+ const char* ptr = str.data();
+ do {
+ const char* begin = ptr;
+ while (*ptr != delim && *ptr)
+ ptr++;
+ tokens.emplace_back(begin, ptr);
+ } while (*ptr++ != 0);
+}
+
+
} // namespace utils
} // namespace parser
#define MANIFEST_PARSER_UTILS_STRING_UTIL_H_
#include <string>
+#include <vector>
namespace parser {
namespace utils {
*/
std::string DecodePercentEscapedCharacter(const std::string& text);
+/**
+ * @brief Join
+ * Concatenates all strings in vector into single string.
+ *
+ * @param strings vector of strings
+ * @param delim delimiter between strings
+ * @return concatenated string
+ */
+std::string Join(const std::vector<std::string> strings, const char* delim);
+
+/**
+ * @brief Trim
+ * Removes leading and trailing whitespaces from string.
+ *
+ * @param str string to be trimmed
+ */
+void Trim(std::string& str);
+
+/**
+ * @brief Split
+ * Splits string into substrings using given delimiter.
+ *
+ * @param tokens output vector of substrings
+ * @param str string to be split
+ * @param delim delimiter
+ */
+void Split(std::vector<std::string>& tokens, const std::string& str,
+ const char delim);
+
} // namespace utils
} // namespace parser
#include "manifest_parser/utils/version_number.h"
-#include <boost/algorithm/string/classification.hpp>
-#include <boost/algorithm/string/join.hpp>
-#include <boost/algorithm/string/split.hpp>
-#include <boost/algorithm/string/trim.hpp>
-
#include <algorithm>
#include <cstdlib>
+#include <string>
+#include <vector>
#include "manifest_parser/utils/logging.h"
+#include "manifest_parser/utils/string_util.h"
namespace {
} // namespace
-namespace ba = boost::algorithm;
-
namespace utils {
VersionNumber::VersionNumber(const std::string& str) {
std::string number = str;
- ba::trim(number);
+ parser::utils::Trim(number);
std::vector<std::string> tokens;
- try {
- ba::split(tokens, number, ba::is_any_of("."));
- } catch (const boost::exception& /*exc*/) {
- LOG(ERROR) << "boost::algorithm::split failed";
- return;
- }
+ parser::utils::Split(tokens, number, '.');
for (auto& token : tokens) {
char* end = nullptr;
int value = strtol(token.c_str(), &end, 10);
std::vector<std::string> strings;
std::transform(parts_.begin(), parts_.end(), std::back_inserter(strings),
static_cast<std::string(*)(int)>(&std::to_string));
- return ba::join(strings, ".");
+ return parser::utils::Join(strings, ".");
}
bool VersionNumber::IsValidTizenPackageVersion() const {
#include "manifest_parser/utils/w3c_languages.h"
-#include <boost/filesystem.hpp>
#include <algorithm>
+#include <filesystem>
#include <fstream>
#include <vector>
#include "manifest_parser/utils/logging.h"
-namespace bf = boost::filesystem;
+namespace fs = std::filesystem;
namespace {
-const bf::path kLanguagesFile =
- bf::path(SHAREDIR)
+const fs::path kLanguagesFile =
+ fs::path(SHAREDIR)
/ "manifest-parser/languages-only.txt";
const int kLanguagesNumber = 8094;
bool InitializeLanguageSet() {
if (!w3c_languages.empty())
return true;
- if (!bf::exists(kLanguagesFile)) {
+ if (!fs::exists(kLanguagesFile)) {
LOG(ERROR) << "File does not exist";
return false;
}
#include "manifest_parser/values.h"
-#include <boost/regex.hpp>
#include <string.h>
#include <algorithm>
FOREACH(test ${TESTS})
APPLY_PKG_CONFIG(${test} PUBLIC
- Boost
GTEST
)
ENDFOREACH(test)
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE-xwalk file.
-#include <boost/filesystem/path.hpp>
#include <gtest/gtest.h>
+#include <filesystem>
#include <memory>
#include <string>
#include <vector>
namespace parser {
-namespace bf = boost::filesystem;
+namespace fs = std::filesystem;
class ManifestHandlerTest : public testing::Test {
public:
// Use of this source code is governed by an apache 2.0 license that can be
// found in the LICENSE file.
-#include <boost/filesystem/path.hpp>
#include <gtest/gtest.h>
+#include <filesystem>
#include <utility>
#include "manifest_parser/manifest_parser.h"
-namespace bf = boost::filesystem;
+namespace fs = std::filesystem;
namespace wgt {
namespace parse {
// Tests manifest parser with proper manifest
TEST_F(ParseManifestTest, HandlesProperManifestFile) {
- bf::path path =
+ fs::path path =
"/usr/share/manifest-parser-ut/test_samples/good_manifest.xml";
std::vector<std::shared_ptr<parser::ManifestHandler>> handlers = {
std::make_shared<wgt::parse::TizenApplicationHandler>(),
// Tests manifest parser with broken manifest
TEST_F(ParseManifestTest, HandlesBrokenManifestFile) {
- bf::path path = "/usr/share/manifest-parser-ut/test_samples/bad_manifest.xml";
+ fs::path path = "/usr/share/manifest-parser-ut/test_samples/bad_manifest.xml";
std::vector<std::shared_ptr<parser::ManifestHandler>> handlers = {
std::make_shared<wgt::parse::TizenApplicationHandler>(),
};