diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2023-08-14 21:07:46 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2023-08-14 21:07:46 +0200 |
commit | c894a7cdd8686ea695602a23a511a3f1b0d047be (patch) | |
tree | 1fb4e9f4781af3221982a5831173ea14e6585306 /src/include/xbbcd.h | |
parent | bfa452a375ea0a0a3f95304a69186936567e5263 (diff) |
New upstream version 4.1.4upstream
Diffstat (limited to 'src/include/xbbcd.h')
-rwxr-xr-x | src/include/xbbcd.h | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/src/include/xbbcd.h b/src/include/xbbcd.h new file mode 100755 index 0000000..8c931d3 --- /dev/null +++ b/src/include/xbbcd.h @@ -0,0 +1,93 @@ +/* xbbcd.h + +XBase64 Software Library + +Copyright (c) 1997,2003,2014, 2018, 2019, 2022 Gary A Kunkel + +The xb64 software library is covered under the terms of the GPL Version 3, 2007 license. + +Email Contact: + + XDB-devel@lists.sourceforge.net + XDB-users@lists.sourceforge.net + +*/ + +#ifndef __XB_BCD_H__ +#define __XB_BCD_H__ +#ifdef XB_INDEX_SUPPORT + +///@cond DOXYOFF + +namespace xb{ + +// structure for bcd value +// next structure superceeded. Different compilers allocate different +// sizes to structures with bit fields, can't count on the size + +/* +struct XBDLLEXPORT xbBcdStrucOld { + unsigned SigDigits : 8; // significant digit count + unsigned Filler : 2; // always set to 1 + unsigned EncDigits : 5; // encoded digit count + unsigned Sign : 1; // +/- sign + unsigned char Data[10]; +}; +*/ + +struct XBDLLEXPORT xbBcdStruct { + unsigned char cSigDigits; // significant digit count + unsigned char cEncDigits; // encoded digit count + unsigned char cData[10]; // data +}; + +struct XBDLLEXPORT xbByteSplit { + unsigned c1 : 4; + unsigned c2 : 4; +}; + +class XBDLLEXPORT xbBcd { + public: + + xbBcd( const xbString &sIn ); + xbBcd( xbDouble dIn ); + xbBcd( const void *vBcd12In ); + void Set( xbDouble dIn ); + void Set( const void *cBcd12In ); + void Set( const xbString &sIn ); + + + void ToString( xbString &sOut ); + void ToDouble( xbDouble &dOut ); + void ToBcd( xbBcdStruct &bcdOut ); + void ToChar( char *cOut ); + + // const unsigned char * GetBcd() const; + void StringToBcd( const xbString &sStringIn ); + + xbInt16 Compare( const xbBcd &bcdIn ); + xbInt16 Compare( xbDouble d ); + + const unsigned char *GetData() const; + const void * GetBcd() const; + + + private: + void ctor(); + unsigned char GetEncDigitsNoSign() const; + unsigned GetSign() const; + unsigned GetSigDigits() const; + unsigned GetActualSigDigits() const; + + +// xbBcdStruc bcdOld; + xbBcdStruct bcd; +}; + +} /* namespace xb */ + + +///@endcond DOXYOFF + +#endif /* XB_INDEX_SUPPORT */ +#endif /* __XB_BCD_H__ */ |