aqbanking
5.0.28beta
Main Page
Related Pages
Modules
Namespaces
Data Structures
Files
File List
Globals
aqbanking5
aqbankingpp
value.hpp
Go to the documentation of this file.
1
/***************************************************************************
2
$RCSfile$
3
-------------------
4
begin : Mon March 1 2011
5
copyright : (C) 2011 by Christian Stimming
6
email : christian@cstimming.de
7
8
***************************************************************************
9
* This file is part of the project "AqBanking". *
10
* Please see toplevel file COPYING of that project for license details. *
11
***************************************************************************/
12
13
14
#ifndef AB_VALUE_HPP
15
#define AB_VALUE_HPP
16
17
#include <
aqbanking/value.h
>
18
#include <
aqbankingpp/cxxwrap.hpp
>
19
#include <string>
20
21
namespace
AB
22
{
23
25
class
/*AQBANKING_API*/
Value
26
// note: AQBANKING_API isn't needed as long as this class is defined
27
// purely in the header.
28
{
29
public
:
30
typedef
AB_VALUE
wrapped_type
;
31
private
:
32
wrapped_type
* m_ptr;
33
public
:
34
35
AB_CXXWRAP_CONSTRUCTOR0
(
Value
, AB_Value);
36
AB_CXXWRAP_CONSTRUCTORS
(
Value
, AB_Value);
37
40
Value
(
double
d)
41
: m_ptr(
AB_Value_fromDouble
(d))
42
{}
43
46
Value
(
long
int
num,
long
int
denom)
47
: m_ptr(
AB_Value_fromInt
(num, denom))
48
{}
49
51
void
toString
(GWEN_BUFFER *buf)
const
52
{
53
AB_Value_toString
(m_ptr, buf);
54
}
55
57
std::string
toString
()
const
58
{
59
GWEN_BUFFER *buf = GWEN_Buffer_new(NULL, 100, 0, 0);
60
toString
(buf);
61
std::string result(GWEN_Buffer_GetStart(buf));
62
GWEN_Buffer_free(buf);
63
return
result;
64
}
65
66
67
long
int
AB_CXXWRAP_GET0_CONST
(getNum,
AB_Value_Num
);
68
long
int
AB_CXXWRAP_GET0_CONST
(getDenom,
AB_Value_Denom
);
69
double
AB_CXXWRAP_GET0_CONST
(getValueAsDouble,
AB_Value_GetValueAsDouble
);
70
71
AB_CXXWRAP_SET1
(setValueFromDouble,
double
,
AB_Value_SetValueFromDouble
);
72
AB_CXXWRAP_SET0
(setZero,
AB_Value_SetZero
);
73
74
bool
AB_CXXWRAP_GET0_CONST
(isZero,
AB_Value_IsZero
);
75
bool
AB_CXXWRAP_GET0_CONST
(isNegative,
AB_Value_IsNegative
);
76
bool
AB_CXXWRAP_GET0_CONST
(isPositive,
AB_Value_IsPositive
);
77
78
int
AB_CXXWRAP_GET1_CONST
(compare,
const
Value
&,
AB_Value_Compare
);
79
bool
AB_CXXWRAP_GET1_CONST
(equal,
const
Value
&,
AB_Value_Equal
);
80
81
int
AB_CXXWRAP_GET1
(addValue,
const
Value
&,
AB_Value_AddValue
);
82
int
AB_CXXWRAP_GET1
(subValue,
const
Value
&,
AB_Value_SubValue
);
83
int
AB_CXXWRAP_GET1
(multValue,
const
Value
&,
AB_Value_MultValue
);
84
int
AB_CXXWRAP_GET1
(divValue,
const
Value
&,
AB_Value_DivValue
);
85
86
int
AB_CXXWRAP_GET0
(negate,
AB_Value_Negate
);
87
88
std::string
AB_CXXWRAP_GET0_CONST
(getCurrency,
AB_Value_GetCurrency
);
89
void
setCurrency
(
const
std::string& s)
90
{
91
AB_Value_SetCurrency
(m_ptr, s.c_str());
92
}
93
95
static
Value
fromString
(
const
std::string& s)
96
{
97
return
Value
(
AB_Value_fromString
(s.c_str()));
98
}
99
};
100
101
bool
operator==
(
const
Value
& v1,
const
Value
& v2)
102
{
103
return
v1.equal(v2);
104
}
105
bool
operator!=
(
const
Value
& v1,
const
Value
& v2)
106
{
107
return
!(v1 == v2);
108
}
109
bool
operator>
(
const
Value
& v1,
const
Value
& v2)
110
{
111
return
v1.compare(v2) > 0;
112
}
113
bool
operator<
(
const
Value
& v1,
const
Value
& v2)
114
{
115
return
v1.compare(v2) < 0;
116
}
117
118
}
// END namespace AB
119
120
121
#endif // AB_VALUE_HPP
122
Generated on Sun May 26 2013 06:38:22 for aqbanking by
1.8.3.1