GnuCash c935c2f+
Loading...
Searching...
No Matches
Public Member Functions
compare_visitor Struct Reference
Inheritance diagram for compare_visitor:

Public Member Functions

template<typename T , typename U >
int operator() (T &one, U &two) const
 
template<typename T >
int operator() (T &one, T &two) const
 
template<>
int operator() (const char *const &one, const char *const &two) const
 
template<>
int operator() (gnc_numeric const &one, gnc_numeric const &two) const
 
template<>
int operator() (GncGUID *const &one, GncGUID *const &two) const
 
template<>
int operator() (Time64 const &one, Time64 const &two) const
 
template<>
int operator() (GDate const &one, GDate const &two) const
 
template<>
int operator() (GList *const &one, GList *const &two) const
 
template<>
int operator() (KvpFrame *const &one, KvpFrame *const &two) const
 
template<>
int operator() (double const &one, double const &two) const
 

Detailed Description

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

Member Function Documentation

◆ operator()() [1/10]

template<>
int compare_visitor::operator() ( const char *const &  one,
const char *const &  two 
) const

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

275{
276 return strcmp(one, two);
277}

◆ operator()() [2/10]

template<>
int compare_visitor::operator() ( double const &  one,
double const &  two 
) const

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

303{
304 if (std::isnan(one) && std::isnan(two))
305 return 0;
306 if (one < two) return -1;
307 if (two < one) return 1;
308 return 0;
309}

◆ operator()() [3/10]

template<>
int compare_visitor::operator() ( GDate const &  one,
GDate const &  two 
) const

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

291{
292 return g_date_compare(&one,&two);
293}

◆ operator()() [4/10]

template<>
int compare_visitor::operator() ( GList *const &  one,
GList *const &  two 
) const

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

295{
296 return kvp_glist_compare(one, two);
297}

◆ operator()() [5/10]

template<>
int compare_visitor::operator() ( gnc_numeric const &  one,
gnc_numeric const &  two 
) const

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

279{
280 return gnc_numeric_compare(one, two);
281}
int gnc_numeric_compare(gnc_numeric a, gnc_numeric b)
Returns 1 if a>b, -1 if b>a, 0 if a == b

◆ operator()() [6/10]

template<>
int compare_visitor::operator() ( GncGUID *const &  one,
GncGUID *const &  two 
) const

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

283{
284 return guid_compare(one, two);
285}

◆ operator()() [7/10]

template<>
int compare_visitor::operator() ( KvpFrame *const &  one,
KvpFrame *const &  two 
) const

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

299{
300 return compare(one, two);
301}

◆ operator()() [8/10]

template<typename T >
int compare_visitor::operator() ( T &  one,
T &  two 
) const
inline

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

265 {
266 /*This will work for any type that implements < and ==.*/
267 if (one < two)
268 return -1;
269 if (two < one)
270 return 1;
271 return 0;
272 }

◆ operator()() [9/10]

template<typename T , typename U >
int compare_visitor::operator() ( T &  one,
U &  two 
) const
inline

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

259 {
260 throw std::invalid_argument{"You may not compare objects of different type."};
261 }

◆ operator()() [10/10]

template<>
int compare_visitor::operator() ( Time64 const &  one,
Time64 const &  two 
) const

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

287{
288 return one.t < two.t ? -1 : one.t > two.t ? 1 : 0;
289}

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