Skip to content

Commit

Permalink
Merge pull request #17 from ReCodEx/modernization
Browse files Browse the repository at this point in the history
Modernization
  • Loading branch information
SemaiCZE authored Jun 28, 2018
2 parents beb1a78 + cad570a commit 134ef2d
Show file tree
Hide file tree
Showing 107 changed files with 664 additions and 707 deletions.
39 changes: 22 additions & 17 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,23 @@ include_directories(${CURL_INCLUDE_DIRS})
# -- Yaml-cpp
# find the yaml-cpp include directory
find_path(YAMLCPP_INCLUDE_DIR yaml-cpp/yaml.h
PATH_SUFFIXES include
PATHS
~/Library/Frameworks/yaml-cpp/include/
/Library/Frameworks/yaml-cpp/include/
/usr/local/include/
/usr/include/
/sw/yaml-cpp/ # Fink
/opt/local/yaml-cpp/ # DarwinPorts
/opt/csw/yaml-cpp/ # Blastwave
/opt/yaml-cpp/
${YAMLCPP_DIR}/include/)
PATH_SUFFIXES include
PATHS
~/Library/Frameworks/yaml-cpp/include/
/Library/Frameworks/yaml-cpp/include/
/usr/local/include/
/usr/include/
/sw/yaml-cpp/ # Fink
/opt/local/yaml-cpp/ # DarwinPorts
/opt/csw/yaml-cpp/ # Blastwave
/opt/yaml-cpp/
${YAMLCPP_DIR}/include/)

# find the yaml-cpp library
find_library(YAMLCPP_LIBRARY
NAMES ${YAMLCPP_STATIC} yaml-cpp
PATH_SUFFIXES lib64 lib
PATHS ~/Library/Frameworks
NAMES ${YAMLCPP_STATIC} yaml-cpp
PATH_SUFFIXES lib64 lib
PATHS ~/Library/Frameworks
/Library/Frameworks
/usr/local
/usr
Expand Down Expand Up @@ -97,10 +97,10 @@ endif()

# Use C++11
if(UNIX)
#-Wno-deprecated-declarations hides warning in yaml-cpp (using std::auto_ptr)
#-Wno-deprecated-declarations hides warning in yaml-cpp (using std::auto_ptr)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wno-deprecated-declarations")
elseif(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP /D NOMINMAX")
endif()


Expand Down Expand Up @@ -184,6 +184,8 @@ set(SOURCE_FILES
${HELPERS_DIR}/logger.cpp
${HELPERS_DIR}/string_utils.h
${HELPERS_DIR}/string_utils.cpp
${HELPERS_DIR}/type_utils.h
${HELPERS_DIR}/format.h

${CONFIG_DIR}/worker_config.cpp
${CONFIG_DIR}/worker_config.h
Expand Down Expand Up @@ -213,6 +215,8 @@ set(SOURCE_FILES
${COMMAND_DIR}/jobs_client_commands.h
)

include_directories(AFTER, ${SRC_DIR})


add_executable(${EXEC_NAME} ${SOURCE_FILES})

Expand All @@ -238,7 +242,7 @@ if(UNIX)
target_link_libraries(${EXEC_NAME} -lzmq)
target_link_libraries(${EXEC_NAME} pthread)
elseif(MSVC)
target_link_libraries(${EXEC_NAME} ${ZEROMQ_LIB})
target_link_libraries(${EXEC_NAME} ${ZEROMQ_LIB})
endif()


Expand Down Expand Up @@ -326,3 +330,4 @@ add_custom_target(lines
COMMENT "Counting lines"
VERBATIM
)

6 changes: 3 additions & 3 deletions judges/recodex_token_judge/bpplib/algo/lcs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace bpp
* \tparam RES The result type (must be an integral type).
* \tparam CONTAINER Class holding the sequence. The class must have size() method
* and the comparator must be able to get values from the container based on their indices.
* \tparma COMPARATOR Comparator class holds a static method compare(seq1, i1, seq2, i2) -> bool.
* \tparam COMPARATOR Comparator class holds a static method compare(seq1, i1, seq2, i2) -> bool.
* I.e., the comparator is also responsible for fetching values from the seq. containers.
*/
template <typename RES = std::size_t, class CONTAINER, typename COMPARATOR>
Expand All @@ -31,7 +31,7 @@ namespace bpp
const CONTAINER &seq2 = sequence1.size() < sequence2.size() ? sequence1 : sequence2;

std::vector<RES> row((std::size_t) seq2.size());
std::size_t rows = (std::size_t) seq1.size();
auto rows = (std::size_t) seq1.size();

// Dynamic programming - matrix traversal that keeps only the last row.
for (std::size_t r = 0; r < rows; ++r) {
Expand Down Expand Up @@ -65,7 +65,7 @@ namespace bpp
* \tparam RES The result type (must be an integral type).
* \tparam CONTAINER Class holding the sequence. The class must have size() method
* and the comparator must be able to get values from the container based on their indices.
* \tparma COMPARATOR Comparator class holds a static method compare(seq1, i1, seq2, i2) -> bool.
* \tparam COMPARATOR Comparator class holds a static method compare(seq1, i1, seq2, i2) -> bool.
* I.e., the comparator is also responsible for fetching values from the seq. containers.
*/
template <typename IDX = std::size_t, class CONTAINER, typename COMPARATOR>
Expand Down
62 changes: 29 additions & 33 deletions judges/recodex_token_judge/bpplib/cli/args.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ namespace bpp
ArgumentException(const std::string &msg) : RuntimeError(msg)
{
}
virtual ~ArgumentException() throw()
{
}
~ArgumentException() noexcept override = default;

/*
* Overloading << operator that uses stringstream to append data to mMessage.
Expand Down Expand Up @@ -106,26 +104,26 @@ namespace bpp
// Constraint checks are done only if the argument is present.
if (isPresent()) {
// Check for collisions.
for (auto it = mConflictsWith.begin(); it != mConflictsWith.end(); ++it) {
if (arguments.find(*it) == arguments.end())
for (const auto &it : mConflictsWith) {
if (arguments.find(it) == arguments.end())
throw(ArgumentException()
<< "Internal Error: Argument '" << mName << "' has unspecified argument '" << *it
<< "Internal Error: Argument '" << mName << "' has unspecified argument '" << it
<< "' on its collision list.");

if (arguments.find(*it)->second->isPresent())
if (arguments.find(it)->second->isPresent())
throw(ArgumentException()
<< "The argument '" << mName << "' conflicts with argument '" << *it << "'.");
<< "The argument '" << mName << "' conflicts with argument '" << it << "'.");
}

// Check for requirements.
for (auto it = mRequiresAlso.begin(); it != mRequiresAlso.end(); ++it) {
if (arguments.find(*it) == arguments.end())
for (const auto & it : mRequiresAlso) {
if (arguments.find(it) == arguments.end())
throw(ArgumentException()
<< "Internal Error: Argument '" << mName << "' has unspecified argument '" << *it
<< "Internal Error: Argument '" << mName << "' has unspecified argument '" << it
<< "' on its requirements list.");

if (!arguments.find(*it)->second->isPresent())
throw(ArgumentException() << "The argument '" << *it << "' is also required when '" << mName
if (!arguments.find(it)->second->isPresent())
throw(ArgumentException() << "The argument '" << it << "' is also required when '" << mName
<< "' was specified.");
}
}
Expand Down Expand Up @@ -161,9 +159,7 @@ namespace bpp
}

// Enforce virtual destructor for descendants.
virtual ~ArgBase()
{
}
virtual ~ArgBase() = default;


/**
Expand Down Expand Up @@ -242,10 +238,10 @@ namespace bpp
class ArgBool : public ArgBase
{
public:
typedef bool value_t;
using value_t = bool;

protected:
virtual void process(int &, const char **&)
void process(int &, const char **&) override
{
this->mPresent = true;
}
Expand All @@ -269,7 +265,7 @@ namespace bpp
class ArgIntBase : public ArgBase
{
public:
typedef std::int64_t value_t;
using value_t = std::int64_t;

protected:
value_t mMin; ///< Range constraint for the value.
Expand Down Expand Up @@ -350,7 +346,7 @@ namespace bpp
value_t mValue; ///< Parsed value of the argument.

protected:
virtual void process(int &argc, const char **(&argv))
void process(int &argc, const char **(&argv)) override
{
mValue = this->processInt(argc, argv);
this->mPresent = true;
Expand Down Expand Up @@ -379,7 +375,7 @@ namespace bpp

if (getAsUint() > (std::uint64_t) std::numeric_limits<std::size_t>::max())
throw(bpp::ArgumentException()
<< "Unable to convert int argument '" << this->getName() << "' to size_t.");
<< "Unable to convert int argument '" << this->getName() << "' to std::size_t.");
return (std::size_t) mValue;
}

Expand Down Expand Up @@ -420,7 +416,7 @@ namespace bpp
std::vector<value_t> mValues; ///< Parsed values of the argument.

protected:
virtual void process(int &argc, const char **(&argv))
void process(int &argc, const char **(&argv)) override
{
if (!this->mPresent) mValues.clear();

Expand Down Expand Up @@ -479,7 +475,7 @@ namespace bpp
class ArgFloatBase : public ArgBase
{
public:
typedef double value_t;
using value_t = double;

protected:
value_t mMin; ///< Range constraint for the value.
Expand Down Expand Up @@ -548,7 +544,7 @@ namespace bpp
value_t mValue; ///< Parsed value of the argument.

protected:
virtual void process(int &argc, const char **(&argv))
void process(int &argc, const char **(&argv)) override
{
mValue = this->processFloat(argc, argv);
this->mPresent = true;
Expand Down Expand Up @@ -583,7 +579,7 @@ namespace bpp
std::vector<value_t> mValues; ///< Parsed values of the argument.

protected:
virtual void process(int &argc, const char **(&argv))
void process(int &argc, const char **(&argv)) override
{
if (!this->mPresent) mValues.clear();

Expand Down Expand Up @@ -643,12 +639,12 @@ namespace bpp
class ArgString : public ArgBase
{
public:
typedef std::string value_t;
using value_t = std::string;

protected:
std::string mValue; ///< The value of the argument stored after parsing.

virtual void process(int &argc, const char **(&argv))
void process(int &argc, const char **(&argv)) override
{
if (argc == 0)
throw(ArgumentException() << "Value of argument '" << this->getName() << "' is missing!");
Expand Down Expand Up @@ -682,7 +678,7 @@ namespace bpp
class ArgEnum : public ArgString
{
public:
typedef std::string value_t;
using value_t = std::string;

private:
std::string mNormalizedValue;
Expand All @@ -702,7 +698,7 @@ namespace bpp
mOptions.insert(mCaseSensitive ? str : toLower(str));
}

virtual void process(int &argc, const char **(&argv))
void process(int &argc, const char **(&argv)) override
{
ArgString::process(argc, argv);

Expand Down Expand Up @@ -769,7 +765,7 @@ namespace bpp
std::vector<std::string> mValues; ///< The list of values of the argument stored after parsing.

protected:
virtual void process(int &argc, const char **(&argv))
void process(int &argc, const char **(&argv)) override
{
if (argc == 0)
throw(ArgumentException() << "Value of argument '" << this->getName() << "' is missing!");
Expand Down Expand Up @@ -1110,12 +1106,12 @@ namespace bpp
stream << "Usage: " << Path::getFileName(getProgramName()) << std::endl;

stream << "Named arguments:" << std::endl;
for (auto it = mArguments.begin(); it != mArguments.end(); ++it) {
stream << " " << it->first << " - " << it->second->getComment() << std::endl;
for (const auto &mArgument : mArguments) {
stream << " " << mArgument.first << " - " << mArgument.second->getComment() << std::endl;
}

stream << "Nameless arguments (" << mNamelessMin << ", " << mNamelessMax << "):";
for (std::size_t i = 0; i < mNamelessCaptions.size(); ++i) { stream << " " << mNamelessCaptions[i]; }
for (const auto &mNamelessCaption : mNamelessCaptions) { stream << " " << mNamelessCaption; }
stream << std::endl;
}
};
Expand Down
6 changes: 3 additions & 3 deletions judges/recodex_token_judge/bpplib/cli/logger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ namespace bpp
std::size_t applySizeLimit(LogSeverity &severity)
{
std::size_t total = 0;
for (std::size_t i = (std::size_t) LogSeverity::UNDEFINED; i < (std::size_t) severity; ++i) {
for (auto i = (std::size_t) LogSeverity::UNDEFINED; i < (std::size_t) severity; ++i) {
total += mLengths[(LogSeverity) i];
if (total >= mMaxLength) { // max log length would be exceeded including current severity into output
severity = (LogSeverity) i;
Expand Down Expand Up @@ -215,8 +215,8 @@ namespace bpp
std::size_t size(LogSeverity severity = LogSeverity::ANY) const
{
std::size_t size = 0;
for (std::size_t i = (std::size_t) LogSeverity::UNDEFINED; i <= (std::size_t) severity; ++i) {
LogSeverity s = (LogSeverity) i;
for (auto i = (std::size_t) LogSeverity::UNDEFINED; i <= (std::size_t) severity; ++i) {
auto s = (LogSeverity) i;
auto it = mLengths.find(s);
if (it != mLengths.end()) { size += it->second; }

Expand Down
20 changes: 5 additions & 15 deletions judges/recodex_token_judge/bpplib/misc/exception.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,9 @@ namespace bpp
StreamException(const std::string &msg) : std::exception(), mMessage(msg)
{
}
virtual ~StreamException() throw()
{
}
~StreamException() noexcept override = default;

virtual const char *what() const throw()
const char *what() const noexcept override
{
return mMessage.c_str();
}
Expand Down Expand Up @@ -68,9 +66,7 @@ namespace bpp
RuntimeError(const std::string &msg) : StreamException(msg)
{
}
virtual ~RuntimeError() throw()
{
}
~RuntimeError() noexcept override = default;


// Overloading << operator that uses stringstream to append data to mMessage.
Expand Down Expand Up @@ -102,10 +98,7 @@ namespace bpp
LogicError(const std::string &msg) : RuntimeError(msg)
{
}
virtual ~LogicError() throw()
{
}

~LogicError() noexcept override = default;

// Overloading << operator that uses stringstream to append data to mMessage.
template <typename T> LogicError &operator<<(const T &data)
Expand Down Expand Up @@ -133,10 +126,7 @@ namespace bpp
NotImplementedError(const std::string &msg) : RuntimeError(msg)
{
}
virtual ~NotImplementedError() throw()
{
}

~NotImplementedError() noexcept override = default;

// Overloading << operator that uses stringstream to append data to mMessage.
template <typename T> NotImplementedError &operator<<(const T &data)
Expand Down
6 changes: 2 additions & 4 deletions judges/recodex_token_judge/bpplib/system/filesystem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ namespace bpp
FileError(const std::string &msg) : RuntimeError(msg)
{
}
virtual ~FileError() throw()
{
}
~FileError() noexcept override = default;


// Overloading << operator that uses stringstream to append data to mMessage.
Expand Down Expand Up @@ -75,7 +73,7 @@ namespace bpp
*/
static std::string getFileName(const std::string &path)
{
size_t pos = path.find_last_of("/\\");
std::size_t pos = path.find_last_of("/\\");
return (pos != std::string::npos) ? path.substr(pos + 1) : path;
}

Expand Down
Loading

0 comments on commit 134ef2d

Please sign in to comment.