Skip to content

Commit b6fc82c

Browse files
committed
Add support for boost.decimal
1 parent c152516 commit b6fc82c

16 files changed

Lines changed: 857 additions & 48 deletions

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ if(FB_CPP_USE_BOOST_MULTIPRECISION)
6868
set(FB_CPP_USE_BOOST_MULTIPRECISION_VALUE 1)
6969
endif()
7070

71+
set(FB_CPP_USE_BOOST_DECIMAL_VALUE 0)
72+
if(FB_CPP_USE_BOOST_DECIMAL)
73+
set(FB_CPP_USE_BOOST_DECIMAL_VALUE 1)
74+
endif()
75+
7176

7277
include(CMakePackageConfigHelpers)
7378
write_basic_package_version_file(

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ It wraps the Firebird C++ API with RAII principles, smart pointers, and modern C
1818
- **RAII**: Automatic resource management with smart pointers
1919
- **Type Safety**: Strong typing for database operations
2020
- **Exception Safety**: Proper error handling with exceptions
21-
- **Boost Integration**: Optional Boost.DLL for loading fbclient and Boost.Multiprecision support for large numbers
21+
- **Boost Integration**: Optional Boost.DLL for loading fbclient, Boost.Multiprecision support for large numbers, and
22+
Boost.Decimal support for decimal floating-point values
2223

2324
## Quick Start
2425

@@ -102,6 +103,7 @@ Or add it to your `vcpkg.json` manifest:
102103
The default features are:
103104
- `boost-dll`: Enable Boost.DLL support for runtime dynamic loading of Firebird client library
104105
- `boost-multiprecision`: Enable Boost.Multiprecision support for INT128 and DECFLOAT types
106+
- `boost-decimal`: Enable Boost.Decimal support for DECFLOAT types
105107

106108
## Building
107109

cmake/fb-cppConfig.cmake.in

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ find_dependency(firebird CONFIG)
66

77
set(_fb_cpp_use_boost_dll "@FB_CPP_USE_BOOST_DLL_VALUE@")
88
set(_fb_cpp_use_boost_multiprecision "@FB_CPP_USE_BOOST_MULTIPRECISION_VALUE@")
9+
set(_fb_cpp_use_boost_decimal "@FB_CPP_USE_BOOST_DECIMAL_VALUE@")
910

1011
if(_fb_cpp_use_boost_dll)
1112
find_dependency(Boost COMPONENTS dll)
@@ -15,9 +16,14 @@ if(_fb_cpp_use_boost_multiprecision)
1516
find_dependency(Boost COMPONENTS multiprecision)
1617
endif()
1718

19+
if(_fb_cpp_use_boost_decimal)
20+
find_dependency(Boost COMPONENTS decimal)
21+
endif()
22+
1823
include("${CMAKE_CURRENT_LIST_DIR}/fb-cppTargets.cmake")
1924

2025
unset(_fb_cpp_use_boost_dll)
2126
unset(_fb_cpp_use_boost_multiprecision)
27+
unset(_fb_cpp_use_boost_decimal)
2228

2329
check_required_components(fb-cpp)

doc/Doxyfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ SEARCH_INCLUDES = YES
195195
INCLUDE_PATH =
196196
INCLUDE_FILE_PATTERNS =
197197
PREDEFINED = FB_CPP_USE_BOOST_MULTIPRECISION=1 \
198+
FB_CPP_USE_BOOST_DECIMAL=1 \
198199
FB_CPP_USE_BOOST_DLL=1
199200
EXPAND_AS_DEFINED =
200201
SKIP_FUNCTION_MACROS = YES

src/fb-cpp/CMakeLists.txt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,16 @@ option(FB_CPP_USE_BOOST_MULTIPRECISION "Enable Boost.Multiprecision helpers for
2222
${_fb_cpp_use_boost_multiprecision_default})
2323
unset(_fb_cpp_use_boost_multiprecision_default)
2424

25+
set(_fb_cpp_use_boost_decimal_default ON)
26+
if(DEFINED VCPKG_INSTALLED_DIR AND DEFINED VCPKG_TARGET_TRIPLET)
27+
if(NOT EXISTS "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/share/boost-decimal")
28+
set(_fb_cpp_use_boost_decimal_default OFF)
29+
endif()
30+
endif()
31+
option(FB_CPP_USE_BOOST_DECIMAL "Enable Boost.Decimal helpers for DECFLOAT types"
32+
${_fb_cpp_use_boost_decimal_default})
33+
unset(_fb_cpp_use_boost_decimal_default)
34+
2535
file(GLOB_RECURSE SRC
2636
"*.h"
2737
"*.cpp"
@@ -34,6 +44,9 @@ endif()
3444
if(FB_CPP_USE_BOOST_MULTIPRECISION)
3545
list(APPEND _fb_cpp_boost_components multiprecision)
3646
endif()
47+
if(FB_CPP_USE_BOOST_DECIMAL)
48+
list(APPEND _fb_cpp_boost_components decimal)
49+
endif()
3750

3851
if(_fb_cpp_boost_components)
3952
find_package(Boost REQUIRED
@@ -77,10 +90,19 @@ if(NOT DEFINED FB_CPP_USE_BOOST_MULTIPRECISION_VALUE)
7790
endif()
7891
endif()
7992

93+
if(NOT DEFINED FB_CPP_USE_BOOST_DECIMAL_VALUE)
94+
if(FB_CPP_USE_BOOST_DECIMAL)
95+
set(FB_CPP_USE_BOOST_DECIMAL_VALUE 1)
96+
else()
97+
set(FB_CPP_USE_BOOST_DECIMAL_VALUE 0)
98+
endif()
99+
endif()
100+
80101
target_compile_definitions(${PROJECT_NAME}
81102
PUBLIC
82103
FB_CPP_USE_BOOST_DLL=${FB_CPP_USE_BOOST_DLL_VALUE}
83104
FB_CPP_USE_BOOST_MULTIPRECISION=${FB_CPP_USE_BOOST_MULTIPRECISION_VALUE}
105+
FB_CPP_USE_BOOST_DECIMAL=${FB_CPP_USE_BOOST_DECIMAL_VALUE}
84106
)
85107

86108
target_link_libraries(${PROJECT_NAME}
@@ -100,6 +122,12 @@ if(FB_CPP_USE_BOOST_MULTIPRECISION)
100122
)
101123
endif()
102124

125+
if(FB_CPP_USE_BOOST_DECIMAL)
126+
target_link_libraries(${PROJECT_NAME}
127+
PUBLIC Boost::decimal
128+
)
129+
endif()
130+
103131
unset(_fb_cpp_boost_components)
104132

105133
file(GLOB_RECURSE HEADER_FILES

0 commit comments

Comments
 (0)