GnuCash c935c2f+
Loading...
Searching...
No Matches
Public Member Functions | Data Fields
to_string_visitor Struct Reference
Inheritance diagram for to_string_visitor:

Public Member Functions

 to_string_visitor (std::ostringstream &val)
 
void operator() (int64_t val)
 
void operator() (KvpFrame *val)
 
void operator() (GDate val)
 
void operator() (GList *val)
 
void operator() (Time64 val)
 
void operator() (gnc_numeric val)
 
void operator() (GncGUID *val)
 
void operator() (const char *val)
 
void operator() (double val)
 

Data Fields

std::ostringstream & output
 

Detailed Description

Definition at line 102 of file kvp-value.cpp.

Constructor & Destructor Documentation

◆ to_string_visitor()

to_string_visitor::to_string_visitor ( std::ostringstream &  val)
inline

Definition at line 106 of file kvp-value.cpp.

106: output(val){}

Member Function Documentation

◆ operator()() [1/9]

void to_string_visitor::operator() ( const char *  val)
inline

Definition at line 177 of file kvp-value.cpp.

178 {
179 output << val << " (char *)";
180 }

◆ operator()() [2/9]

void to_string_visitor::operator() ( double  val)
inline

Definition at line 182 of file kvp-value.cpp.

183 {
184 output << val << " (double)";
185 }

◆ operator()() [3/9]

void to_string_visitor::operator() ( GDate  val)
inline

Definition at line 118 of file kvp-value.cpp.

119 {
120 output << std::setw(4) << g_date_get_year(&val) << '-';
121 output << std::setw(2) << g_date_get_month(&val) << '-';
122 output << std::setw(2) << g_date_get_day(&val);
123 output << " (gdate)";
124 }

◆ operator()() [4/9]

void to_string_visitor::operator() ( GList *  val)
inline

Definition at line 126 of file kvp-value.cpp.

127 {
128 output << "KVP_VALUE_GLIST(";
129 output << "[ ";
130 /*Since val is passed by value, we can modify it*/
131 for (;val; val = val->next)
132 {
133 auto realvalue = static_cast<const KvpValue *>(val->data);
134 output << ' ' << realvalue->to_string() << ',';
135 }
136 output << " ]";
137 output << ")";
138 }

◆ operator()() [5/9]

void to_string_visitor::operator() ( gnc_numeric  val)
inline

Definition at line 147 of file kvp-value.cpp.

148 {
149 auto tmp1 = gnc_numeric_to_string(val);
150 if (tmp1)
151 {
152 output << tmp1;
153 g_free(tmp1);
154 }
155 else
156 {
157 output << "(null)";
158 }
159 output << " (gnc_numeric)";
160 }
gchar * gnc_numeric_to_string(gnc_numeric n)
Convert to string.

◆ operator()() [6/9]

void to_string_visitor::operator() ( GncGUID val)
inline

Definition at line 162 of file kvp-value.cpp.

163 {
164 char guidstr[GUID_ENCODING_LENGTH+1];
165 if (val)
166 {
167 guid_to_string_buff(val,guidstr);
168 output << guidstr;
169 }
170 else
171 {
172 output << "(null)";
173 }
174 output << " (guid)";
175 }
#define GUID_ENCODING_LENGTH
Number of characters needed to encode a guid as a string not including the null terminator.
Definition guid.h:84
gchar * guid_to_string_buff(const GncGUID *guid, gchar *str)
The guid_to_string_buff() routine puts a null-terminated string encoding of the id into the memory po...
Definition guid.cpp:208

◆ operator()() [7/9]

void to_string_visitor::operator() ( int64_t  val)
inline

Definition at line 108 of file kvp-value.cpp.

109 {
110 output << val << " (64-bit int)";
111 }

◆ operator()() [8/9]

void to_string_visitor::operator() ( KvpFrame *  val)
inline

Definition at line 113 of file kvp-value.cpp.

114 {
115 output << val->to_string();
116 }

◆ operator()() [9/9]

void to_string_visitor::operator() ( Time64  val)
inline

Definition at line 140 of file kvp-value.cpp.

141 {
142 char tmp1[MAX_DATE_LENGTH + 1] {};
143 gnc_time64_to_iso8601_buff (val.t, tmp1);
144 output << tmp1 << " (time64)";
145 }
char * gnc_time64_to_iso8601_buff(time64 time, char *buff)
The gnc_time64_to_iso8601_buff() routine takes the input UTC time64 value and prints it as an ISO-860...
#define MAX_DATE_LENGTH
The maximum length of a string created by the date printers.
Definition gnc-date.h:108

Field Documentation

◆ output

std::ostringstream& to_string_visitor::output

Definition at line 104 of file kvp-value.cpp.


The documentation for this struct was generated from the following file: