Mixe for Privacy and Anonymity in the Internet
CAXMLCostConfirmation.hpp
Go to the documentation of this file.
1 #ifndef __CAXMLCOSTCONFIRMATION__
2 #define __CAXMLCOSTCONFIRMATION__
3 #ifdef PAYMENT
4 #include "xml/DOM_Output.hpp"
5 #include "CAPriceInfo.hpp"
6 
12 class CAXMLCostConfirmation
13  {
14 
15  private:
16  SINT32 setValues();
17  CAXMLCostConfirmation();
18 
19  UINT64 m_lTransferredBytes;
20  UINT64 m_lAccountNumber;
21  UINT32 m_id; //id of the CC, only set after storing it in the BI's database
22  CAPriceInfo** m_priceCerts;
23  UINT32 m_priceCertsLen;
24  UINT8* m_pStrPIID;
25  XERCES_CPP_NAMESPACE::DOMDocument* m_domDocument;
26  static const char* const ms_pStrElemName;
27 
28  SINT32 checkLen(UINT32 a_hashNumber)
29  {
30  if (a_hashNumber < 0 || a_hashNumber > m_priceCertsLen - 1)
31  {
32  return E_UNKNOWN;
33  }
34  return E_SUCCESS;
35  }
36 
37  public:
42  static CAXMLCostConfirmation* getInstance(UINT8 * strXmlData,UINT32 strXMlDataLen);
47  static CAXMLCostConfirmation* getInstance(DOMElement* elemRoot);
48  ~CAXMLCostConfirmation();
49 
50  UINT32 getNumberOfHashes()
51  {
52  return m_priceCertsLen;
53  }
54 
55  SINT32 getPosition(UINT32 a_hashNumber)
56  {
57  if (checkLen(a_hashNumber) != E_SUCCESS)
58  {
59  return E_UNKNOWN;
60  }
61 
62  return m_priceCerts[a_hashNumber]->getPosition();
63  }
64 
65  UINT8* getPriceCertHash(UINT32 a_hashNumber)
66  {
67  if (checkLen(a_hashNumber) != E_SUCCESS)
68  {
69  return NULL;
70  }
71  return m_priceCerts[a_hashNumber]->getPriceCertHash();
72  }
73 
74  UINT8* getMixId(UINT32 a_hashNumber)
75  {
76  if (checkLen(a_hashNumber) != E_SUCCESS)
77  {
78  return NULL;
79  }
80  return m_priceCerts[a_hashNumber]->getMixId();
81  }
82 
84  UINT8* dumpToMem(UINT32* pLen)
85  {
86  if(m_domDocument==NULL)
87  return NULL;
88  return DOM_Output::dumpToMem(m_domDocument,pLen);
89  }
90 
92  SINT32 toXMLString(UINT8* buff,UINT32* bufflen)
93  {
94  if(DOM_Output::dumpToMem(m_domDocument,buff,bufflen)!=E_SUCCESS)
95  return E_UNKNOWN;
96  buff[*bufflen]=0;
97  return E_SUCCESS;
98  }
99 
100  UINT64 getTransferredBytes()
101  {
102  return m_lTransferredBytes;
103  }
104 
105  UINT64 getAccountNumber()
106  {
107  return m_lAccountNumber;
108  }
109 
110 
111  UINT32 getID()
112  {
113  return m_id;
114  }
115 
116 //dangerous and currently not needed?
117 // CAPriceInfo** getPriceCerts()
118 // {
119 // return m_priceCerts;
120 // }
121 
125  UINT8* getPIID()
126  {
127  UINT8* pTmpStr = NULL;
128  if(m_pStrPIID!=NULL)
129  {
130  pTmpStr = new UINT8[strlen((char*)m_pStrPIID)+1];
131  strcpy((char*)pTmpStr, (char*)m_pStrPIID);
132  }
133  return pTmpStr;
134  }
135 
136  static const char* const getXMLElementName()
137  {
138  return ms_pStrElemName;
139  }
140 
141  XERCES_CPP_NAMESPACE::DOMDocument* getXMLDocument()
142  {
143  return m_domDocument;
144  }
145 
146 
147 
148  };
149 
150 #endif //PAYMENT
151 #endif
signed int SINT32
Definition: basetypedefs.h:132
unsigned char UINT8
Definition: basetypedefs.h:135
unsigned int UINT32
Definition: basetypedefs.h:131
static SINT32 dumpToMem(const DOMNode *node, UINT8 *buff, UINT32 *size)
Dumps the node and all childs into buff.
Definition: DOM_Output.hpp:161
const SINT32 E_SUCCESS
Definition: errorcodes.hpp:2
#define E_UNKNOWN
Definition: errorcodes.hpp:3