Xbase64 4.0.1
C++ Library for handling Xbase (DBF) format type files
xbbcd.h
Go to the documentation of this file.
1/* xbbcd.h
2
3XBase64 Software Library
4
5Copyright (c) 1997,2003,2014, 2018, 2019, 2022 Gary A Kunkel
6
7The xb64 software library is covered under the terms of the GPL Version 3, 2007 license.
8
9Email Contact:
10
11 XDB-devel@lists.sourceforge.net
12 XDB-users@lists.sourceforge.net
13
14*/
15
16#ifndef __XB_BCD_H__
17#define __XB_BCD_H__
18#ifdef XB_INDEX_SUPPORT
19
21
22namespace xb{
23
24// structure for bcd value
25// next structure superceeded. Different compilers allocate different
26// sizes to structures with bit fields, can't count on the size
27
28/*
29struct XBDLLEXPORT xbBcdStrucOld {
30 unsigned SigDigits : 8; // significant digit count
31 unsigned Filler : 2; // always set to 1
32 unsigned EncDigits : 5; // encoded digit count
33 unsigned Sign : 1; // +/- sign
34 unsigned char Data[10];
35};
36*/
37
38struct XBDLLEXPORT xbBcdStruct {
39 unsigned char cSigDigits; // significant digit count
40 unsigned char cEncDigits; // encoded digit count
41 unsigned char cData[10]; // data
42};
43
44struct XBDLLEXPORT xbByteSplit {
45 unsigned c1 : 4;
46 unsigned c2 : 4;
47};
48
49class XBDLLEXPORT xbBcd {
50 public:
51
52 xbBcd( const xbString &sIn );
53 xbBcd( xbDouble dIn );
54 xbBcd( const void *vBcd12In );
55 void Set( xbDouble dIn );
56 void Set( const void *cBcd12In );
57 void Set( const xbString &sIn );
58
59
60 void ToString( xbString &sOut );
61 void ToDouble( xbDouble &dOut );
62 void ToBcd( xbBcdStruct &bcdOut );
63 void ToChar( char *cOut );
64
65 // const unsigned char * GetBcd() const;
66 void StringToBcd( const xbString &sStringIn );
67
68 xbInt16 Compare( const xbBcd &bcdIn );
69 xbInt16 Compare( xbDouble d );
70
71 const unsigned char *GetData() const;
72 const void * GetBcd() const;
73
74
75 private:
76 void ctor();
77 unsigned char GetEncDigitsNoSign() const;
78 unsigned GetSign() const;
79 unsigned GetSigDigits() const;
80 unsigned GetActualSigDigits() const;
81
82
83// xbBcdStruc bcdOld;
84 xbBcdStruct bcd;
85};
86
87} /* namespace xb */
88
89
91
92#endif /* XB_INDEX_SUPPORT */
93#endif /* __XB_BCD_H__ */
Definition: xbdate.cpp:19
double xbDouble
Definition: xbtypes.h:23