Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
fintarin committed Apr 8, 2024
1 parent ff8d790 commit 45a4a6c
Show file tree
Hide file tree
Showing 19 changed files with 43 additions and 43 deletions.
2 changes: 1 addition & 1 deletion include/fintamath/config/Config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace fintamath::detail {

struct Config final {
Config();
Config() noexcept;
};

}
4 changes: 2 additions & 2 deletions include/fintamath/core/Converter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Converter final {
using ConverterMultiMethod = MultiMethod<std::unique_ptr<IMathObject>(const IMathObject &, const IMathObject &)>;

public:
static std::unique_ptr<IMathObject> convert(const IMathObject &to, const IMathObject &from) {
static std::unique_ptr<IMathObject> convert(const IMathObject &to, const IMathObject &from) noexcept {
return getConverter()(to, from);
}

Expand All @@ -33,7 +33,7 @@ class Converter final {
}

private:
static ConverterMultiMethod &getConverter();
static ConverterMultiMethod &getConverter() noexcept;
};

}
Expand Down
18 changes: 9 additions & 9 deletions include/fintamath/core/MultiMethod.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,6 @@ class MultiMethod<Res(ArgsBase...)> final {
using IdToCallbackMap = std::unordered_map<CallbackId, Callback, Hash<CallbackId>>;

public:
template <typename... Args>
requires(sizeof...(Args) == sizeof...(ArgsBase))
void add(const auto &func) {
idToCallbackMap[CallbackId(Args::getClassStatic()...)] = [func](const ArgsBase &...args) {
return func(cast<Args>(args)...);
};
}

template <typename... Args>
requires(sizeof...(Args) == sizeof...(ArgsBase))
Res operator()(Args &&...args) const {
Expand All @@ -45,10 +37,18 @@ class MultiMethod<Res(ArgsBase...)> final {

template <typename... Args>
requires(sizeof...(Args) == sizeof...(ArgsBase))
bool contains(const Args &...args) const {
bool contains(const Args &...args) const noexcept {
return idToCallbackMap.contains(CallbackId(args.getClass()...));
}

template <typename... Args>
requires(sizeof...(Args) == sizeof...(ArgsBase))
void add(const auto &func) noexcept {
idToCallbackMap[CallbackId(Args::getClassStatic()...)] = [func](const ArgsBase &...args) {
return func(cast<Args>(args)...);
};
}

private:
IdToCallbackMap idToCallbackMap;
};
Expand Down
2 changes: 1 addition & 1 deletion include/fintamath/core/None.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace fintamath {

struct None {
static constexpr MathObjectClass getClassStatic() {
static constexpr MathObjectClass getClassStatic() noexcept {
return nullptr;
}
};
Expand Down
12 changes: 6 additions & 6 deletions include/fintamath/core/Parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class Parser final {
using GeneratorConstructorVector = std::vector<GeneratorConstructor>;

public:
Generator parse(std::string str) const {
Generator parse(std::string str) const noexcept {
if (const auto stringToConstructors = stringToConstructorsMap.find(str); stringToConstructors != stringToConstructorsMap.end()) {
for (const auto &constructor : stringToConstructors->second) {
co_yield constructor();
Expand All @@ -57,7 +57,7 @@ class Parser final {
}
}

std::optional<Return> parseFirst(std::string str) const {
std::optional<Return> parseFirst(std::string str) const noexcept {
auto gener = parse(std::move(str));

if (auto iter = gener.begin(); iter != gener.end()) {
Expand All @@ -69,7 +69,7 @@ class Parser final {

template <typename Type>
requires(!std::is_abstract_v<Type> && !StringConstructable<Type> && EmptyConstructable<Type>)
void registerType() {
void registerType() noexcept {
static const std::string name = Type{}.toString();

stringToConstructorsMap[name].emplace_back([]() -> Return {
Expand All @@ -81,7 +81,7 @@ class Parser final {

template <typename Type>
requires(!std::is_abstract_v<Type> && StringConstructable<Type>)
void registerType() {
void registerType() noexcept {
generatorConstructors.emplace_back([](std::string str) -> Generator {
try {
co_yield std::make_unique<Type>(std::move(str));
Expand All @@ -94,7 +94,7 @@ class Parser final {

template <typename Type>
requires(std::is_abstract_v<Type>)
void registerType() {
void registerType() noexcept {
generatorConstructors.emplace_back([](std::string str) -> Generator {
for (auto &value : Type::parse(std::move(str))) {
co_yield std::move(value);
Expand All @@ -103,7 +103,7 @@ class Parser final {
}

template <typename Type>
void registerType() const {
void registerType() const noexcept {
// No object of this type can be constructed
}

Expand Down
4 changes: 2 additions & 2 deletions include/fintamath/core/Tokenizer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Tokenizer final {
public:
static TokenVector tokenize(std::string str);

static void registerToken(const Token &token);
static void registerToken(const Token &token) noexcept;

private:
static bool appendToken(TokenVector &tokens, Token &token, bool shouldSplit = false);
Expand All @@ -23,7 +23,7 @@ class Tokenizer final {

static bool isSpace(char ch);

static TokenVector &getRegisteredTokens();
static TokenVector &getRegisteredTokens() noexcept;
};

}
10 changes: 5 additions & 5 deletions include/fintamath/exceptions/InvalidInputException.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ namespace fintamath {

class InvalidInputException : public Exception {
public:
InvalidInputException() = default;
InvalidInputException() noexcept = default;

explicit InvalidInputException(const std::string &input) {
explicit InvalidInputException(const std::string &input) noexcept {
content += ": " + input;
}

Expand All @@ -26,7 +26,7 @@ class InvalidInputException : public Exception {

class InvalidInputFunctionException final : public InvalidInputException {
public:
explicit InvalidInputFunctionException(const std::string &func, const std::vector<std::string> &argVect) {
explicit InvalidInputFunctionException(const std::string &func, const std::vector<std::string> &argVect) noexcept {
content += ": " + func + "(";

if (!argVect.empty()) {
Expand All @@ -47,7 +47,7 @@ class InvalidInputFunctionException final : public InvalidInputException {

class InvalidInputBinaryOperatorException final : public InvalidInputException {
public:
explicit InvalidInputBinaryOperatorException(const std::string &oper, const std::string &lhs, const std::string &rhs) {
explicit InvalidInputBinaryOperatorException(const std::string &oper, const std::string &lhs, const std::string &rhs) noexcept {
content += ": (" + lhs + ")" + oper + "(" + rhs + ")";
}
};
Expand All @@ -60,7 +60,7 @@ class InvalidInputUnaryOperatorException final : public InvalidInputException {
};

public:
explicit InvalidInputUnaryOperatorException(const std::string &oper, const std::string &rhs, const Type type) {
explicit InvalidInputUnaryOperatorException(const std::string &oper, const std::string &rhs, const Type type) noexcept {
switch (type) {
case Type::Prefix:
content += ": " + oper + "(" + rhs + ")";
Expand Down
10 changes: 5 additions & 5 deletions include/fintamath/exceptions/UndefinedException.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ namespace fintamath {

class UndefinedException : public Exception {
public:
UndefinedException() = default;
UndefinedException() noexcept = default;

explicit UndefinedException(const std::string &input) {
explicit UndefinedException(const std::string &input) noexcept {
content += ": " + input;
}

Expand All @@ -26,7 +26,7 @@ class UndefinedException : public Exception {

class UndefinedFunctionException final : public UndefinedException {
public:
explicit UndefinedFunctionException(const std::string &func, const std::vector<std::string> &argVect) {
explicit UndefinedFunctionException(const std::string &func, const std::vector<std::string> &argVect) noexcept {
content += ": " + func + "(";

if (!argVect.empty()) {
Expand All @@ -47,7 +47,7 @@ class UndefinedFunctionException final : public UndefinedException {

class UndefinedBinaryOperatorException final : public UndefinedException {
public:
explicit UndefinedBinaryOperatorException(const std::string &oper, const std::string &lhs, const std::string &rhs) {
explicit UndefinedBinaryOperatorException(const std::string &oper, const std::string &lhs, const std::string &rhs) noexcept {
content += ": (" + lhs + ")" + oper + "(" + rhs + ")";
}
};
Expand All @@ -60,7 +60,7 @@ class UndefinedUnaryOperatorException final : public UndefinedException {
};

public:
explicit UndefinedUnaryOperatorException(const std::string &oper, const std::string &rhs, const Type type) {
explicit UndefinedUnaryOperatorException(const std::string &oper, const std::string &rhs, const Type type) noexcept {
switch (type) {
case Type::Prefix:
content += ": " + oper + "(" + rhs + ")";
Expand Down
2 changes: 1 addition & 1 deletion src/fintamath/config/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace fintamath::detail {

Config::Config() {
Config::Config() noexcept {
[[maybe_unused]] static const TypeConfig typeConfig;
[[maybe_unused]] static const PrecisionConfig precisionConfig;
[[maybe_unused]] static const ConverterConfig converterConfig;
Expand Down
2 changes: 1 addition & 1 deletion src/fintamath/config/ConverterConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

namespace fintamath::detail {

ConverterConfig::ConverterConfig() {
ConverterConfig::ConverterConfig() noexcept {
Converter::add<Integer, Integer>([](const Integer & /*type*/, const Integer &value) {
return Integer(value).clone();
});
Expand Down
2 changes: 1 addition & 1 deletion src/fintamath/config/ConverterConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace fintamath::detail {

struct ConverterConfig final {
ConverterConfig();
ConverterConfig() noexcept;
};

}
2 changes: 1 addition & 1 deletion src/fintamath/config/ExpressionConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@

namespace fintamath::detail {

ExpressionConfig::ExpressionConfig() {
ExpressionConfig::ExpressionConfig() noexcept {
Expression::registerExpressionConstructor<Add>([](ArgumentPtrVector &&args) {
return AddExpr(std::move(args)).clone();
});
Expand Down
2 changes: 1 addition & 1 deletion src/fintamath/config/ExpressionConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace fintamath::detail {

struct ExpressionConfig final {
ExpressionConfig();
ExpressionConfig() noexcept;
};

}
2 changes: 1 addition & 1 deletion src/fintamath/config/PrecisionConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace fintamath::detail {

PrecisionConfig::PrecisionConfig() {
PrecisionConfig::PrecisionConfig() noexcept{
constexpr unsigned defaultPrecision = 20;
Real::setPrecision(defaultPrecision);
}
Expand Down
2 changes: 1 addition & 1 deletion src/fintamath/config/PrecisionConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace fintamath::detail {

struct PrecisionConfig final {
PrecisionConfig();
PrecisionConfig() noexcept;
};

}
2 changes: 1 addition & 1 deletion src/fintamath/config/TypeConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@

namespace fintamath::detail {

TypeConfig::TypeConfig() {
TypeConfig::TypeConfig() noexcept {
IMathObject::registerType<IArithmetic>();
IMathObject::registerType<IFunction>();
IMathObject::registerType<ILiteral>();
Expand Down
2 changes: 1 addition & 1 deletion src/fintamath/config/TypeConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace fintamath::detail {

struct TypeConfig final {
TypeConfig();
TypeConfig() noexcept;
};

}
2 changes: 1 addition & 1 deletion src/fintamath/core/Converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace fintamath::detail {

Converter::ConverterMultiMethod &Converter::getConverter() {
Converter::ConverterMultiMethod &Converter::getConverter() noexcept {
static ConverterMultiMethod converter;
return converter;
}
Expand Down
4 changes: 2 additions & 2 deletions src/fintamath/core/Tokenizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ TokenVector Tokenizer::tokenize(std::string str) {
return tokens;
}

void Tokenizer::registerToken(const Token &token) {
void Tokenizer::registerToken(const Token &token) noexcept {
auto &tokens = getRegisteredTokens();
tokens.insert(std::ranges::upper_bound(tokens, token, [](const Token &lhs, const Token &rhs) {
return lhs.size() > rhs.size();
Expand Down Expand Up @@ -98,7 +98,7 @@ bool Tokenizer::isSpace(const char ch) {
return ch == ' ';
}

TokenVector &Tokenizer::getRegisteredTokens() {
TokenVector &Tokenizer::getRegisteredTokens() noexcept {
static TokenVector registeredTokens;
return registeredTokens;
}
Expand Down

0 comments on commit 45a4a6c

Please sign in to comment.