diff options
author | Alexis Hildebrandt <afh@surryhill.net> | 2023-04-12 11:14:08 +0200 |
---|---|---|
committer | Alexis Hildebrandt <afh@surryhill.net> | 2023-04-12 21:52:36 +0200 |
commit | 5f78556078d2e61d5c0ef44e36d58f3864cd84d1 (patch) | |
tree | eb8e9e52d156b00e8699e46c01de42c606b935d7 /src | |
parent | 15f29d4852e01bc6c6fb802ee818d991142e2f36 (diff) | |
download | fork-ledger-5f78556078d2e61d5c0ef44e36d58f3864cd84d1.tar.gz fork-ledger-5f78556078d2e61d5c0ef44e36d58f3864cd84d1.tar.bz2 fork-ledger-5f78556078d2e61d5c0ef44e36d58f3864cd84d1.zip |
Refactor basic_flags_t to ledger::flags::basic_t
Diffstat (limited to 'src')
-rw-r--r-- | src/account.h | 2 | ||||
-rw-r--r-- | src/amount.cc | 2 | ||||
-rw-r--r-- | src/amount.h | 2 | ||||
-rw-r--r-- | src/annotate.h | 2 | ||||
-rw-r--r-- | src/commodity.h | 4 | ||||
-rw-r--r-- | src/flags.h | 38 | ||||
-rw-r--r-- | src/format.h | 2 | ||||
-rw-r--r-- | src/item.h | 2 | ||||
-rw-r--r-- | src/py_account.cc | 1 | ||||
-rw-r--r-- | src/py_commodity.cc | 1 | ||||
-rw-r--r-- | src/py_item.cc | 1 | ||||
-rw-r--r-- | src/py_post.cc | 1 | ||||
-rw-r--r-- | src/py_utils.cc | 1 |
13 files changed, 32 insertions, 27 deletions
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<post_t *> posts_list; typedef std::map<string, account_t *> accounts_map; typedef std::map<string, posts_list> 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_enum_t, uint_least8_t> parse_flags_t; +typedef flags::basic_t<parse_flags_enum_t, uint_least8_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<annotation_t> { #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<uint_least16_t>, + : public flags::delegates_flags<uint_least16_t>, public equality_comparable1<commodity_t, noncopyable> { protected: friend class commodity_pool_t; friend class annotated_commodity_t; - class base_t : public noncopyable, public supports_flags<uint_least16_t> + class base_t : public noncopyable, public flags::supports_flags<uint_least16_t> { 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 <typename T = boost::uint_least8_t, typename U = T> class supports_flags @@ -93,33 +93,33 @@ public: }; template <typename T = boost::uint_least8_t, typename U = T> -class basic_flags_t : public supports_flags<T, U> +class basic_t : public supports_flags<T, U> { 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<T, U>::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<T, U>::set_flags(static_cast<T>(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<T, U>(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<T, U>::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<string>, public noncopyable { typedef expr_base_t<string> base_type; - struct element_t : public supports_flags<>, public noncopyable + struct element_t : public flags::supports_flags<>, public noncopyable { #define ELEMENT_ALIGN_LEFT 0x01 @@ -79,7 +79,7 @@ struct position_t } }; -class item_t : public supports_flags<uint_least16_t>, public scope_t +class item_t : public flags::supports_flags<uint_least16_t>, 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 |