parent
0ef77132a0
commit
f7a33bbeb0
|
@ -27,11 +27,11 @@
|
||||||
|
|
||||||
#include "common/system/system.h"
|
#include "common/system/system.h"
|
||||||
|
|
||||||
|
#include <boost/property_tree/ini_parser.hpp>
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <boost/property_tree/ini_parser.hpp>
|
|
||||||
#include <boost/regex.hpp>
|
|
||||||
|
|
||||||
namespace bp = boost::property_tree;
|
namespace bp = boost::property_tree;
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,6 @@
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <boost/property_tree/ini_parser.hpp>
|
#include <boost/property_tree/ini_parser.hpp>
|
||||||
#include <boost/regex.hpp>
|
|
||||||
|
|
||||||
namespace bp = boost::property_tree;
|
namespace bp = boost::property_tree;
|
||||||
|
|
||||||
|
|
|
@ -26,16 +26,16 @@ static std::string FormatAssertRegexMatchError(const std::string& text,
|
||||||
}
|
}
|
||||||
|
|
||||||
RegexUtils::CAssertRegexMatchError::CAssertRegexMatchError(
|
RegexUtils::CAssertRegexMatchError::CAssertRegexMatchError(
|
||||||
const std::string& text, const std::string& pattern) NOEXCEPT
|
const std::string& text, const std::string& pattern) noexcept
|
||||||
: std::runtime_error(FormatAssertRegexMatchError(text, pattern))
|
: std::runtime_error(FormatAssertRegexMatchError(text, pattern))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::smatch RegexUtils::AssertRegexMatch(const std::string& text, const std::string& pattern)
|
std::smatch RegexUtils::AssertRegexMatch(const std::string& text, const std::string& pattern)
|
||||||
{
|
{
|
||||||
boost::regex regex(pattern);
|
std::regex regex(pattern);
|
||||||
boost::smatch matches;
|
std::smatch matches;
|
||||||
bool ok = boost::regex_match(text, matches, regex);
|
bool ok = std::regex_match(text, matches, regex);
|
||||||
if (!ok)
|
if (!ok)
|
||||||
throw CAssertRegexMatchError(text, pattern);
|
throw CAssertRegexMatchError(text, pattern);
|
||||||
|
|
||||||
|
|
|
@ -20,8 +20,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
#include <regex>
|
||||||
#include <boost/regex.hpp>
|
|
||||||
|
|
||||||
namespace RegexUtils
|
namespace RegexUtils
|
||||||
{
|
{
|
||||||
|
@ -30,10 +29,10 @@ class CAssertRegexMatchError : public std::runtime_error
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit CAssertRegexMatchError(const std::string& text,
|
explicit CAssertRegexMatchError(const std::string& text,
|
||||||
const std::string& pattern) NOEXCEPT;
|
const std::string& pattern) noexcept;
|
||||||
};
|
};
|
||||||
|
|
||||||
//! Match string with regex and return list of matches; throw exception on mismatch
|
//! Match string with regex and return list of matches; throw exception on mismatch
|
||||||
boost::smatch AssertRegexMatch(const std::string& text, const std::string& pattern);
|
std::smatch AssertRegexMatch(const std::string& text, const std::string& pattern);
|
||||||
|
|
||||||
} // namespace RegexUtils
|
} // namespace RegexUtils
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
|
|
||||||
#include <physfs.h>
|
#include <physfs.h>
|
||||||
|
|
||||||
#include <boost/regex.hpp>
|
#include <regex>
|
||||||
|
|
||||||
|
|
||||||
CResourceManager::CResourceManager(const char *argv0)
|
CResourceManager::CResourceManager(const char *argv0)
|
||||||
|
@ -57,7 +57,7 @@ CResourceManager::~CResourceManager()
|
||||||
|
|
||||||
std::string CResourceManager::CleanPath(const std::filesystem::path& path)
|
std::string CResourceManager::CleanPath(const std::filesystem::path& path)
|
||||||
{
|
{
|
||||||
return boost::regex_replace(path.generic_u8string(), boost::regex("(.*)/\\.\\./"), "");
|
return std::regex_replace(path.generic_u8string(), std::regex("(.*)/\\.\\./"), "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,6 @@
|
||||||
#include "object/object_type.h"
|
#include "object/object_type.h"
|
||||||
|
|
||||||
#include <SDL_keyboard.h>
|
#include <SDL_keyboard.h>
|
||||||
#include <boost/regex.hpp>
|
|
||||||
|
|
||||||
#include <libintl.h>
|
#include <libintl.h>
|
||||||
|
|
||||||
|
|
|
@ -36,11 +36,11 @@
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
#include <regex>
|
||||||
|
|
||||||
#include <boost/algorithm/string/trim.hpp>
|
#include <boost/algorithm/string/trim.hpp>
|
||||||
#include <boost/algorithm/string/replace.hpp>
|
#include <boost/algorithm/string/replace.hpp>
|
||||||
#include <boost/lexical_cast.hpp>
|
#include <boost/lexical_cast.hpp>
|
||||||
#include <boost/regex.hpp>
|
|
||||||
|
|
||||||
CLevelParser::CLevelParser()
|
CLevelParser::CLevelParser()
|
||||||
{
|
{
|
||||||
|
@ -174,9 +174,9 @@ void CLevelParser::Load()
|
||||||
// ignore comments
|
// ignore comments
|
||||||
size_t pos = 0;
|
size_t pos = 0;
|
||||||
std::string linesuffix = line;
|
std::string linesuffix = line;
|
||||||
boost::regex commentRegex{ R"(("[^"]*")|('[^']*')|(//.*$))" };
|
std::regex commentRegex{ R"(("[^"]*")|('[^']*')|(//.*$))" };
|
||||||
boost::smatch matches;
|
std::smatch matches;
|
||||||
while (boost::regex_search(linesuffix, matches, commentRegex))
|
while (std::regex_search(linesuffix, matches, commentRegex))
|
||||||
{
|
{
|
||||||
if (matches[3].matched)
|
if (matches[3].matched)
|
||||||
{
|
{
|
||||||
|
|
|
@ -47,10 +47,7 @@
|
||||||
#include "ui/controls/interface.h"
|
#include "ui/controls/interface.h"
|
||||||
#include "ui/controls/window.h"
|
#include "ui/controls/window.h"
|
||||||
|
|
||||||
|
#include <regex>
|
||||||
#include <boost/regex.hpp>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Object's constructor.
|
// Object's constructor.
|
||||||
|
|
||||||
|
@ -410,12 +407,12 @@ bool CAutoFactory::EventProcess(const Event &event)
|
||||||
{
|
{
|
||||||
Program* program = dynamic_cast<CProgramStorageObject&>(*vehicle).AddProgram();
|
Program* program = dynamic_cast<CProgramStorageObject&>(*vehicle).AddProgram();
|
||||||
|
|
||||||
if (boost::regex_match(m_program, boost::regex("[A-Za-z0-9_]+"))) // Public function name?
|
if (std::regex_match(m_program, std::regex("[A-Za-z0-9_]+"))) // Public function name?
|
||||||
{
|
{
|
||||||
std::string code = "extern void object::Start_"+m_program+"()\n{\n\t\n\t//Automatically generated by object.factory()\n\t"+m_program+"();\n\t\n}\n";
|
std::string code = "extern void object::Start_"+m_program+"()\n{\n\t\n\t//Automatically generated by object.factory()\n\t"+m_program+"();\n\t\n}\n";
|
||||||
program->script->SendScript(code.c_str());
|
program->script->SendScript(code.c_str());
|
||||||
}
|
}
|
||||||
else if (boost::regex_match(m_program, boost::regex(".*\\.txt"))) // File name (with .txt extension)?
|
else if (std::regex_match(m_program, std::regex(".*\\.txt"))) // File name (with .txt extension)?
|
||||||
{
|
{
|
||||||
program->script->ReadScript(m_program.c_str());
|
program->script->ReadScript(m_program.c_str());
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,10 +46,11 @@
|
||||||
|
|
||||||
#include "ui/controls/edit.h"
|
#include "ui/controls/edit.h"
|
||||||
|
|
||||||
|
#include <boost/lexical_cast.hpp>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <boost/regex.hpp>
|
#include <regex>
|
||||||
#include <boost/lexical_cast.hpp>
|
|
||||||
|
|
||||||
CProgramStorageObjectImpl::CProgramStorageObjectImpl(ObjectInterfaceTypes& types, CObject* object)
|
CProgramStorageObjectImpl::CProgramStorageObjectImpl(ObjectInterfaceTypes& types, CObject* object)
|
||||||
: CProgramStorageObject(types),
|
: CProgramStorageObject(types),
|
||||||
|
@ -233,11 +234,11 @@ void CProgramStorageObjectImpl::SaveAllUserPrograms(const std::string& userSourc
|
||||||
|
|
||||||
std::string dir = userSource.substr(0, userSource.find_last_of("/"));
|
std::string dir = userSource.substr(0, userSource.find_last_of("/"));
|
||||||
std::string file = userSource.substr(userSource.find_last_of("/")+1) + StrUtils::Format("%.3d([0-9]{3})\\.txt", m_programStorageIndex);
|
std::string file = userSource.substr(userSource.find_last_of("/")+1) + StrUtils::Format("%.3d([0-9]{3})\\.txt", m_programStorageIndex);
|
||||||
boost::regex regex(file);
|
std::regex regex(file);
|
||||||
for (const std::string& filename : CResourceManager::ListFiles(dir))
|
for (const std::string& filename : CResourceManager::ListFiles(dir))
|
||||||
{
|
{
|
||||||
boost::smatch matches;
|
std::smatch matches;
|
||||||
if (boost::regex_match(filename, matches, regex))
|
if (std::regex_match(filename, matches, regex))
|
||||||
{
|
{
|
||||||
unsigned int id = boost::lexical_cast<unsigned int>(matches[1]);
|
unsigned int id = boost::lexical_cast<unsigned int>(matches[1]);
|
||||||
if (id >= m_program.size() || !m_program[id]->filename.empty())
|
if (id >= m_program.size() || !m_program[id]->filename.empty())
|
||||||
|
@ -296,11 +297,11 @@ void CProgramStorageObjectImpl::LoadAllProgramsForLevel(CLevelParserLine* levelS
|
||||||
|
|
||||||
std::string dir = userSource.substr(0, userSource.find_last_of("/"));
|
std::string dir = userSource.substr(0, userSource.find_last_of("/"));
|
||||||
std::string file = userSource.substr(userSource.find_last_of("/")+1) + StrUtils::Format("%.3d([0-9]{3})\\.txt", m_programStorageIndex);
|
std::string file = userSource.substr(userSource.find_last_of("/")+1) + StrUtils::Format("%.3d([0-9]{3})\\.txt", m_programStorageIndex);
|
||||||
boost::regex regex(file);
|
std::regex regex(file);
|
||||||
for (const std::string& filename : CResourceManager::ListFiles(dir))
|
for (const std::string& filename : CResourceManager::ListFiles(dir))
|
||||||
{
|
{
|
||||||
boost::smatch matches;
|
std::smatch matches;
|
||||||
if (boost::regex_match(filename, matches, regex))
|
if (std::regex_match(filename, matches, regex))
|
||||||
{
|
{
|
||||||
unsigned int i = boost::lexical_cast<unsigned int>(matches[1]);
|
unsigned int i = boost::lexical_cast<unsigned int>(matches[1]);
|
||||||
Program* program = GetOrAddProgram(i);
|
Program* program = GetOrAddProgram(i);
|
||||||
|
@ -341,11 +342,11 @@ void CProgramStorageObjectImpl::SaveAllProgramsForSavedScene(CLevelParserLine* l
|
||||||
levelSourceLine->AddParam("scriptRunnable" + StrUtils::ToString<int>(i+1), std::make_unique<CLevelParserParam>(m_program[i]->runnable));
|
levelSourceLine->AddParam("scriptRunnable" + StrUtils::ToString<int>(i+1), std::make_unique<CLevelParserParam>(m_program[i]->runnable));
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::regex regex(StrUtils::Format("prog%.3d([0-9]{3})\\.txt", m_programStorageIndex));
|
std::regex regex(StrUtils::Format("prog%.3d([0-9]{3})\\.txt", m_programStorageIndex));
|
||||||
for (const std::string& filename : CResourceManager::ListFiles(levelSource))
|
for (const std::string& filename : CResourceManager::ListFiles(levelSource))
|
||||||
{
|
{
|
||||||
boost::smatch matches;
|
std::smatch matches;
|
||||||
if (boost::regex_match(filename, matches, regex))
|
if (std::regex_match(filename, matches, regex))
|
||||||
{
|
{
|
||||||
unsigned int id = boost::lexical_cast<unsigned int>(matches[1]);
|
unsigned int id = boost::lexical_cast<unsigned int>(matches[1]);
|
||||||
if (id >= m_program.size() || !m_program[id]->filename.empty())
|
if (id >= m_program.size() || !m_program[id]->filename.empty())
|
||||||
|
|
|
@ -144,7 +144,7 @@ const std::vector<ExchangePostInfo>& CExchangePost::GetInfoList()
|
||||||
return m_infoList;
|
return m_infoList;
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::optional<float> CExchangePost::GetInfoValue(const std::string& name)
|
std::optional<float> CExchangePost::GetInfoValue(const std::string& name)
|
||||||
{
|
{
|
||||||
for (auto& info : m_infoList)
|
for (auto& info : m_infoList)
|
||||||
{
|
{
|
||||||
|
@ -153,7 +153,7 @@ boost::optional<float> CExchangePost::GetInfoValue(const std::string& name)
|
||||||
return info.value;
|
return info.value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return boost::none;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CExchangePost::HasInfo(const std::string& name)
|
bool CExchangePost::HasInfo(const std::string& name)
|
||||||
|
|
|
@ -24,11 +24,10 @@
|
||||||
|
|
||||||
#include "object/auto/auto.h"
|
#include "object/auto/auto.h"
|
||||||
|
|
||||||
|
#include <optional>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <boost/optional.hpp>
|
|
||||||
|
|
||||||
struct ExchangePostInfo
|
struct ExchangePostInfo
|
||||||
{
|
{
|
||||||
std::string name; //!< name of the information
|
std::string name; //!< name of the information
|
||||||
|
@ -57,7 +56,7 @@ public:
|
||||||
|
|
||||||
bool SetInfo(const std::string& name, float value);
|
bool SetInfo(const std::string& name, float value);
|
||||||
const std::vector<ExchangePostInfo>& GetInfoList();
|
const std::vector<ExchangePostInfo>& GetInfoList();
|
||||||
boost::optional<float> GetInfoValue(const std::string& name);
|
std::optional<float> GetInfoValue(const std::string& name);
|
||||||
bool HasInfo(const std::string& name);
|
bool HasInfo(const std::string& name);
|
||||||
bool DeleteInfo(const std::string& name);
|
bool DeleteInfo(const std::string& name);
|
||||||
|
|
||||||
|
|
|
@ -26,11 +26,10 @@
|
||||||
|
|
||||||
#include "CBot/CBot.h"
|
#include "CBot/CBot.h"
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
#include <memory>
|
||||||
|
#include <optional>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <boost/optional.hpp>
|
|
||||||
|
|
||||||
|
|
||||||
class COldObject;
|
class COldObject;
|
||||||
class CTaskExecutorObject;
|
class CTaskExecutorObject;
|
||||||
|
@ -128,5 +127,5 @@ protected:
|
||||||
CBot::CBotError m_error = CBot::CBotNoErr; // error (0=ok)
|
CBot::CBotError m_error = CBot::CBotNoErr; // error (0=ok)
|
||||||
int m_cursor1 = 0;
|
int m_cursor1 = 0;
|
||||||
int m_cursor2 = 0;
|
int m_cursor2 = 0;
|
||||||
boost::optional<float> m_returnValue = boost::none;
|
std::optional<float> m_returnValue = std::nullopt;
|
||||||
};
|
};
|
||||||
|
|
|
@ -2336,7 +2336,7 @@ bool CScriptFunctions::rReceive(CBotVar* var, CBotVar* result, int& exception, v
|
||||||
}
|
}
|
||||||
if ( !WaitForForegroundTask(script, result, exception) ) return false; // not finished
|
if ( !WaitForForegroundTask(script, result, exception) ) return false; // not finished
|
||||||
|
|
||||||
if ( script->m_returnValue == boost::none )
|
if ( !script->m_returnValue.has_value() )
|
||||||
{
|
{
|
||||||
result->SetValFloat(nanf(""));
|
result->SetValFloat(nanf(""));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue