blob: 8c931d3f5fe06d8ff8f473cb8efe5e51d8cbb788 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
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__ */
|