Skip to content

Commit 530cba9

Browse files
committed
removed the need to #include operators hpp
1 parent 13e58ee commit 530cba9

File tree

3 files changed

+39
-7
lines changed

3 files changed

+39
-7
lines changed

README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,19 @@ These are implementations of the multi-precision `BigInteger`, `BigDecimal` and
2121
A type that holds a number as fraction (ratio) of two `BigIntegers`, a numerator and a denominator, i.e. `1/7` or `100/3`.
2222
This type is very good at simple arithmetic (`+`, `-`, `*`, `/`), since it doesn't lose precision or need any rounding. Still a work in progress...
2323

24+
## C++Builder
25+
26+
The newest version of BigIntegers has additional overloaded operators and additional constructors that are compatible
27+
with C++Builder. So now you simply include:
28+
29+
#include "Velthuis.BigIntegers.hpp"
30+
31+
and then you can do things like:
32+
33+
BigInteger a = 17;
34+
BigInteger b = "123";
35+
BigInteger c = a + b;
36+
2437
## Directory structure
2538

2639
```
@@ -48,4 +61,3 @@ BigNumbers
4861
and BigDecimal
4962
```
5063

51-

Source/Velthuis.BigIntegers.pas

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,11 @@ interface
221221
{$DEFINE HasExtended}
222222
{$IFEND}
223223

224+
// For PAnsiChar:
225+
{$IF NOT DECLARED(PAnsiChar)}
226+
{$DEFINE NoAnsi}
227+
{$IFEND}
228+
224229
// Assembler is only supplied for Windows targets.
225230
// For other targets, PUREPASCAL must be defined.
226231
{$IFNDEF PUREPASCAL}
@@ -1178,6 +1183,8 @@ function Max(const A, B: BigInteger): BigInteger; overload; inline;
11781183

11791184
implementation
11801185

1186+
{$HPPEMIT END '#include "Velthuis.BigIntegers.operators.hpp"'}
1187+
11811188
// To switch PUREPASCAL for debug purposes. UNDEF PUREPASCAL before the routine and DEFINE PUREPASCAL
11821189
// after the routine, if PP was defined.
11831190
{$IFDEF PUREPASCAL}
@@ -3079,11 +3086,13 @@ constructor BigInteger.Create(const Value: Double);
30793086
Compact;
30803087
end;
30813088

3089+
{$IFNDEF NoAnsi}
30823090
constructor BigInteger.Create(const Value: PAnsiChar);
30833091
begin
30843092
if not TryParse(string(AnsiString(Value)), Self) then
30853093
Error(ecParse, [string(AnsiString(Value)), 'BigInteger']);
30863094
end;
3095+
{$ENDIF}
30873096

30883097
constructor BigInteger.Create(const Value: PWideChar);
30893098
begin
@@ -10454,11 +10463,13 @@ function BigInteger.Remainder(const Other: BigInteger): PBigInteger;
1045410463
Error(ecParse, [Value, 'BigInteger']);
1045510464
end;
1045610465

10466+
{$IFNDEF NoAnsi}
1045710467
class operator BigInteger.Implicit(const Value: PAnsiChar): BigInteger;
1045810468
begin
1045910469
if not TryParse(string(AnsiString(Value)), Result) then
1046010470
Error(ecParse, [string(AnsiString(Value)), 'BigInteger']);
1046110471
end;
10472+
{$ENDIF}
1046210473

1046310474
class operator BigInteger.Implicit(const Value: PWideChar): BigInteger;
1046410475
begin

Tests/BigIntegers/BigIntegerDevelopmentTests.dproj

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@
3333
<CfgParent>Base</CfgParent>
3434
<Base>true</Base>
3535
</PropertyGroup>
36+
<PropertyGroup Condition="('$(Platform)'=='OSX32' and '$(Cfg_1)'=='true') or '$(Cfg_1_OSX32)'!=''">
37+
<Cfg_1_OSX32>true</Cfg_1_OSX32>
38+
<CfgParent>Cfg_1</CfgParent>
39+
<Cfg_1>true</Cfg_1>
40+
<Base>true</Base>
41+
</PropertyGroup>
3642
<PropertyGroup Condition="('$(Platform)'=='Win32' and '$(Cfg_1)'=='true') or '$(Cfg_1_Win32)'!=''">
3743
<Cfg_1_Win32>true</Cfg_1_Win32>
3844
<CfgParent>Cfg_1</CfgParent>
@@ -90,6 +96,7 @@
9096
<DCC_UsePackage>FireDACSqliteDriver;FireDACDSDriver;DBXSqliteDriver;FireDACPgDriver;fmx;IndySystem;tethering;DBXInterBaseDriver;DataSnapClient;DataSnapServer;DataSnapCommon;DataSnapProviderClient;DbxCommonDriver;dbxcds;fmxFireDAC;DBXOracleDriver;CustomIPTransport;dsnap;IndyIPServer;fmxase;IndyCore;IndyIPCommon;CloudService;FmxTeeUI;FireDACIBDriver;DataSnapFireDAC;FireDACDBXDriver;soapserver;inetdbxpress;dsnapxml;FireDACASADriver;bindcompfmx;FireDACODBCDriver;RESTBackendComponents;emsclientfiredac;rtl;dbrtl;DbxClientDriver;FireDACCommon;bindcomp;inetdb;xmlrtl;DataSnapNativeClient;ibxpress;IndyProtocols;DBXMySQLDriver;FireDACCommonDriver;bindengine;bindcompdbx;soaprtl;FMXTee;emsclient;FireDACMSSQLDriver;FireDAC;DBXInformixDriver;DataSnapServerMidas;DBXFirebirdDriver;inet;fmxobj;FireDACMySQLDriver;soapmidas;DBXSybaseASADriver;FireDACOracleDriver;fmxdae;RESTComponents;dbexpress;DataSnapIndy10ServerTransport;IndyIPClient;$(DCC_UsePackage)</DCC_UsePackage>
9197
<VerInfo_Keys>CFBundleName=$(MSBuildProjectName);CFBundleDisplayName=$(MSBuildProjectName);CFBundleIdentifier=$(MSBuildProjectName);CFBundleVersion=1.0.0;CFBundlePackageType=APPL;CFBundleSignature=????;CFBundleAllowMixedLocalizations=YES;CFBundleExecutable=$(MSBuildProjectName);NSHighResolutionCapable=true;LSApplicationCategoryType=public.app-category.utilities;NSLocationAlwaysUsageDescription=The reason for accessing the location information of the user;NSLocationWhenInUseUsageDescription=The reason for accessing the location information of the user;NSContactsUsageDescription=The reason for accessing the contacts;CFBundleShortVersionString=1.0.0</VerInfo_Keys>
9298
<BT_BuildType>Debug</BT_BuildType>
99+
<Debugger_Launcher>/usr/X11/bin/xterm -e &quot;%debuggee%&quot;</Debugger_Launcher>
93100
</PropertyGroup>
94101
<PropertyGroup Condition="'$(Base_Win32)'!=''">
95102
<DCC_UsePackage>FireDACSqliteDriver;FireDACDSDriver;DBXSqliteDriver;FireDACPgDriver;fmx;IndySystem;TeeDB;tethering;vclib;DBXInterBaseDriver;DataSnapClient;DataSnapServer;DataSnapCommon;DataSnapProviderClient;DBXSybaseASEDriver;DbxCommonDriver;vclimg;dbxcds;DatasnapConnectorsFreePascal;MetropolisUILiveTile;vcldb;vcldsnap;fmxFireDAC;DBXDb2Driver;DBXOracleDriver;CustomIPTransport;vclribbon;dsnap;IndyIPServer;fmxase;vcl;IndyCore;DBXMSSQLDriver;IndyIPCommon;CloudService;FmxTeeUI;FireDACIBDriver;CodeSiteExpressPkg;DataSnapFireDAC;FireDACDBXDriver;soapserver;inetdbxpress;dsnapxml;FireDACInfxDriver;FireDACDb2Driver;adortl;FireDACASADriver;bindcompfmx;FireDACODBCDriver;RESTBackendComponents;emsclientfiredac;rtl;dbrtl;DbxClientDriver;FireDACCommon;bindcomp;inetdb;Tee;DBXOdbcDriver;vclFireDAC;xmlrtl;DataSnapNativeClient;svnui;ibxpress;IndyProtocols;DBXMySQLDriver;FireDACCommonDriver;bindengine;vclactnband;bindcompdbx;soaprtl;FMXTee;TeeUI;bindcompvcl;vclie;FireDACADSDriver;vcltouch;emsclient;VCLRESTComponents;FireDACMSSQLDriver;FireDAC;VclSmp;DBXInformixDriver;Intraweb;DataSnapConnectors;DataSnapServerMidas;dsnapcon;DBXFirebirdDriver;inet;fmxobj;FireDACMySQLDriver;soapmidas;vclx;svn;DBXSybaseASADriver;FireDACOracleDriver;fmxdae;RESTComponents;FireDACMSAccDriver;dbexpress;DataSnapIndy10ServerTransport;IndyIPClient;$(DCC_UsePackage)</DCC_UsePackage>
@@ -109,6 +116,9 @@
109116
<DCC_DebugInfoInExe>true</DCC_DebugInfoInExe>
110117
<DCC_RemoteDebug>true</DCC_RemoteDebug>
111118
</PropertyGroup>
119+
<PropertyGroup Condition="'$(Cfg_1_OSX32)'!=''">
120+
<VerInfo_Keys>CFBundleName=$(MSBuildProjectName);CFBundleDisplayName=$(MSBuildProjectName);CFBundleIdentifier=$(MSBuildProjectName);CFBundleVersion=1.0.0;CFBundlePackageType=APPL;CFBundleSignature=????;CFBundleAllowMixedLocalizations=YES;CFBundleExecutable=$(MSBuildProjectName);NSHighResolutionCapable=true;LSApplicationCategoryType=public.app-category.utilities;NSLocationAlwaysUsageDescription=The reason for accessing the location information of the user;NSLocationWhenInUseUsageDescription=The reason for accessing the location information of the user;NSContactsUsageDescription=The reason for accessing the contacts;CFBundleShortVersionString=1.0.0</VerInfo_Keys>
121+
</PropertyGroup>
112122
<PropertyGroup Condition="'$(Cfg_1_Win32)'!=''">
113123
<DCC_ExeOutput>.\$(Platform)\$(Config)\T</DCC_ExeOutput>
114124
<DCC_GenerateStackFrames>false</DCC_GenerateStackFrames>
@@ -119,7 +129,7 @@
119129
<ILINK_FullDebugInfo>true</ILINK_FullDebugInfo>
120130
<BCC_DebugLineNumbers>true</BCC_DebugLineNumbers>
121131
<BCC_SourceDebuggingOn>true</BCC_SourceDebuggingOn>
122-
<DCC_AdditionalSwitches>-x-orc=2</DCC_AdditionalSwitches>
132+
<DCC_OutputDependencies>true</DCC_OutputDependencies>
123133
</PropertyGroup>
124134
<PropertyGroup Condition="'$(Cfg_1_Win64)'!=''">
125135
<DCC_MinimumEnumSize>4</DCC_MinimumEnumSize>
@@ -191,11 +201,10 @@
191201
<Source Name="MainSource">BigIntegerDevelopmentTests.dpr</Source>
192202
</Source>
193203
<Excluded_Packages>
194-
<Excluded_Packages Name="$(BDSBIN)\dcltee9240.bpl">TeeChart Standard VCL Components</Excluded_Packages>
195-
<Excluded_Packages Name="$(BDSBIN)\bcboffice2k240.bpl">Embarcadero C++Builder Office 2000 Servers Package</Excluded_Packages>
196-
<Excluded_Packages Name="$(BDSBIN)\bcbofficexp240.bpl">Embarcadero C++Builder Office XP Servers Package</Excluded_Packages>
197-
<Excluded_Packages Name="$(BDSBIN)\dcloffice2k240.bpl">Microsoft Office 2000 Sample Automation Server Wrapper Components</Excluded_Packages>
198-
<Excluded_Packages Name="$(BDSBIN)\dclofficexp240.bpl">Microsoft Office XP Sample Automation Server Wrapper Components</Excluded_Packages>
204+
<Excluded_Packages Name="$(BDSBIN)\bcboffice2k250.bpl">Embarcadero C++Builder Office 2000 Servers Package</Excluded_Packages>
205+
<Excluded_Packages Name="$(BDSBIN)\bcbofficexp250.bpl">Embarcadero C++Builder Office XP Servers Package</Excluded_Packages>
206+
<Excluded_Packages Name="$(BDSBIN)\dcloffice2k250.bpl">Microsoft Office 2000 Sample Automation Server Wrapper Components</Excluded_Packages>
207+
<Excluded_Packages Name="$(BDSBIN)\dclofficexp250.bpl">Microsoft Office XP Sample Automation Server Wrapper Components</Excluded_Packages>
199208
</Excluded_Packages>
200209
<VersionInfo>
201210
<VersionInfo Name="IncludeVerInfo">False</VersionInfo>

0 commit comments

Comments
 (0)