-
Notifications
You must be signed in to change notification settings - Fork 2.1k
/
Var.h
2310 lines (1731 loc) · 56.3 KB
/
Var.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//
// Var.h
//
// Library: Foundation
// Package: Dynamic
// Module: Var
//
// Definition of the Var class.
//
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#ifndef Foundation_Var_INCLUDED
#define Foundation_Var_INCLUDED
#include "Poco/Foundation.h"
#include "Poco/Format.h"
#include "Poco/SharedPtr.h"
#include "Poco/OrderedMap.h"
#include "Poco/OrderedSet.h"
#include "Poco/Dynamic/VarHolder.h"
#include "Poco/Dynamic/VarIterator.h"
#include <typeinfo>
#include <map>
#include <set>
namespace Poco {
namespace Dynamic {
template <typename K, typename M, typename S>
class Struct;
class Foundation_API Var
/// Var allows to store data of different types and to convert between these types transparently.
/// Var puts forth the best effort to provide intuitive and reasonable conversion semantics and prevent
/// unexpected data loss, particularly when performing narrowing or signedness conversions of numeric data types.
///
/// An attempt to convert or extract from a non-initialized ("empty") Var variable shall result
/// in an exception being thrown.
///
/// Loss of signedness is not allowed for numeric values. This means that if an attempt is made to convert
/// the internal value which is a negative signed integer to an unsigned integer type storage, a RangeException is thrown.
/// Overflow is not allowed, so if the internal value is a larger number than the target numeric type size can accommodate,
/// a RangeException is thrown.
///
/// Precision loss, such as in conversion from floating-point types to integers or from double to float on platforms
/// where they differ in size (provided internal actual value fits in float min/max range), is allowed.
///
/// String truncation is allowed -- it is possible to convert between string and character when string length is
/// greater than 1. An empty string gets converted to the char '\0', a non-empty string is truncated to the first character.
///
/// Boolean conversion is performed as follows:
///
/// A string value "false" (not case sensitive), "0" or "" (empty string) can be converted to a boolean value false,
/// any other string not being false by the above criteria evaluates to true (e.g: "hi" -> true).
/// Integer 0 values are false, everything else is true.
/// Floating point values equal to the minimal FP representation on a given platform are false, everything else is true.
///
/// Arithmetic operations with POD types as well as between Var's are supported, subject to following
/// limitations:
///
/// - for std::string and const char* values, only '+' and '+=' operations are supported
///
/// - for integral and floating point numeric values, following operations are supported:
/// '+', '+=', '-', '-=', '*', '*=' , '/' and '/='
///
/// - for integral values, following operations are supported:
/// prefix and postfix increment (++) and decrement (--)
///
/// - for all other types, InvalidArgumentException is thrown upon attempt of an arithmetic operation
///
/// A Var can be created from and converted to a value of any type for which a specialization of
/// VarHolderImpl is available. For supported types, see VarHolder documentation.
{
public:
using Ptr = SharedPtr<Var>;
using Iterator = Poco::Dynamic::VarIterator;
using ConstIterator = const VarIterator;
Var();
/// Creates an empty Var.
template <typename T>
Var(const T& val)
/// Creates the Var from the given value.
{
construct(val);
}
Var(const char* pVal);
// Convenience constructor for const char* which gets mapped to a std::string internally, i.e. pVal is deep-copied.
Var(const Var& other);
/// Copy constructor.
~Var();
/// Destroys the Var.
void swap(Var& other);
/// Swaps the content of the this Var with the other Var.
ConstIterator begin() const;
/// Returns the const Var iterator.
ConstIterator end() const;
/// Returns the const Var iterator.
Iterator begin();
/// Returns the Var iterator.
Iterator end();
/// Returns the Var iterator.
template <typename T>
void convert(T& val) const
/// Invoke this method to perform a safe conversion.
///
/// Example usage:
/// Var any("42");
/// int i;
/// any.convert(i);
///
/// Throws a RangeException if the value does not fit
/// into the result variable.
/// Throws a NotImplementedException if conversion is
/// not available for the given type.
/// Throws InvalidAccessException if Var is empty.
{
VarHolder* pHolder = content();
if (!pHolder)
throw InvalidAccessException("Can not convert empty value.");
pHolder->convert(val);
}
template <typename T>
T convert() const
/// Invoke this method to perform a safe conversion.
///
/// Example usage:
/// Var any("42");
/// int i = any.convert<int>();
///
/// Throws a RangeException if the value does not fit
/// into the result variable.
/// Throws a NotImplementedException if conversion is
/// not available for the given type.
/// Throws InvalidAccessException if Var is empty.
{
VarHolder* pHolder = content();
if (!pHolder)
throw InvalidAccessException("Can not convert empty value.");
if (typeid(T) == pHolder->type()) return extract<T>();
T result;
pHolder->convert(result);
return result;
}
template <typename T>
operator T () const
/// Safe conversion operator for implicit type
/// conversions. If the requested type T is same as the
/// type being held, the operation performed is direct
/// extraction, otherwise it is the conversion of the value
/// from type currently held to the one requested.
///
/// Throws a RangeException if the value does not fit
/// into the result variable.
/// Throws a NotImplementedException if conversion is
/// not available for the given type.
/// Throws InvalidAccessException if Var is empty.
{
VarHolder* pHolder = content();
if (!pHolder)
throw InvalidAccessException("Can not convert empty value.");
if (typeid(T) == pHolder->type())
return extract<T>();
else
{
T result;
pHolder->convert(result);
return result;
}
}
template <typename T>
const T& extract() const
/// Returns a const reference to the actual value.
///
/// Must be instantiated with the exact type of
/// the stored value, otherwise a BadCastException
/// is thrown.
/// Throws InvalidAccessException if Var is empty.
{
VarHolder* pHolder = content();
if (pHolder && pHolder->type() == typeid(T))
{
VarHolderImpl<T>* pHolderImpl = static_cast<VarHolderImpl<T>*>(pHolder);
return pHolderImpl->value();
}
else if (!pHolder)
throw InvalidAccessException("Can not extract empty value.");
else
throw BadCastException(format("Can not convert %s to %s.",
std::string(pHolder->type().name()),
std::string(typeid(T).name())));
}
template <typename T>
Var& operator = (const T& other)
/// Assignment operator for assigning POD to Var
{
construct(other);
return *this;
}
bool operator ! () const;
/// Logical NOT operator.
Var& operator = (const Var& other);
/// Assignment operator specialization for Var
template <typename T>
const Var operator + (const T& other) const
/// Addition operator for adding POD to Var
{
return convert<T>() + other;
}
const Var operator + (const Var& other) const;
/// Addition operator specialization for Var
const Var operator + (const char* other) const;
/// Addition operator specialization for adding const char* to Var
Var& operator ++ ();
/// Pre-increment operator
const Var operator ++ (int);
/// Post-increment operator
Var& operator -- ();
/// Pre-decrement operator
const Var operator -- (int);
/// Post-decrement operator
template <typename T>
Var& operator += (const T& other)
/// Addition assignment operator for addition/assignment of POD to Var.
{
return *this = convert<T>() + other;
}
Var& operator += (const Var& other);
/// Addition assignment operator overload for Var
Var& operator += (const char* other);
/// Addition assignment operator overload for const char*
template <typename T>
const Var operator - (const T& other) const
/// Subtraction operator for subtracting POD from Var
{
return convert<T>() - other;
}
const Var operator - (const Var& other) const;
/// Subtraction operator overload for Var
template <typename T>
Var& operator -= (const T& other)
/// Subtraction assignment operator
{
return *this = convert<T>() - other;
}
Var& operator -= (const Var& other);
/// Subtraction assignment operator overload for Var
template <typename T>
const Var operator * (const T& other) const
/// Multiplication operator for multiplying Var with POD
{
return convert<T>() * other;
}
const Var operator * (const Var& other) const;
/// Multiplication operator overload for Var
template <typename T>
Var& operator *= (const T& other)
/// Multiplication assignment operator
{
return *this = convert<T>() * other;
}
Var& operator *= (const Var& other);
/// Multiplication assignment operator overload for Var
template <typename T>
const Var operator / (const T& other) const
/// Division operator for dividing Var with POD
{
return convert<T>() / other;
}
const Var operator / (const Var& other) const;
/// Division operator overload for Var
template <typename T>
Var& operator /= (const T& other)
/// Division assignment operator
{
return *this = convert<T>() / other;
}
Var& operator /= (const Var& other);
/// Division assignment operator specialization for Var
template <typename T>
bool operator == (const T& other) const
/// Equality operator
{
if (isEmpty()) return false;
return convert<T>() == other;
}
bool operator == (const char* other) const;
/// Equality operator overload for const char*
bool operator == (const Var& other) const;
/// Equality operator overload for Var
template <typename T>
bool operator != (const T& other) const
/// Inequality operator
{
if (isEmpty()) return true;
return convert<T>() != other;
}
bool operator != (const Var& other) const;
/// Inequality operator overload for Var
bool operator != (const char* other) const;
/// Inequality operator overload for const char*
template <typename T>
bool operator < (const T& other) const
/// Less than operator
{
if (isEmpty()) return false;
return convert<T>() < other;
}
bool operator < (const Var& other) const;
/// Less than operator overload for Var
template <typename T>
bool operator <= (const T& other) const
/// Less than or equal operator
{
if (isEmpty()) return false;
return convert<T>() <= other;
}
bool operator <= (const Var& other) const;
/// Less than or equal operator overload for Var
template <typename T>
bool operator > (const T& other) const
/// Greater than operator
{
if (isEmpty()) return false;
return convert<T>() > other;
}
bool operator > (const Var& other) const;
/// Greater than operator overload for Var
template <typename T>
bool operator >= (const T& other) const
/// Greater than or equal operator
{
if (isEmpty()) return false;
return convert<T>() >= other;
}
bool operator >= (const Var& other) const;
/// Greater than or equal operator overload for Var
template <typename T>
bool operator || (const T& other) const
/// Logical OR operator
{
if (isEmpty()) return false;
return convert<bool>() || other;
}
bool operator || (const Var& other) const;
/// Logical OR operator operator overload for Var
template <typename T>
bool operator && (const T& other) const
/// Logical AND operator.
{
if (isEmpty()) return false;
return convert<bool>() && other;
}
bool operator && (const Var& other) const;
/// Logical AND operator operator overload for Var.
bool isArray() const;
/// Returns true if Var is an array.
bool isVector() const;
/// Returns true if Var represents a vector.
bool isList() const;
/// Returns true if Var represents a list.
bool isDeque() const;
/// Returns true if Var represents a deque.
bool isStruct() const;
/// Returns true if Var represents a struct.
bool isOrdered() const;
/// Returns true if Var represents an ordered struct,
/// false if struct is sorted.
char& at(std::size_t n);
/// Returns character at position n. This function only works with
/// Var containing a std::string.
template <typename T>
Var& operator [] (const T& n)
{
return getAt(n);
}
template <typename T>
const Var& operator [] (const T& n) const
{
return const_cast<Var*>(this)->getAt(n);
}
Var& operator [] (const std::string& name);
/// Index operator by name, only use on Vars where isStruct
/// returns true! In all other cases InvalidAccessException is thrown.
const Var& operator [] (const std::string& name) const;
/// Index operator by name, only use on Vars where isStruct
/// returns true! In all other cases InvalidAccessException is thrown.
const std::type_info& type() const;
/// Returns the type information of the stored content.
//@ deprecated
void empty();
/// Empties Var.
/// This function is deprecated and will be removed.
/// Please use clear().
void clear();
/// Empties Var.
bool isEmpty() const;
/// Returns true if empty.
bool isInteger() const;
/// Returns true if stored value is integer.
bool isSigned() const;
/// Returns true if stored value is signed.
bool isNumeric() const;
/// Returns true if stored value is numeric.
/// Returns false for numeric strings (e.g. "123" is string, not number)
bool isBoolean() const;
/// Returns true if stored value is boolean.
/// Returns false for boolean strings (e.g. "true" is string, not number)
bool isString() const;
/// Returns true if stored value is std::string.
bool isDate() const;
/// Returns true if stored value represents a date.
bool isTime() const;
/// Returns true if stored value represents time or date/time.
bool isDateTime() const;
/// Returns true if stored value represents a date/time.
bool isUUID() const;
/// Returns true if stored value is a Poco::UUID.
std::size_t size() const;
/// Returns the size of this Var.
/// This function returns 0 when Var is empty, 1 for POD or the size (i.e. length)
/// for held container.
std::string toString() const
/// Returns the stored value as string.
{
VarHolder* pHolder = content();
if (!pHolder)
throw InvalidAccessException("Can not convert empty value.");
if (typeid(std::string) == pHolder->type())
return extract<std::string>();
else
{
std::string result;
pHolder->convert(result);
return result;
}
}
static Var parse(const std::string& val);
/// Parses the string which must be in JSON format
static std::string toString(const Var& var);
/// Converts the Var to a string in JSON format. Note that toString(const Var&) will return
/// a different result than Var::convert<std::string>() and Var::toString()!
private:
Var& getAt(std::size_t n);
Var& getAt(const std::string& n);
static Var parse(const std::string& val, std::string::size_type& offset);
/// Parses the string which must be in JSON format
static Var parseObject(const std::string& val, std::string::size_type& pos);
static Var parseArray(const std::string& val, std::string::size_type& pos);
static std::string parseString(const std::string& val, std::string::size_type& pos);
static std::string parseJSONString(const std::string& val, std::string::size_type& pos);
static void skipWhiteSpace(const std::string& val, std::string::size_type& pos);
template <typename T>
T add(const Var& other) const
{
return convert<T>() + other.convert<T>();
}
template <typename T>
T subtract(const Var& other) const
{
return convert<T>() - other.convert<T>();
}
template <typename T>
T multiply(const Var& other) const
{
return convert<T>() * other.convert<T>();
}
template <typename T>
T divide(const Var& other) const
{
return convert<T>() / other.convert<T>();
}
template <typename T, typename E>
VarHolderImpl<T>* holderImpl(const std::string errorMessage = "") const
{
VarHolder* pHolder = content();
if (pHolder && pHolder->type() == typeid(T))
return static_cast<VarHolderImpl<T>*>(pHolder);
else if (!pHolder)
throw InvalidAccessException("Can not access empty value.");
else
throw E(errorMessage);
}
template <typename T, typename N>
Var& structIndexOperator(T* pStr, N n) const
{
return pStr->operator[](n);
}
VarHolder* content() const
{
return _placeholder.content();
}
void destruct()
{
}
template<typename ValueType,
typename std::enable_if<TypeSizeLE<VarHolderImpl<ValueType>, Placeholder<ValueType>::Size::value>::value>::type* = nullptr>
void constructSOO(const ValueType& value)
{
_placeholder.assignStack<VarHolderImpl<ValueType>, ValueType>(value);
}
template<typename ValueType,
typename std::enable_if<TypeSizeGT<VarHolderImpl<ValueType>, Placeholder<ValueType>::Size::value>::value>::type* = nullptr>
void constructSOO(const ValueType& value)
{
_placeholder.assignHeap<VarHolderImpl<ValueType>, ValueType>(value);
}
template<typename ValueType>
void construct(const ValueType& value)
{
constructSOO(value);
}
void construct(const char* value)
{
std::string val(value);
constructSOO(val);
}
void construct(const Var& other)
{
_placeholder.erase();
if (!other.isEmpty())
other.content()->clone(&_placeholder);
}
Placeholder<VarHolder> _placeholder;
};
///
/// inlines
///
///
/// Var members
///
inline void Var::swap(Var& other)
{
if (this == &other) return;
if (!_placeholder.isLocal() && !other._placeholder.isLocal())
{
_placeholder.swap(other._placeholder);
}
else
{
Var tmp(*this);
try
{
construct(other);
other = tmp;
}
catch (...)
{
construct(tmp);
throw;
}
}
}
inline const std::type_info& Var::type() const
{
VarHolder* pHolder = content();
return pHolder ? pHolder->type() : typeid(void);
}
inline Var::ConstIterator Var::begin() const
{
if (size() == 0) return ConstIterator(const_cast<Var*>(this), true);
return ConstIterator(const_cast<Var*>(this), false);
}
inline Var::ConstIterator Var::end() const
{
return ConstIterator(const_cast<Var*>(this), true);
}
inline Var::Iterator Var::begin()
{
if (size() == 0) return Iterator(const_cast<Var*>(this), true);
return Iterator(const_cast<Var*>(this), false);
}
inline Var::Iterator Var::end()
{
return Iterator(this, true);
}
inline Var& Var::operator [] (const std::string& name)
{
return getAt(name);
}
inline const Var& Var::operator [] (const std::string& name) const
{
return const_cast<Var*>(this)->getAt(name);
}
inline const Var Var::operator + (const char* other) const
{
return convert<std::string>() + other;
}
inline Var& Var::operator += (const char*other)
{
return *this = convert<std::string>() + other;
}
inline bool Var::operator ! () const
{
return !convert<bool>();
}
inline bool Var::isEmpty() const
{
return 0 == content();
}
inline bool Var::isArray() const
{
if (isEmpty() || isString()) return false;
VarHolder* pHolder = content();
return pHolder ? pHolder->isArray() : false;
}
inline bool Var::isVector() const
{
VarHolder* pHolder = content();
return pHolder ? pHolder->isVector() : false;
}
inline bool Var::isList() const
{
VarHolder* pHolder = content();
return pHolder ? pHolder->isList() : false;
}
inline bool Var::isDeque() const
{
VarHolder* pHolder = content();
return pHolder ? pHolder->isDeque() : false;
}
inline bool Var::isStruct() const
{
VarHolder* pHolder = content();
return pHolder ? pHolder->isStruct() : false;
}
inline bool Var::isOrdered() const
{
VarHolder* pHolder = content();
return pHolder ? pHolder->isOrdered() : false;
}
inline bool Var::isInteger() const
{
VarHolder* pHolder = content();
return pHolder ? pHolder->isInteger() : false;
}
inline bool Var::isSigned() const
{
VarHolder* pHolder = content();
return pHolder ? pHolder->isSigned() : false;
}
inline bool Var::isNumeric() const
{
VarHolder* pHolder = content();
return pHolder ? pHolder->isNumeric() : false;
}
inline bool Var::isBoolean() const
{
VarHolder* pHolder = content();
return pHolder ? pHolder->isBoolean() : false;
}
inline bool Var::isString() const
{
VarHolder* pHolder = content();
return pHolder ? pHolder->isString() : false;
}
inline bool Var::isDate() const
{
VarHolder* pHolder = content();
return pHolder ? pHolder->isDate() : false;
}
inline bool Var::isTime() const
{
VarHolder* pHolder = content();
return pHolder ? pHolder->isTime() : false;
}
inline bool Var::isDateTime() const
{
VarHolder* pHolder = content();
return pHolder ? pHolder->isDateTime() : false;
}
inline bool Var::isUUID() const
{
VarHolder* pHolder = content();
return pHolder ? pHolder->isUUID() : false;
}
inline std::size_t Var::size() const
{
VarHolder* pHolder = content();
return pHolder ? pHolder->size() : 0;
}
///
/// Var non-member functions
///
inline const Var operator + (const char* other, const Var& da)
/// Addition operator for adding Var to const char*
{
std::string tmp = other;
return tmp + da.convert<std::string>();
}
inline char operator + (const char& other, const Var& da)
/// Addition operator for adding Var to char
{
return other + da.convert<char>();
}
inline char operator - (const char& other, const Var& da)
/// Subtraction operator for subtracting Var from char
{
return other - da.convert<char>();
}
inline char operator * (const char& other, const Var& da)
/// Multiplication operator for multiplying Var with char
{
return other * da.convert<char>();
}
inline char operator / (const char& other, const Var& da)
/// Division operator for dividing Var with char
{
return other / da.convert<char>();
}
inline char operator += (char& other, const Var& da)
/// Addition assignment operator for adding Var to char
{
return other += da.convert<char>();
}
inline char operator -= (char& other, const Var& da)
/// Subtraction assignment operator for subtracting Var from char
{
return other -= da.convert<char>();
}
inline char operator *= (char& other, const Var& da)
/// Multiplication assignment operator for multiplying Var with char
{
return other *= da.convert<char>();
}
inline char operator /= (char& other, const Var& da)
/// Division assignment operator for dividing Var with char
{
return other /= da.convert<char>();
}
inline bool operator == (const char& other, const Var& da)
/// Equality operator for comparing Var with char
{
if (da.isEmpty()) return false;
return other == da.convert<char>();
}
inline bool operator != (const char& other, const Var& da)
/// Inequality operator for comparing Var with char
{
if (da.isEmpty()) return true;
return other != da.convert<char>();
}
inline bool operator < (const char& other, const Var& da)
/// Less than operator for comparing Var with char
{
if (da.isEmpty()) return false;
return other < da.convert<char>();
}
inline bool operator <= (const char& other, const Var& da)
/// Less than or equal operator for comparing Var with char
{
if (da.isEmpty()) return false;
return other <= da.convert<char>();
}
inline bool operator > (const char& other, const Var& da)
/// Greater than operator for comparing Var with char
{
if (da.isEmpty())return false;
return other > da.convert<char>();
}
inline bool operator >= (const char& other, const Var& da)
/// Greater than or equal operator for comparing Var with char
{
if (da.isEmpty())return false;
return other >= da.convert<char>();
}
inline Poco::Int8 operator + (const Poco::Int8& other, const Var& da)
/// Addition operator for adding Var to Poco::Int8
{
return other + da.convert<Poco::Int8>();
}
inline Poco::Int8 operator - (const Poco::Int8& other, const Var& da)
/// Subtraction operator for subtracting Var from Poco::Int8
{
return other - da.convert<Poco::Int8>();
}
inline Poco::Int8 operator * (const Poco::Int8& other, const Var& da)
/// Multiplication operator for multiplying Var with Poco::Int8
{
return other * da.convert<Poco::Int8>();
}