From 5f78556078d2e61d5c0ef44e36d58f3864cd84d1 Mon Sep 17 00:00:00 2001 From: Alexis Hildebrandt Date: Wed, 12 Apr 2023 11:14:08 +0200 Subject: Refactor basic_flags_t to ledger::flags::basic_t --- flake.nix | 3 ++- src/account.h | 2 +- src/amount.cc | 2 +- src/amount.h | 2 +- src/annotate.h | 2 +- src/commodity.h | 4 ++-- src/flags.h | 38 +++++++++++++++++++------------------- src/format.h | 2 +- src/item.h | 2 +- src/py_account.cc | 1 + src/py_commodity.cc | 1 + src/py_item.cc | 1 + src/py_post.cc | 1 + src/py_utils.cc | 1 + 14 files changed, 34 insertions(+), 28 deletions(-) diff --git a/flake.nix b/flake.nix index a992594b..ef87e0c6 100644 --- a/flake.nix +++ b/flake.nix @@ -30,11 +30,12 @@ then [ python3 (boost.override { enablePython = true; python = python3; }) ] else [ boost ]); - nativeBuildInputs = [ cmake texinfo tzdata ]; + nativeBuildInputs = [ cmake texinfo tzdata doxygen graphviz ninja ]; enableParallelBuilding = true; cmakeFlags = [ + "-GNinja" "-DCMAKE_INSTALL_LIBDIR=lib" "-DBUILD_DOCS:BOOL=ON" "-DUSE_PYTHON:BOOL=${if usePython then "ON" else "OFF"}" diff --git a/src/account.h b/src/account.h index 871a3516..be8fddaf 100644 --- a/src/account.h +++ b/src/account.h @@ -53,7 +53,7 @@ typedef std::list posts_list; typedef std::map accounts_map; typedef std::map deferred_posts_map_t; -class account_t : public supports_flags<>, public scope_t +class account_t : public flags::supports_flags<>, public scope_t { #define ACCOUNT_NORMAL 0x00 // no flags at all, a basic account #define ACCOUNT_KNOWN 0x01 diff --git a/src/amount.cc b/src/amount.cc index eb5e0196..484c3099 100644 --- a/src/amount.cc +++ b/src/amount.cc @@ -52,7 +52,7 @@ static mpfr_t tempfnum; static mpfr_t tempfden; #endif -struct amount_t::bigint_t : public supports_flags<> +struct amount_t::bigint_t : public flags::supports_flags<> { #define BIGINT_BULK_ALLOC 0x01 #define BIGINT_KEEP_PREC 0x02 diff --git a/src/amount.h b/src/amount.h index 45e5a68f..7abaa1c9 100644 --- a/src/amount.h +++ b/src/amount.h @@ -76,7 +76,7 @@ enum parse_flags_enum_t { PARSE_SOFT_FAIL = 0x80 }; -typedef ledger::basic_flags_t parse_flags_t; +typedef flags::basic_t parse_flags_t; /** * @brief Encapsulate infinite-precision commoditized amounts diff --git a/src/annotate.h b/src/annotate.h index 1564b812..9f8bde00 100644 --- a/src/annotate.h +++ b/src/annotate.h @@ -49,7 +49,7 @@ namespace ledger { -struct annotation_t : public supports_flags<>, +struct annotation_t : public flags::supports_flags<>, public equality_comparable { #define ANNOTATION_PRICE_CALCULATED 0x01 diff --git a/src/commodity.h b/src/commodity.h index 8177fb4e..3a253297 100644 --- a/src/commodity.h +++ b/src/commodity.h @@ -70,14 +70,14 @@ struct price_point_t }; class commodity_t - : public delegates_flags, + : public flags::delegates_flags, public equality_comparable1 { protected: friend class commodity_pool_t; friend class annotated_commodity_t; - class base_t : public noncopyable, public supports_flags + class base_t : public noncopyable, public flags::supports_flags { public: #define COMMODITY_STYLE_DEFAULTS 0x000 diff --git a/src/flags.h b/src/flags.h index cd01fc29..4d7e653c 100644 --- a/src/flags.h +++ b/src/flags.h @@ -41,7 +41,7 @@ */ #pragma once -namespace ledger { +namespace ledger { namespace flags { template class supports_flags @@ -93,33 +93,33 @@ public: }; template -class basic_flags_t : public supports_flags +class basic_t : public supports_flags { public: - basic_flags_t() { - TRACE_CTOR(basic_flags_t, ""); + basic_t() { + TRACE_CTOR(basic_t, ""); } - basic_flags_t(const T& bits) { - TRACE_CTOR(basic_flags_t, "const T&"); + basic_t(const T& bits) { + TRACE_CTOR(basic_t, "const T&"); supports_flags::set_flags(bits); } - basic_flags_t(const U& bits) { - TRACE_CTOR(basic_flags_t, "const U&"); + basic_t(const U& bits) { + TRACE_CTOR(basic_t, "const U&"); supports_flags::set_flags(static_cast(bits)); } - ~basic_flags_t() throw() { - TRACE_DTOR(basic_flags_t); + ~basic_t() throw() { + TRACE_DTOR(basic_t); } - basic_flags_t(const basic_flags_t& other) + basic_t(const basic_t& other) : supports_flags(other) { - TRACE_CTOR(basic_flags_t, "copy"); + TRACE_CTOR(basic_t, "copy"); } - basic_flags_t& operator=(const basic_flags_t& other) { + basic_t& operator=(const basic_t& other) { set_flags(other.flags()); return *this; } - basic_flags_t& operator=(const T& bits) { + basic_t& operator=(const T& bits) { set_flags(bits); return *this; } @@ -131,13 +131,13 @@ public: return supports_flags::flags(); } - basic_flags_t plus_flags(const T& arg) const { - basic_flags_t temp(*this); + basic_t plus_flags(const T& arg) const { + basic_t temp(*this); temp.add_flags(arg); return temp; } - basic_flags_t minus_flags(const T& arg) const { - basic_flags_t temp(*this); + basic_t minus_flags(const T& arg) const { + basic_t temp(*this); temp.drop_flags(arg); return temp; } @@ -184,4 +184,4 @@ public: } }; -} // namespace ledger +} } // namespace ledger::flags diff --git a/src/format.h b/src/format.h index c1c8701a..c021f219 100644 --- a/src/format.h +++ b/src/format.h @@ -56,7 +56,7 @@ class format_t : public expr_base_t, public noncopyable { typedef expr_base_t base_type; - struct element_t : public supports_flags<>, public noncopyable + struct element_t : public flags::supports_flags<>, public noncopyable { #define ELEMENT_ALIGN_LEFT 0x01 diff --git a/src/item.h b/src/item.h index faebe61f..c21450e8 100644 --- a/src/item.h +++ b/src/item.h @@ -79,7 +79,7 @@ struct position_t } }; -class item_t : public supports_flags, public scope_t +class item_t : public flags::supports_flags, public scope_t { public: #define ITEM_NORMAL 0x00 // no flags at all, a basic posting diff --git a/src/py_account.cc b/src/py_account.cc index cc9008c9..67218c8b 100644 --- a/src/py_account.cc +++ b/src/py_account.cc @@ -39,6 +39,7 @@ namespace ledger { +using namespace flags; using namespace boost::python; namespace { diff --git a/src/py_commodity.cc b/src/py_commodity.cc index 577254db..28074b5c 100644 --- a/src/py_commodity.cc +++ b/src/py_commodity.cc @@ -39,6 +39,7 @@ namespace ledger { +using namespace flags; using namespace boost::python; namespace { diff --git a/src/py_item.cc b/src/py_item.cc index 9fbccc98..a23ebe5f 100644 --- a/src/py_item.cc +++ b/src/py_item.cc @@ -39,6 +39,7 @@ namespace ledger { +using namespace flags; using namespace boost::python; namespace { diff --git a/src/py_post.cc b/src/py_post.cc index f2af16eb..0065cf3f 100644 --- a/src/py_post.cc +++ b/src/py_post.cc @@ -37,6 +37,7 @@ namespace ledger { +using namespace flags; using namespace boost::python; namespace { diff --git a/src/py_utils.cc b/src/py_utils.cc index 1f5e448f..1a28f087 100644 --- a/src/py_utils.cc +++ b/src/py_utils.cc @@ -36,6 +36,7 @@ namespace ledger { +using namespace flags; using namespace boost::python; struct bool_to_python -- cgit v1.2.3