1 | // |
2 | // Var.h |
3 | // |
4 | // Library: Foundation |
5 | // Package: Dynamic |
6 | // Module: Var |
7 | // |
8 | // Definition of the Var class. |
9 | // |
10 | // Copyright (c) 2007, Applied Informatics Software Engineering GmbH. |
11 | // and Contributors. |
12 | // |
13 | // SPDX-License-Identifier: BSL-1.0 |
14 | // |
15 | |
16 | |
17 | #ifndef Foundation_Var_INCLUDED |
18 | #define Foundation_Var_INCLUDED |
19 | |
20 | |
21 | #include "Poco/Foundation.h" |
22 | #include "Poco/Format.h" |
23 | #include "Poco/SharedPtr.h" |
24 | #include "Poco/Dynamic/VarHolder.h" |
25 | #include "Poco/Dynamic/VarIterator.h" |
26 | #include <typeinfo> |
27 | |
28 | |
29 | namespace Poco { |
30 | namespace Dynamic { |
31 | |
32 | |
33 | template <typename T> |
34 | class Struct; |
35 | |
36 | |
37 | class Foundation_API Var |
38 | /// Var allows to store data of different types and to convert between these types transparently. |
39 | /// Var puts forth the best effort to provide intuitive and reasonable conversion semantics and prevent |
40 | /// unexpected data loss, particularly when performing narrowing or signedness conversions of numeric data types. |
41 | /// |
42 | /// An attempt to convert or extract from a non-initialized ("empty") Var variable shall result |
43 | /// in an exception being thrown. |
44 | /// |
45 | /// Loss of signedness is not allowed for numeric values. This means that if an attempt is made to convert |
46 | /// the internal value which is a negative signed integer to an unsigned integer type storage, a RangeException is thrown. |
47 | /// Overflow is not allowed, so if the internal value is a larger number than the target numeric type size can accommodate, |
48 | /// a RangeException is thrown. |
49 | /// |
50 | /// Precision loss, such as in conversion from floating-point types to integers or from double to float on platforms |
51 | /// where they differ in size (provided internal actual value fits in float min/max range), is allowed. |
52 | /// |
53 | /// String truncation is allowed -- it is possible to convert between string and character when string length is |
54 | /// greater than 1. An empty string gets converted to the char '\0', a non-empty string is truncated to the first character. |
55 | /// |
56 | /// Boolean conversion is performed as follows: |
57 | /// |
58 | /// A string value "false" (not case sensitive), "0" or "" (empty string) can be converted to a boolean value false, |
59 | /// any other string not being false by the above criteria evaluates to true (e.g: "hi" -> true). |
60 | /// Integer 0 values are false, everything else is true. |
61 | /// Floating point values equal to the minimal FP representation on a given platform are false, everything else is true. |
62 | /// |
63 | /// Arithmetic operations with POD types as well as between Var's are supported, subject to following |
64 | /// limitations: |
65 | /// |
66 | /// - for std::string and const char* values, only '+' and '+=' operations are supported |
67 | /// |
68 | /// - for integral and floating point numeric values, following operations are supported: |
69 | /// '+', '+=', '-', '-=', '*', '*=' , '/' and '/=' |
70 | /// |
71 | /// - for integral values, following operations are supported: |
72 | /// prefix and postfix increment (++) and decrement (--) |
73 | /// |
74 | /// - for all other types, InvalidArgumentException is thrown upon attempt of an arithmetic operation |
75 | /// |
76 | /// A Var can be created from and converted to a value of any type for which a specialization of |
77 | /// VarHolderImpl is available. For supported types, see VarHolder documentation. |
78 | { |
79 | public: |
80 | typedef SharedPtr<Var> Ptr; |
81 | typedef Poco::Dynamic::VarIterator Iterator; |
82 | typedef const VarIterator ConstIterator; |
83 | |
84 | Var(); |
85 | /// Creates an empty Var. |
86 | |
87 | template <typename T> |
88 | Var(const T& val) |
89 | /// Creates the Var from the given value. |
90 | #ifdef POCO_NO_SOO |
91 | : _pHolder(new VarHolderImpl<T>(val)) |
92 | { |
93 | } |
94 | #else |
95 | { |
96 | construct(val); |
97 | } |
98 | #endif |
99 | |
100 | Var(const char* pVal); |
101 | // Convenience constructor for const char* which gets mapped to a std::string internally, i.e. pVal is deep-copied. |
102 | |
103 | Var(const Var& other); |
104 | /// Copy constructor. |
105 | |
106 | ~Var(); |
107 | /// Destroys the Var. |
108 | |
109 | void swap(Var& other); |
110 | /// Swaps the content of the this Var with the other Var. |
111 | |
112 | ConstIterator begin() const; |
113 | /// Returns the const Var iterator. |
114 | |
115 | ConstIterator end() const; |
116 | /// Returns the const Var iterator. |
117 | |
118 | Iterator begin(); |
119 | /// Returns the Var iterator. |
120 | |
121 | Iterator end(); |
122 | /// Returns the Var iterator. |
123 | |
124 | template <typename T> |
125 | void convert(T& val) const |
126 | /// Invoke this method to perform a safe conversion. |
127 | /// |
128 | /// Example usage: |
129 | /// Var any("42"); |
130 | /// int i; |
131 | /// any.convert(i); |
132 | /// |
133 | /// Throws a RangeException if the value does not fit |
134 | /// into the result variable. |
135 | /// Throws a NotImplementedException if conversion is |
136 | /// not available for the given type. |
137 | /// Throws InvalidAccessException if Var is empty. |
138 | { |
139 | VarHolder* pHolder = content(); |
140 | |
141 | if (!pHolder) |
142 | throw InvalidAccessException("Can not convert empty value." ); |
143 | |
144 | pHolder->convert(val); |
145 | } |
146 | |
147 | template <typename T> |
148 | T convert() const |
149 | /// Invoke this method to perform a safe conversion. |
150 | /// |
151 | /// Example usage: |
152 | /// Var any("42"); |
153 | /// int i = any.convert<int>(); |
154 | /// |
155 | /// Throws a RangeException if the value does not fit |
156 | /// into the result variable. |
157 | /// Throws a NotImplementedException if conversion is |
158 | /// not available for the given type. |
159 | /// Throws InvalidAccessException if Var is empty. |
160 | { |
161 | VarHolder* pHolder = content(); |
162 | |
163 | if (!pHolder) |
164 | throw InvalidAccessException("Can not convert empty value." ); |
165 | |
166 | if (typeid(T) == pHolder->type()) return extract<T>(); |
167 | |
168 | T result; |
169 | pHolder->convert(result); |
170 | return result; |
171 | } |
172 | |
173 | template <typename T> |
174 | operator T () const |
175 | /// Safe conversion operator for implicit type |
176 | /// conversions. If the requested type T is same as the |
177 | /// type being held, the operation performed is direct |
178 | /// extraction, otherwise it is the conversion of the value |
179 | /// from type currently held to the one requested. |
180 | /// |
181 | /// Throws a RangeException if the value does not fit |
182 | /// into the result variable. |
183 | /// Throws a NotImplementedException if conversion is |
184 | /// not available for the given type. |
185 | /// Throws InvalidAccessException if Var is empty. |
186 | { |
187 | VarHolder* pHolder = content(); |
188 | |
189 | if (!pHolder) |
190 | throw InvalidAccessException("Can not convert empty value." ); |
191 | |
192 | if (typeid(T) == pHolder->type()) |
193 | return extract<T>(); |
194 | else |
195 | { |
196 | T result; |
197 | pHolder->convert(result); |
198 | return result; |
199 | } |
200 | } |
201 | |
202 | template <typename T> |
203 | const T& () const |
204 | /// Returns a const reference to the actual value. |
205 | /// |
206 | /// Must be instantiated with the exact type of |
207 | /// the stored value, otherwise a BadCastException |
208 | /// is thrown. |
209 | /// Throws InvalidAccessException if Var is empty. |
210 | { |
211 | VarHolder* pHolder = content(); |
212 | |
213 | if (pHolder && pHolder->type() == typeid(T)) |
214 | { |
215 | VarHolderImpl<T>* pHolderImpl = static_cast<VarHolderImpl<T>*>(pHolder); |
216 | return pHolderImpl->value(); |
217 | } |
218 | else if (!pHolder) |
219 | throw InvalidAccessException("Can not extract empty value." ); |
220 | else |
221 | throw BadCastException(format("Can not convert %s to %s." , |
222 | std::string(pHolder->type().name()), |
223 | std::string(typeid(T).name()))); |
224 | } |
225 | |
226 | template <typename T> |
227 | Var& operator = (const T& other) |
228 | /// Assignment operator for assigning POD to Var |
229 | { |
230 | #ifdef POCO_NO_SOO |
231 | Var tmp(other); |
232 | swap(tmp); |
233 | #else |
234 | construct(other); |
235 | #endif |
236 | return *this; |
237 | } |
238 | |
239 | bool operator ! () const; |
240 | /// Logical NOT operator. |
241 | |
242 | Var& operator = (const Var& other); |
243 | /// Assignment operator specialization for Var |
244 | |
245 | template <typename T> |
246 | const Var operator + (const T& other) const |
247 | /// Addition operator for adding POD to Var |
248 | { |
249 | return convert<T>() + other; |
250 | } |
251 | |
252 | const Var operator + (const Var& other) const; |
253 | /// Addition operator specialization for Var |
254 | |
255 | const Var operator + (const char* other) const; |
256 | /// Addition operator specialization for adding const char* to Var |
257 | |
258 | Var& operator ++ (); |
259 | /// Pre-increment operator |
260 | |
261 | const Var operator ++ (int); |
262 | /// Post-increment operator |
263 | |
264 | Var& operator -- (); |
265 | /// Pre-decrement operator |
266 | |
267 | const Var operator -- (int); |
268 | /// Post-decrement operator |
269 | |
270 | template <typename T> |
271 | Var& operator += (const T& other) |
272 | /// Addition assignment operator for addition/assignment of POD to Var. |
273 | { |
274 | return *this = convert<T>() + other; |
275 | } |
276 | |
277 | Var& operator += (const Var& other); |
278 | /// Addition assignment operator overload for Var |
279 | |
280 | Var& operator += (const char* other); |
281 | /// Addition assignment operator overload for const char* |
282 | |
283 | template <typename T> |
284 | const Var operator - (const T& other) const |
285 | /// Subtraction operator for subtracting POD from Var |
286 | { |
287 | return convert<T>() - other; |
288 | } |
289 | |
290 | const Var operator - (const Var& other) const; |
291 | /// Subtraction operator overload for Var |
292 | |
293 | template <typename T> |
294 | Var& operator -= (const T& other) |
295 | /// Subtraction assignment operator |
296 | { |
297 | return *this = convert<T>() - other; |
298 | } |
299 | |
300 | Var& operator -= (const Var& other); |
301 | /// Subtraction assignment operator overload for Var |
302 | |
303 | template <typename T> |
304 | const Var operator * (const T& other) const |
305 | /// Multiplication operator for multiplying Var with POD |
306 | { |
307 | return convert<T>() * other; |
308 | } |
309 | |
310 | const Var operator * (const Var& other) const; |
311 | /// Multiplication operator overload for Var |
312 | |
313 | template <typename T> |
314 | Var& operator *= (const T& other) |
315 | /// Multiplication assignment operator |
316 | { |
317 | return *this = convert<T>() * other; |
318 | } |
319 | |
320 | Var& operator *= (const Var& other); |
321 | /// Multiplication assignment operator overload for Var |
322 | |
323 | template <typename T> |
324 | const Var operator / (const T& other) const |
325 | /// Division operator for dividing Var with POD |
326 | { |
327 | return convert<T>() / other; |
328 | } |
329 | |
330 | const Var operator / (const Var& other) const; |
331 | /// Division operator overload for Var |
332 | |
333 | template <typename T> |
334 | Var& operator /= (const T& other) |
335 | /// Division assignment operator |
336 | { |
337 | return *this = convert<T>() / other; |
338 | } |
339 | |
340 | Var& operator /= (const Var& other); |
341 | /// Division assignment operator specialization for Var |
342 | |
343 | template <typename T> |
344 | bool operator == (const T& other) const |
345 | /// Equality operator |
346 | { |
347 | if (isEmpty()) return false; |
348 | return convert<T>() == other; |
349 | } |
350 | |
351 | bool operator == (const char* other) const; |
352 | /// Equality operator overload for const char* |
353 | |
354 | bool operator == (const Var& other) const; |
355 | /// Equality operator overload for Var |
356 | |
357 | template <typename T> |
358 | bool operator != (const T& other) const |
359 | /// Inequality operator |
360 | { |
361 | if (isEmpty()) return true; |
362 | return convert<T>() != other; |
363 | } |
364 | |
365 | bool operator != (const Var& other) const; |
366 | /// Inequality operator overload for Var |
367 | |
368 | bool operator != (const char* other) const; |
369 | /// Inequality operator overload for const char* |
370 | |
371 | template <typename T> |
372 | bool operator < (const T& other) const |
373 | /// Less than operator |
374 | { |
375 | if (isEmpty()) return false; |
376 | return convert<T>() < other; |
377 | } |
378 | |
379 | bool operator < (const Var& other) const; |
380 | /// Less than operator overload for Var |
381 | |
382 | template <typename T> |
383 | bool operator <= (const T& other) const |
384 | /// Less than or equal operator |
385 | { |
386 | if (isEmpty()) return false; |
387 | return convert<T>() <= other; |
388 | } |
389 | |
390 | bool operator <= (const Var& other) const; |
391 | /// Less than or equal operator overload for Var |
392 | |
393 | template <typename T> |
394 | bool operator > (const T& other) const |
395 | /// Greater than operator |
396 | { |
397 | if (isEmpty()) return false; |
398 | return convert<T>() > other; |
399 | } |
400 | |
401 | bool operator > (const Var& other) const; |
402 | /// Greater than operator overload for Var |
403 | |
404 | template <typename T> |
405 | bool operator >= (const T& other) const |
406 | /// Greater than or equal operator |
407 | { |
408 | if (isEmpty()) return false; |
409 | return convert<T>() >= other; |
410 | } |
411 | |
412 | bool operator >= (const Var& other) const; |
413 | /// Greater than or equal operator overload for Var |
414 | |
415 | template <typename T> |
416 | bool operator || (const T& other) const |
417 | /// Logical OR operator |
418 | { |
419 | if (isEmpty()) return false; |
420 | return convert<bool>() || other; |
421 | } |
422 | |
423 | bool operator || (const Var& other) const; |
424 | /// Logical OR operator operator overload for Var |
425 | |
426 | template <typename T> |
427 | bool operator && (const T& other) const |
428 | /// Logical AND operator. |
429 | { |
430 | if (isEmpty()) return false; |
431 | return convert<bool>() && other; |
432 | } |
433 | |
434 | bool operator && (const Var& other) const; |
435 | /// Logical AND operator operator overload for Var. |
436 | |
437 | bool isArray() const; |
438 | /// Returns true if Var is an array. |
439 | |
440 | bool isVector() const; |
441 | /// Returns true if Var represents a vector. |
442 | |
443 | bool isList() const; |
444 | /// Returns true if Var represents a list. |
445 | |
446 | bool isDeque() const; |
447 | /// Returns true if Var represents a deque. |
448 | |
449 | bool isStruct() const; |
450 | /// Returns true if Var represents a struct. |
451 | |
452 | char& at(std::size_t n); |
453 | /// Returns character at position n. This function only works with |
454 | /// Var containing a std::string. |
455 | |
456 | |
457 | template <typename T> |
458 | Var& operator [] (const T& n) |
459 | { |
460 | return getAt(n); |
461 | } |
462 | |
463 | template <typename T> |
464 | const Var& operator [] (const T& n) const |
465 | { |
466 | return const_cast<Var*>(this)->getAt(n); |
467 | } |
468 | |
469 | Var& operator [] (const std::string& name); |
470 | /// Index operator by name, only use on Vars where isStruct |
471 | /// returns true! In all other cases InvalidAccessException is thrown. |
472 | |
473 | const Var& operator [] (const std::string& name) const; |
474 | /// Index operator by name, only use on Vars where isStruct |
475 | /// returns true! In all other cases InvalidAccessException is thrown. |
476 | |
477 | const std::type_info& type() const; |
478 | /// Returns the type information of the stored content. |
479 | |
480 | //@ deprecated |
481 | void empty(); |
482 | /// Empties Var. |
483 | /// This function is deprecated and will be removed. |
484 | /// Please use clear(). |
485 | |
486 | void clear(); |
487 | /// Empties Var. |
488 | |
489 | bool isEmpty() const; |
490 | /// Returns true if empty. |
491 | |
492 | bool isInteger() const; |
493 | /// Returns true if stored value is integer. |
494 | |
495 | bool isSigned() const; |
496 | /// Returns true if stored value is signed. |
497 | |
498 | bool isNumeric() const; |
499 | /// Returns true if stored value is numeric. |
500 | /// Returns false for numeric strings (e.g. "123" is string, not number) |
501 | |
502 | bool isBoolean() const; |
503 | /// Returns true if stored value is boolean. |
504 | /// Returns false for boolean strings (e.g. "true" is string, not number) |
505 | |
506 | bool isString() const; |
507 | /// Returns true if stored value is std::string. |
508 | |
509 | bool isDate() const; |
510 | /// Returns true if stored value represents a date. |
511 | |
512 | bool isTime() const; |
513 | /// Returns true if stored value represents time or date/time. |
514 | |
515 | bool isDateTime() const; |
516 | /// Returns true if stored value represents a date/time. |
517 | |
518 | std::size_t size() const; |
519 | /// Returns the size of this Var. |
520 | /// This function returns 0 when Var is empty, 1 for POD or the size (i.e. length) |
521 | /// for held container. |
522 | |
523 | std::string toString() const |
524 | /// Returns the stored value as string. |
525 | { |
526 | VarHolder* pHolder = content(); |
527 | |
528 | if (!pHolder) |
529 | throw InvalidAccessException("Can not convert empty value." ); |
530 | |
531 | if (typeid(std::string) == pHolder->type()) |
532 | return extract<std::string>(); |
533 | else |
534 | { |
535 | std::string result; |
536 | pHolder->convert(result); |
537 | return result; |
538 | } |
539 | } |
540 | |
541 | static Var parse(const std::string& val); |
542 | /// Parses the string which must be in JSON format |
543 | |
544 | static std::string toString(const Var& var); |
545 | /// Converts the Var to a string in JSON format. Note that toString(const Var&) will return |
546 | /// a different result than Var::convert<std::string>() and Var::toString()! |
547 | |
548 | private: |
549 | Var& getAt(std::size_t n); |
550 | Var& getAt(const std::string& n); |
551 | |
552 | static Var parse(const std::string& val, std::string::size_type& offset); |
553 | /// Parses the string which must be in JSON format |
554 | |
555 | static Var parseObject(const std::string& val, std::string::size_type& pos); |
556 | static Var parseArray(const std::string& val, std::string::size_type& pos); |
557 | static std::string parseString(const std::string& val, std::string::size_type& pos); |
558 | static std::string parseJSONString(const std::string& val, std::string::size_type& pos); |
559 | static void skipWhiteSpace(const std::string& val, std::string::size_type& pos); |
560 | |
561 | template <typename T> |
562 | T add(const Var& other) const |
563 | { |
564 | return convert<T>() + other.convert<T>(); |
565 | } |
566 | |
567 | template <typename T> |
568 | T subtract(const Var& other) const |
569 | { |
570 | return convert<T>() - other.convert<T>(); |
571 | } |
572 | |
573 | template <typename T> |
574 | T multiply(const Var& other) const |
575 | { |
576 | return convert<T>() * other.convert<T>(); |
577 | } |
578 | |
579 | template <typename T> |
580 | T divide(const Var& other) const |
581 | { |
582 | return convert<T>() / other.convert<T>(); |
583 | } |
584 | |
585 | template <typename T, typename E> |
586 | VarHolderImpl<T>* holderImpl(const std::string errorMessage = "" ) const |
587 | { |
588 | VarHolder* pHolder = content(); |
589 | |
590 | if (pHolder && pHolder->type() == typeid(T)) |
591 | return static_cast<VarHolderImpl<T>*>(pHolder); |
592 | else if (!pHolder) |
593 | throw InvalidAccessException("Can not access empty value." ); |
594 | else |
595 | throw E(errorMessage); |
596 | } |
597 | |
598 | Var& structIndexOperator(VarHolderImpl<Struct<int> >* pStr, int n) const; |
599 | |
600 | #ifdef POCO_NO_SOO |
601 | |
602 | VarHolder* content() const |
603 | { |
604 | return _pHolder; |
605 | } |
606 | |
607 | void destruct() |
608 | { |
609 | if (!isEmpty()) delete content(); |
610 | } |
611 | |
612 | VarHolder* _pHolder; |
613 | |
614 | #else |
615 | |
616 | VarHolder* content() const |
617 | { |
618 | return _placeholder.content(); |
619 | } |
620 | |
621 | template<typename ValueType> |
622 | void construct(const ValueType& value) |
623 | { |
624 | if (sizeof(VarHolderImpl<ValueType>) <= Placeholder<ValueType>::Size::value) |
625 | { |
626 | new (reinterpret_cast<VarHolder*>(_placeholder.holder)) VarHolderImpl<ValueType>(value); |
627 | _placeholder.setLocal(true); |
628 | } |
629 | else |
630 | { |
631 | _placeholder.pHolder = new VarHolderImpl<ValueType>(value); |
632 | _placeholder.setLocal(false); |
633 | } |
634 | } |
635 | |
636 | void construct(const char* value) |
637 | { |
638 | std::string val(value); |
639 | if (sizeof(VarHolderImpl<std::string>) <= Placeholder<std::string>::Size::value) |
640 | { |
641 | new (reinterpret_cast<VarHolder*>(_placeholder.holder)) VarHolderImpl<std::string>(val); |
642 | _placeholder.setLocal(true); |
643 | } |
644 | else |
645 | { |
646 | _placeholder.pHolder = new VarHolderImpl<std::string>(val); |
647 | _placeholder.setLocal(false); |
648 | } |
649 | } |
650 | |
651 | void construct(const Var& other) |
652 | { |
653 | if (!other.isEmpty()) |
654 | other.content()->clone(&_placeholder); |
655 | else |
656 | _placeholder.erase(); |
657 | } |
658 | |
659 | void destruct() |
660 | { |
661 | if (!isEmpty()) |
662 | { |
663 | if (_placeholder.isLocal()) |
664 | content()->~VarHolder(); |
665 | else |
666 | delete content(); |
667 | } |
668 | } |
669 | |
670 | Placeholder<VarHolder> _placeholder; |
671 | |
672 | #endif // POCO_NO_SOO |
673 | }; |
674 | |
675 | |
676 | /// |
677 | /// inlines |
678 | /// |
679 | |
680 | |
681 | /// |
682 | /// Var members |
683 | /// |
684 | |
685 | inline void Var::swap(Var& other) |
686 | { |
687 | #ifdef POCO_NO_SOO |
688 | |
689 | std::swap(_pHolder, other._pHolder); |
690 | |
691 | #else |
692 | |
693 | if (this == &other) return; |
694 | |
695 | if (!_placeholder.isLocal() && !other._placeholder.isLocal()) |
696 | { |
697 | std::swap(_placeholder.pHolder, other._placeholder.pHolder); |
698 | } |
699 | else |
700 | { |
701 | Var tmp(*this); |
702 | try |
703 | { |
704 | if (_placeholder.isLocal()) destruct(); |
705 | construct(other); |
706 | other = tmp; |
707 | } |
708 | catch (...) |
709 | { |
710 | construct(tmp); |
711 | throw; |
712 | } |
713 | } |
714 | |
715 | #endif |
716 | } |
717 | |
718 | |
719 | inline const std::type_info& Var::type() const |
720 | { |
721 | VarHolder* pHolder = content(); |
722 | return pHolder ? pHolder->type() : typeid(void); |
723 | } |
724 | |
725 | |
726 | inline Var::ConstIterator Var::begin() const |
727 | { |
728 | if (isEmpty()) return ConstIterator(const_cast<Var*>(this), true); |
729 | |
730 | return ConstIterator(const_cast<Var*>(this), false); |
731 | } |
732 | |
733 | inline Var::ConstIterator Var::end() const |
734 | { |
735 | return ConstIterator(const_cast<Var*>(this), true); |
736 | } |
737 | |
738 | inline Var::Iterator Var::begin() |
739 | { |
740 | if (isEmpty()) return Iterator(const_cast<Var*>(this), true); |
741 | |
742 | return Iterator(const_cast<Var*>(this), false); |
743 | } |
744 | |
745 | inline Var::Iterator Var::end() |
746 | { |
747 | return Iterator(this, true); |
748 | } |
749 | |
750 | |
751 | inline Var& Var::operator [] (const std::string& name) |
752 | { |
753 | return getAt(name); |
754 | } |
755 | |
756 | |
757 | inline const Var& Var::operator [] (const std::string& name) const |
758 | { |
759 | return const_cast<Var*>(this)->getAt(name); |
760 | } |
761 | |
762 | |
763 | inline const Var Var::operator + (const char* other) const |
764 | { |
765 | return convert<std::string>() + other; |
766 | } |
767 | |
768 | |
769 | inline Var& Var::operator += (const char*other) |
770 | { |
771 | return *this = convert<std::string>() + other; |
772 | } |
773 | |
774 | |
775 | inline bool Var::operator ! () const |
776 | { |
777 | return !convert<bool>(); |
778 | } |
779 | |
780 | |
781 | inline bool Var::isEmpty() const |
782 | { |
783 | return 0 == content(); |
784 | } |
785 | |
786 | |
787 | inline bool Var::isArray() const |
788 | { |
789 | if (isEmpty() || |
790 | isString()) return false; |
791 | |
792 | VarHolder* pHolder = content(); |
793 | return pHolder ? pHolder->isArray() : false; |
794 | } |
795 | |
796 | |
797 | inline bool Var::isVector() const |
798 | { |
799 | VarHolder* pHolder = content(); |
800 | return pHolder ? pHolder->isVector() : false; |
801 | } |
802 | |
803 | |
804 | inline bool Var::isList() const |
805 | { |
806 | VarHolder* pHolder = content(); |
807 | return pHolder ? pHolder->isList() : false; |
808 | } |
809 | |
810 | |
811 | inline bool Var::isDeque() const |
812 | { |
813 | VarHolder* pHolder = content(); |
814 | return pHolder ? pHolder->isDeque() : false; |
815 | } |
816 | |
817 | |
818 | inline bool Var::isStruct() const |
819 | { |
820 | VarHolder* pHolder = content(); |
821 | return pHolder ? pHolder->isStruct() : false; |
822 | } |
823 | |
824 | |
825 | inline bool Var::isInteger() const |
826 | { |
827 | VarHolder* pHolder = content(); |
828 | return pHolder ? pHolder->isInteger() : false; |
829 | } |
830 | |
831 | |
832 | inline bool Var::isSigned() const |
833 | { |
834 | VarHolder* pHolder = content(); |
835 | return pHolder ? pHolder->isSigned() : false; |
836 | } |
837 | |
838 | |
839 | inline bool Var::isNumeric() const |
840 | { |
841 | VarHolder* pHolder = content(); |
842 | return pHolder ? pHolder->isNumeric() : false; |
843 | } |
844 | |
845 | |
846 | inline bool Var::isBoolean() const |
847 | { |
848 | VarHolder* pHolder = content(); |
849 | return pHolder ? pHolder->isBoolean() : false; |
850 | } |
851 | |
852 | |
853 | inline bool Var::isString() const |
854 | { |
855 | VarHolder* pHolder = content(); |
856 | return pHolder ? pHolder->isString() : false; |
857 | } |
858 | |
859 | |
860 | inline bool Var::isDate() const |
861 | { |
862 | VarHolder* pHolder = content(); |
863 | return pHolder ? pHolder->isDate() : false; |
864 | } |
865 | |
866 | |
867 | inline bool Var::isTime() const |
868 | { |
869 | VarHolder* pHolder = content(); |
870 | return pHolder ? pHolder->isTime() : false; |
871 | } |
872 | |
873 | |
874 | inline bool Var::isDateTime() const |
875 | { |
876 | VarHolder* pHolder = content(); |
877 | return pHolder ? pHolder->isDateTime() : false; |
878 | } |
879 | |
880 | |
881 | inline std::size_t Var::size() const |
882 | { |
883 | VarHolder* pHolder = content(); |
884 | return pHolder ? pHolder->size() : 0; |
885 | } |
886 | |
887 | |
888 | /// |
889 | /// Var non-member functions |
890 | /// |
891 | |
892 | inline const Var operator + (const char* other, const Var& da) |
893 | /// Addition operator for adding Var to const char* |
894 | { |
895 | std::string tmp = other; |
896 | return tmp + da.convert<std::string>(); |
897 | } |
898 | |
899 | |
900 | inline char operator + (const char& other, const Var& da) |
901 | /// Addition operator for adding Var to char |
902 | { |
903 | return other + da.convert<char>(); |
904 | } |
905 | |
906 | |
907 | inline char operator - (const char& other, const Var& da) |
908 | /// Subtraction operator for subtracting Var from char |
909 | { |
910 | return other - da.convert<char>(); |
911 | } |
912 | |
913 | |
914 | inline char operator * (const char& other, const Var& da) |
915 | /// Multiplication operator for multiplying Var with char |
916 | { |
917 | return other * da.convert<char>(); |
918 | } |
919 | |
920 | |
921 | inline char operator / (const char& other, const Var& da) |
922 | /// Division operator for dividing Var with char |
923 | { |
924 | return other / da.convert<char>(); |
925 | } |
926 | |
927 | |
928 | inline char operator += (char& other, const Var& da) |
929 | /// Addition assignment operator for adding Var to char |
930 | { |
931 | return other += da.convert<char>(); |
932 | } |
933 | |
934 | |
935 | inline char operator -= (char& other, const Var& da) |
936 | /// Subtraction assignment operator for subtracting Var from char |
937 | { |
938 | return other -= da.convert<char>(); |
939 | } |
940 | |
941 | |
942 | inline char operator *= (char& other, const Var& da) |
943 | /// Multiplication assignment operator for multiplying Var with char |
944 | { |
945 | return other *= da.convert<char>(); |
946 | } |
947 | |
948 | |
949 | inline char operator /= (char& other, const Var& da) |
950 | /// Division assignment operator for dividing Var with char |
951 | { |
952 | return other /= da.convert<char>(); |
953 | } |
954 | |
955 | |
956 | inline bool operator == (const char& other, const Var& da) |
957 | /// Equality operator for comparing Var with char |
958 | { |
959 | if (da.isEmpty()) return false; |
960 | return other == da.convert<char>(); |
961 | } |
962 | |
963 | |
964 | inline bool operator != (const char& other, const Var& da) |
965 | /// Inequality operator for comparing Var with char |
966 | { |
967 | if (da.isEmpty()) return true; |
968 | return other != da.convert<char>(); |
969 | } |
970 | |
971 | |
972 | inline bool operator < (const char& other, const Var& da) |
973 | /// Less than operator for comparing Var with char |
974 | { |
975 | if (da.isEmpty()) return false; |
976 | return other < da.convert<char>(); |
977 | } |
978 | |
979 | |
980 | inline bool operator <= (const char& other, const Var& da) |
981 | /// Less than or equal operator for comparing Var with char |
982 | { |
983 | if (da.isEmpty()) return false; |
984 | return other <= da.convert<char>(); |
985 | } |
986 | |
987 | |
988 | inline bool operator > (const char& other, const Var& da) |
989 | /// Greater than operator for comparing Var with char |
990 | { |
991 | if (da.isEmpty())return false; |
992 | return other > da.convert<char>(); |
993 | } |
994 | |
995 | |
996 | inline bool operator >= (const char& other, const Var& da) |
997 | /// Greater than or equal operator for comparing Var with char |
998 | { |
999 | if (da.isEmpty())return false; |
1000 | return other >= da.convert<char>(); |
1001 | } |
1002 | |
1003 | |
1004 | inline Poco::Int8 operator + (const Poco::Int8& other, const Var& da) |
1005 | /// Addition operator for adding Var to Poco::Int8 |
1006 | { |
1007 | return other + da.convert<Poco::Int8>(); |
1008 | } |
1009 | |
1010 | |
1011 | inline Poco::Int8 operator - (const Poco::Int8& other, const Var& da) |
1012 | /// Subtraction operator for subtracting Var from Poco::Int8 |
1013 | { |
1014 | return other - da.convert<Poco::Int8>(); |
1015 | } |
1016 | |
1017 | |
1018 | inline Poco::Int8 operator * (const Poco::Int8& other, const Var& da) |
1019 | /// Multiplication operator for multiplying Var with Poco::Int8 |
1020 | { |
1021 | return other * da.convert<Poco::Int8>(); |
1022 | } |
1023 | |
1024 | |
1025 | inline Poco::Int8 operator / (const Poco::Int8& other, const Var& da) |
1026 | /// Division operator for dividing Var with Poco::Int8 |
1027 | { |
1028 | return other / da.convert<Poco::Int8>(); |
1029 | } |
1030 | |
1031 | |
1032 | inline Poco::Int8 operator += (Poco::Int8& other, const Var& da) |
1033 | /// Addition assignment operator for adding Var to Poco::Int8 |
1034 | { |
1035 | return other += da.convert<Poco::Int8>(); |
1036 | } |
1037 | |
1038 | |
1039 | inline Poco::Int8 operator -= (Poco::Int8& other, const Var& da) |
1040 | /// Subtraction assignment operator for subtracting Var from Poco::Int8 |
1041 | { |
1042 | return other -= da.convert<Poco::Int8>(); |
1043 | } |
1044 | |
1045 | |
1046 | inline Poco::Int8 operator *= (Poco::Int8& other, const Var& da) |
1047 | /// Multiplication assignment operator for multiplying Var with Poco::Int8 |
1048 | { |
1049 | return other *= da.convert<Poco::Int8>(); |
1050 | } |
1051 | |
1052 | |
1053 | inline Poco::Int8 operator /= (Poco::Int8& other, const Var& da) |
1054 | /// Division assignment operator for dividing Var with Poco::Int8 |
1055 | { |
1056 | return other /= da.convert<Poco::Int8>(); |
1057 | } |
1058 | |
1059 | |
1060 | inline bool operator == (const Poco::Int8& other, const Var& da) |
1061 | /// Equality operator for comparing Var with Poco::Int8 |
1062 | { |
1063 | if (da.isEmpty()) return false; |
1064 | return other == da.convert<Poco::Int8>(); |
1065 | } |
1066 | |
1067 | |
1068 | inline bool operator != (const Poco::Int8& other, const Var& da) |
1069 | /// Inequality operator for comparing Var with Poco::Int8 |
1070 | { |
1071 | if (da.isEmpty()) return true; |
1072 | return other != da.convert<Poco::Int8>(); |
1073 | } |
1074 | |
1075 | |
1076 | inline bool operator < (const Poco::Int8& other, const Var& da) |
1077 | /// Less than operator for comparing Var with Poco::Int8 |
1078 | { |
1079 | if (da.isEmpty()) return false; |
1080 | return other < da.convert<Poco::Int8>(); |
1081 | } |
1082 | |
1083 | |
1084 | inline bool operator <= (const Poco::Int8& other, const Var& da) |
1085 | /// Less than or equal operator for comparing Var with Poco::Int8 |
1086 | { |
1087 | if (da.isEmpty()) return false; |
1088 | return other <= da.convert<Poco::Int8>(); |
1089 | } |
1090 | |
1091 | |
1092 | inline bool operator > (const Poco::Int8& other, const Var& da) |
1093 | /// Greater than operator for comparing Var with Poco::Int8 |
1094 | { |
1095 | if (da.isEmpty()) return false; |
1096 | return other > da.convert<Poco::Int8>(); |
1097 | } |
1098 | |
1099 | |
1100 | inline bool operator >= (const Poco::Int8& other, const Var& da) |
1101 | /// Greater than or equal operator for comparing Var with Poco::Int8 |
1102 | { |
1103 | if (da.isEmpty()) return false; |
1104 | return other >= da.convert<Poco::Int8>(); |
1105 | } |
1106 | |
1107 | |
1108 | inline Poco::UInt8 operator + (const Poco::UInt8& other, const Var& da) |
1109 | /// Addition operator for adding Var to Poco::UInt8 |
1110 | { |
1111 | return other + da.convert<Poco::UInt8>(); |
1112 | } |
1113 | |
1114 | |
1115 | inline Poco::UInt8 operator - (const Poco::UInt8& other, const Var& da) |
1116 | /// Subtraction operator for subtracting Var from Poco::UInt8 |
1117 | { |
1118 | return other - da.convert<Poco::UInt8>(); |
1119 | } |
1120 | |
1121 | |
1122 | inline Poco::UInt8 operator * (const Poco::UInt8& other, const Var& da) |
1123 | /// Multiplication operator for multiplying Var with Poco::UInt8 |
1124 | { |
1125 | return other * da.convert<Poco::UInt8>(); |
1126 | } |
1127 | |
1128 | |
1129 | inline Poco::UInt8 operator / (const Poco::UInt8& other, const Var& da) |
1130 | /// Division operator for dividing Var with Poco::UInt8 |
1131 | { |
1132 | return other / da.convert<Poco::UInt8>(); |
1133 | } |
1134 | |
1135 | |
1136 | inline Poco::UInt8 operator += (Poco::UInt8& other, const Var& da) |
1137 | /// Addition assignment operator for adding Var to Poco::UInt8 |
1138 | { |
1139 | return other += da.convert<Poco::UInt8>(); |
1140 | } |
1141 | |
1142 | |
1143 | inline Poco::UInt8 operator -= (Poco::UInt8& other, const Var& da) |
1144 | /// Subtraction assignment operator for subtracting Var from Poco::UInt8 |
1145 | { |
1146 | return other -= da.convert<Poco::UInt8>(); |
1147 | } |
1148 | |
1149 | |
1150 | inline Poco::UInt8 operator *= (Poco::UInt8& other, const Var& da) |
1151 | /// Multiplication assignment operator for multiplying Var with Poco::UInt8 |
1152 | { |
1153 | return other *= da.convert<Poco::UInt8>(); |
1154 | } |
1155 | |
1156 | |
1157 | inline Poco::UInt8 operator /= (Poco::UInt8& other, const Var& da) |
1158 | /// Division assignment operator for dividing Var with Poco::UInt8 |
1159 | { |
1160 | return other /= da.convert<Poco::UInt8>(); |
1161 | } |
1162 | |
1163 | |
1164 | inline bool operator == (const Poco::UInt8& other, const Var& da) |
1165 | /// Equality operator for comparing Var with Poco::UInt8 |
1166 | { |
1167 | if (da.isEmpty()) return false; |
1168 | return other == da.convert<Poco::UInt8>(); |
1169 | } |
1170 | |
1171 | |
1172 | inline bool operator != (const Poco::UInt8& other, const Var& da) |
1173 | /// Inequality operator for comparing Var with Poco::UInt8 |
1174 | { |
1175 | if (da.isEmpty()) return true; |
1176 | return other != da.convert<Poco::UInt8>(); |
1177 | } |
1178 | |
1179 | |
1180 | inline bool operator < (const Poco::UInt8& other, const Var& da) |
1181 | /// Less than operator for comparing Var with Poco::UInt8 |
1182 | { |
1183 | if (da.isEmpty()) return false; |
1184 | return other < da.convert<Poco::UInt8>(); |
1185 | } |
1186 | |
1187 | |
1188 | inline bool operator <= (const Poco::UInt8& other, const Var& da) |
1189 | /// Less than or equal operator for comparing Var with Poco::UInt8 |
1190 | { |
1191 | if (da.isEmpty()) return false; |
1192 | return other <= da.convert<Poco::UInt8>(); |
1193 | } |
1194 | |
1195 | |
1196 | inline bool operator > (const Poco::UInt8& other, const Var& da) |
1197 | /// Greater than operator for comparing Var with Poco::UInt8 |
1198 | { |
1199 | if (da.isEmpty()) return false; |
1200 | return other > da.convert<Poco::UInt8>(); |
1201 | } |
1202 | |
1203 | |
1204 | inline bool operator >= (const Poco::UInt8& other, const Var& da) |
1205 | /// Greater than or equal operator for comparing Var with Poco::UInt8 |
1206 | { |
1207 | if (da.isEmpty()) return false; |
1208 | return other >= da.convert<Poco::UInt8>(); |
1209 | } |
1210 | |
1211 | |
1212 | inline Poco::Int16 operator + (const Poco::Int16& other, const Var& da) |
1213 | /// Addition operator for adding Var to Poco::Int16 |
1214 | { |
1215 | return other + da.convert<Poco::Int16>(); |
1216 | } |
1217 | |
1218 | |
1219 | inline Poco::Int16 operator - (const Poco::Int16& other, const Var& da) |
1220 | /// Subtraction operator for subtracting Var from Poco::Int16 |
1221 | { |
1222 | return other - da.convert<Poco::Int16>(); |
1223 | } |
1224 | |
1225 | |
1226 | inline Poco::Int16 operator * (const Poco::Int16& other, const Var& da) |
1227 | /// Multiplication operator for multiplying Var with Poco::Int16 |
1228 | { |
1229 | return other * da.convert<Poco::Int16>(); |
1230 | } |
1231 | |
1232 | |
1233 | inline Poco::Int16 operator / (const Poco::Int16& other, const Var& da) |
1234 | /// Division operator for dividing Var with Poco::Int16 |
1235 | { |
1236 | return other / da.convert<Poco::Int16>(); |
1237 | } |
1238 | |
1239 | |
1240 | inline Poco::Int16 operator += (Poco::Int16& other, const Var& da) |
1241 | /// Addition assignment operator for adding Var to Poco::Int16 |
1242 | { |
1243 | return other += da.convert<Poco::Int16>(); |
1244 | } |
1245 | |
1246 | |
1247 | inline Poco::Int16 operator -= (Poco::Int16& other, const Var& da) |
1248 | /// Subtraction assignment operator for subtracting Var from Poco::Int16 |
1249 | { |
1250 | return other -= da.convert<Poco::Int16>(); |
1251 | } |
1252 | |
1253 | |
1254 | inline Poco::Int16 operator *= (Poco::Int16& other, const Var& da) |
1255 | /// Multiplication assignment operator for multiplying Var with Poco::Int16 |
1256 | { |
1257 | return other *= da.convert<Poco::Int16>(); |
1258 | } |
1259 | |
1260 | |
1261 | inline Poco::Int16 operator /= (Poco::Int16& other, const Var& da) |
1262 | /// Division assignment operator for dividing Var with Poco::Int16 |
1263 | { |
1264 | return other /= da.convert<Poco::Int16>(); |
1265 | } |
1266 | |
1267 | |
1268 | inline bool operator == (const Poco::Int16& other, const Var& da) |
1269 | /// Equality operator for comparing Var with Poco::Int16 |
1270 | { |
1271 | if (da.isEmpty()) return false; |
1272 | return other == da.convert<Poco::Int16>(); |
1273 | } |
1274 | |
1275 | |
1276 | inline bool operator != (const Poco::Int16& other, const Var& da) |
1277 | /// Inequality operator for comparing Var with Poco::Int16 |
1278 | { |
1279 | if (da.isEmpty()) return true; |
1280 | return other != da.convert<Poco::Int16>(); |
1281 | } |
1282 | |
1283 | |
1284 | inline bool operator < (const Poco::Int16& other, const Var& da) |
1285 | /// Less than operator for comparing Var with Poco::Int16 |
1286 | { |
1287 | if (da.isEmpty()) return false; |
1288 | return other < da.convert<Poco::Int16>(); |
1289 | } |
1290 | |
1291 | |
1292 | inline bool operator <= (const Poco::Int16& other, const Var& da) |
1293 | /// Less than or equal operator for comparing Var with Poco::Int16 |
1294 | { |
1295 | if (da.isEmpty()) return false; |
1296 | return other <= da.convert<Poco::Int16>(); |
1297 | } |
1298 | |
1299 | |
1300 | inline bool operator > (const Poco::Int16& other, const Var& da) |
1301 | /// Greater than operator for comparing Var with Poco::Int16 |
1302 | { |
1303 | if (da.isEmpty()) return false; |
1304 | return other > da.convert<Poco::Int16>(); |
1305 | } |
1306 | |
1307 | |
1308 | inline bool operator >= (const Poco::Int16& other, const Var& da) |
1309 | /// Greater than or equal operator for comparing Var with Poco::Int16 |
1310 | { |
1311 | if (da.isEmpty()) return false; |
1312 | return other >= da.convert<Poco::Int16>(); |
1313 | } |
1314 | |
1315 | |
1316 | inline Poco::UInt16 operator + (const Poco::UInt16& other, const Var& da) |
1317 | /// Addition operator for adding Var to Poco::UInt16 |
1318 | { |
1319 | return other + da.convert<Poco::UInt16>(); |
1320 | } |
1321 | |
1322 | |
1323 | inline Poco::UInt16 operator - (const Poco::UInt16& other, const Var& da) |
1324 | /// Subtraction operator for subtracting Var from Poco::UInt16 |
1325 | { |
1326 | return other - da.convert<Poco::UInt16>(); |
1327 | } |
1328 | |
1329 | |
1330 | inline Poco::UInt16 operator * (const Poco::UInt16& other, const Var& da) |
1331 | /// Multiplication operator for multiplying Var with Poco::UInt16 |
1332 | { |
1333 | return other * da.convert<Poco::UInt16>(); |
1334 | } |
1335 | |
1336 | |
1337 | inline Poco::UInt16 operator / (const Poco::UInt16& other, const Var& da) |
1338 | /// Division operator for dividing Var with Poco::UInt16 |
1339 | { |
1340 | return other / da.convert<Poco::UInt16>(); |
1341 | } |
1342 | |
1343 | |
1344 | inline Poco::UInt16 operator += (Poco::UInt16& other, const Var& da) |
1345 | /// Addition assignment operator for adding Var to Poco::UInt16 |
1346 | { |
1347 | return other += da.convert<Poco::UInt16>(); |
1348 | } |
1349 | |
1350 | |
1351 | inline Poco::UInt16 operator -= (Poco::UInt16& other, const Var& da) |
1352 | /// Subtraction assignment operator for subtracting Var from Poco::UInt16 |
1353 | { |
1354 | return other -= da.convert<Poco::UInt16>(); |
1355 | } |
1356 | |
1357 | |
1358 | inline Poco::UInt16 operator *= (Poco::UInt16& other, const Var& da) |
1359 | /// Multiplication assignment operator for multiplying Var with Poco::UInt16 |
1360 | { |
1361 | return other *= da.convert<Poco::UInt16>(); |
1362 | } |
1363 | |
1364 | |
1365 | inline Poco::UInt16 operator /= (Poco::UInt16& other, const Var& da) |
1366 | /// Division assignment operator for dividing Var with Poco::UInt16 |
1367 | { |
1368 | return other /= da.convert<Poco::UInt16>(); |
1369 | } |
1370 | |
1371 | |
1372 | inline bool operator == (const Poco::UInt16& other, const Var& da) |
1373 | /// Equality operator for comparing Var with Poco::UInt16 |
1374 | { |
1375 | if (da.isEmpty()) return false; |
1376 | return other == da.convert<Poco::UInt16>(); |
1377 | } |
1378 | |
1379 | |
1380 | inline bool operator != (const Poco::UInt16& other, const Var& da) |
1381 | /// Inequality operator for comparing Var with Poco::UInt16 |
1382 | { |
1383 | if (da.isEmpty()) return true; |
1384 | return other != da.convert<Poco::UInt16>(); |
1385 | } |
1386 | |
1387 | |
1388 | inline bool operator < (const Poco::UInt16& other, const Var& da) |
1389 | /// Less than operator for comparing Var with Poco::UInt16 |
1390 | { |
1391 | if (da.isEmpty()) return false; |
1392 | return other < da.convert<Poco::UInt16>(); |
1393 | } |
1394 | |
1395 | |
1396 | inline bool operator <= (const Poco::UInt16& other, const Var& da) |
1397 | /// Less than or equal operator for comparing Var with Poco::UInt16 |
1398 | { |
1399 | if (da.isEmpty()) return false; |
1400 | return other <= da.convert<Poco::UInt16>(); |
1401 | } |
1402 | |
1403 | |
1404 | inline bool operator > (const Poco::UInt16& other, const Var& da) |
1405 | /// Greater than operator for comparing Var with Poco::UInt16 |
1406 | { |
1407 | if (da.isEmpty()) return false; |
1408 | return other > da.convert<Poco::UInt16>(); |
1409 | } |
1410 | |
1411 | |
1412 | inline bool operator >= (const Poco::UInt16& other, const Var& da) |
1413 | /// Greater than or equal operator for comparing Var with Poco::UInt16 |
1414 | { |
1415 | if (da.isEmpty()) return false; |
1416 | return other >= da.convert<Poco::UInt16>(); |
1417 | } |
1418 | |
1419 | |
1420 | inline Poco::Int32 operator + (const Poco::Int32& other, const Var& da) |
1421 | /// Addition operator for adding Var to Poco::Int32 |
1422 | { |
1423 | return other + da.convert<Poco::Int32>(); |
1424 | } |
1425 | |
1426 | |
1427 | inline Poco::Int32 operator - (const Poco::Int32& other, const Var& da) |
1428 | /// Subtraction operator for subtracting Var from Poco::Int32 |
1429 | { |
1430 | return other - da.convert<Poco::Int32>(); |
1431 | } |
1432 | |
1433 | |
1434 | inline Poco::Int32 operator * (const Poco::Int32& other, const Var& da) |
1435 | /// Multiplication operator for multiplying Var with Poco::Int32 |
1436 | { |
1437 | return other * da.convert<Poco::Int32>(); |
1438 | } |
1439 | |
1440 | |
1441 | inline Poco::Int32 operator / (const Poco::Int32& other, const Var& da) |
1442 | /// Division operator for dividing Var with Poco::Int32 |
1443 | { |
1444 | return other / da.convert<Poco::Int32>(); |
1445 | } |
1446 | |
1447 | |
1448 | inline Poco::Int32 operator += (Poco::Int32& other, const Var& da) |
1449 | /// Addition assignment operator for adding Var to Poco::Int32 |
1450 | { |
1451 | return other += da.convert<Poco::Int32>(); |
1452 | } |
1453 | |
1454 | |
1455 | inline Poco::Int32 operator -= (Poco::Int32& other, const Var& da) |
1456 | /// Subtraction assignment operator for subtracting Var from Poco::Int32 |
1457 | { |
1458 | return other -= da.convert<Poco::Int32>(); |
1459 | } |
1460 | |
1461 | |
1462 | inline Poco::Int32 operator *= (Poco::Int32& other, const Var& da) |
1463 | /// Multiplication assignment operator for multiplying Var with Poco::Int32 |
1464 | { |
1465 | return other *= da.convert<Poco::Int32>(); |
1466 | } |
1467 | |
1468 | |
1469 | inline Poco::Int32 operator /= (Poco::Int32& other, const Var& da) |
1470 | /// Division assignment operator for dividing Var with Poco::Int32 |
1471 | { |
1472 | return other /= da.convert<Poco::Int32>(); |
1473 | } |
1474 | |
1475 | |
1476 | inline bool operator == (const Poco::Int32& other, const Var& da) |
1477 | /// Equality operator for comparing Var with Poco::Int32 |
1478 | { |
1479 | if (da.isEmpty()) return false; |
1480 | return other == da.convert<Poco::Int32>(); |
1481 | } |
1482 | |
1483 | |
1484 | inline bool operator != (const Poco::Int32& other, const Var& da) |
1485 | /// Inequality operator for comparing Var with Poco::Int32 |
1486 | { |
1487 | if (da.isEmpty()) return true; |
1488 | return other != da.convert<Poco::Int32>(); |
1489 | } |
1490 | |
1491 | |
1492 | inline bool operator < (const Poco::Int32& other, const Var& da) |
1493 | /// Less than operator for comparing Var with Poco::Int32 |
1494 | { |
1495 | if (da.isEmpty()) return false; |
1496 | return other < da.convert<Poco::Int32>(); |
1497 | } |
1498 | |
1499 | |
1500 | inline bool operator <= (const Poco::Int32& other, const Var& da) |
1501 | /// Less than or equal operator for comparing Var with Poco::Int32 |
1502 | { |
1503 | if (da.isEmpty()) return false; |
1504 | return other <= da.convert<Poco::Int32>(); |
1505 | } |
1506 | |
1507 | |
1508 | inline bool operator > (const Poco::Int32& other, const Var& da) |
1509 | /// Greater than operator for comparing Var with Poco::Int32 |
1510 | { |
1511 | if (da.isEmpty()) return false; |
1512 | return other > da.convert<Poco::Int32>(); |
1513 | } |
1514 | |
1515 | |
1516 | inline bool operator >= (const Poco::Int32& other, const Var& da) |
1517 | /// Greater than or equal operator for comparing Var with Poco::Int32 |
1518 | { |
1519 | if (da.isEmpty()) return false; |
1520 | return other >= da.convert<Poco::Int32>(); |
1521 | } |
1522 | |
1523 | |
1524 | inline Poco::UInt32 operator + (const Poco::UInt32& other, const Var& da) |
1525 | /// Addition operator for adding Var to Poco::UInt32 |
1526 | { |
1527 | return other + da.convert<Poco::UInt32>(); |
1528 | } |
1529 | |
1530 | |
1531 | inline Poco::UInt32 operator - (const Poco::UInt32& other, const Var& da) |
1532 | /// Subtraction operator for subtracting Var from Poco::UInt32 |
1533 | { |
1534 | return other - da.convert<Poco::UInt32>(); |
1535 | } |
1536 | |
1537 | |
1538 | inline Poco::UInt32 operator * (const Poco::UInt32& other, const Var& da) |
1539 | /// Multiplication operator for multiplying Var with Poco::UInt32 |
1540 | { |
1541 | return other * da.convert<Poco::UInt32>(); |
1542 | } |
1543 | |
1544 | |
1545 | inline Poco::UInt32 operator / (const Poco::UInt32& other, const Var& da) |
1546 | /// Division operator for dividing Var with Poco::UInt32 |
1547 | { |
1548 | return other / da.convert<Poco::UInt32>(); |
1549 | } |
1550 | |
1551 | |
1552 | inline Poco::UInt32 operator += (Poco::UInt32& other, const Var& da) |
1553 | /// Addition assignment operator for adding Var to Poco::UInt32 |
1554 | { |
1555 | return other += da.convert<Poco::UInt32>(); |
1556 | } |
1557 | |
1558 | |
1559 | inline Poco::UInt32 operator -= (Poco::UInt32& other, const Var& da) |
1560 | /// Subtraction assignment operator for subtracting Var from Poco::UInt32 |
1561 | { |
1562 | return other -= da.convert<Poco::UInt32>(); |
1563 | } |
1564 | |
1565 | |
1566 | inline Poco::UInt32 operator *= (Poco::UInt32& other, const Var& da) |
1567 | /// Multiplication assignment operator for multiplying Var with Poco::UInt32 |
1568 | { |
1569 | return other *= da.convert<Poco::UInt32>(); |
1570 | } |
1571 | |
1572 | |
1573 | inline Poco::UInt32 operator /= (Poco::UInt32& other, const Var& da) |
1574 | /// Division assignment operator for dividing Var with Poco::UInt32 |
1575 | { |
1576 | return other /= da.convert<Poco::UInt32>(); |
1577 | } |
1578 | |
1579 | |
1580 | inline bool operator == (const Poco::UInt32& other, const Var& da) |
1581 | /// Equality operator for comparing Var with Poco::UInt32 |
1582 | { |
1583 | if (da.isEmpty()) return false; |
1584 | return other == da.convert<Poco::UInt32>(); |
1585 | } |
1586 | |
1587 | |
1588 | inline bool operator != (const Poco::UInt32& other, const Var& da) |
1589 | /// Inequality operator for comparing Var with Poco::UInt32 |
1590 | { |
1591 | if (da.isEmpty()) return true; |
1592 | return other != da.convert<Poco::UInt32>(); |
1593 | } |
1594 | |
1595 | |
1596 | inline bool operator < (const Poco::UInt32& other, const Var& da) |
1597 | /// Less than operator for comparing Var with Poco::UInt32 |
1598 | { |
1599 | if (da.isEmpty()) return false; |
1600 | return other < da.convert<Poco::UInt32>(); |
1601 | } |
1602 | |
1603 | |
1604 | inline bool operator <= (const Poco::UInt32& other, const Var& da) |
1605 | /// Less than or equal operator for comparing Var with Poco::UInt32 |
1606 | { |
1607 | if (da.isEmpty()) return false; |
1608 | return other <= da.convert<Poco::UInt32>(); |
1609 | } |
1610 | |
1611 | |
1612 | inline bool operator > (const Poco::UInt32& other, const Var& da) |
1613 | /// Greater than operator for comparing Var with Poco::UInt32 |
1614 | { |
1615 | if (da.isEmpty()) return false; |
1616 | return other > da.convert<Poco::UInt32>(); |
1617 | } |
1618 | |
1619 | |
1620 | inline bool operator >= (const Poco::UInt32& other, const Var& da) |
1621 | /// Greater than or equal operator for comparing Var with Poco::UInt32 |
1622 | { |
1623 | if (da.isEmpty()) return false; |
1624 | return other >= da.convert<Poco::UInt32>(); |
1625 | } |
1626 | |
1627 | |
1628 | inline Poco::Int64 operator + (const Poco::Int64& other, const Var& da) |
1629 | /// Addition operator for adding Var to Poco::Int64 |
1630 | { |
1631 | return other + da.convert<Poco::Int64>(); |
1632 | } |
1633 | |
1634 | |
1635 | inline Poco::Int64 operator - (const Poco::Int64& other, const Var& da) |
1636 | /// Subtraction operator for subtracting Var from Poco::Int64 |
1637 | { |
1638 | return other - da.convert<Poco::Int64>(); |
1639 | } |
1640 | |
1641 | |
1642 | inline Poco::Int64 operator * (const Poco::Int64& other, const Var& da) |
1643 | /// Multiplication operator for multiplying Var with Poco::Int64 |
1644 | { |
1645 | return other * da.convert<Poco::Int64>(); |
1646 | } |
1647 | |
1648 | |
1649 | inline Poco::Int64 operator / (const Poco::Int64& other, const Var& da) |
1650 | /// Division operator for dividing Var with Poco::Int64 |
1651 | { |
1652 | return other / da.convert<Poco::Int64>(); |
1653 | } |
1654 | |
1655 | |
1656 | inline Poco::Int64 operator += (Poco::Int64& other, const Var& da) |
1657 | /// Addition assignment operator for adding Var to Poco::Int64 |
1658 | { |
1659 | return other += da.convert<Poco::Int64>(); |
1660 | } |
1661 | |
1662 | |
1663 | inline Poco::Int64 operator -= (Poco::Int64& other, const Var& da) |
1664 | /// Subtraction assignment operator for subtracting Var from Poco::Int64 |
1665 | { |
1666 | return other -= da.convert<Poco::Int64>(); |
1667 | } |
1668 | |
1669 | |
1670 | inline Poco::Int64 operator *= (Poco::Int64& other, const Var& da) |
1671 | /// Multiplication assignment operator for multiplying Var with Poco::Int64 |
1672 | { |
1673 | return other *= da.convert<Poco::Int64>(); |
1674 | } |
1675 | |
1676 | |
1677 | inline Poco::Int64 operator /= (Poco::Int64& other, const Var& da) |
1678 | /// Division assignment operator for dividing Var with Poco::Int64 |
1679 | { |
1680 | return other /= da.convert<Poco::Int64>(); |
1681 | } |
1682 | |
1683 | |
1684 | inline bool operator == (const Poco::Int64& other, const Var& da) |
1685 | /// Equality operator for comparing Var with Poco::Int64 |
1686 | { |
1687 | if (da.isEmpty()) return false; |
1688 | return other == da.convert<Poco::Int64>(); |
1689 | } |
1690 | |
1691 | |
1692 | inline bool operator != (const Poco::Int64& other, const Var& da) |
1693 | /// Inequality operator for comparing Var with Poco::Int64 |
1694 | { |
1695 | if (da.isEmpty()) return true; |
1696 | return other != da.convert<Poco::Int64>(); |
1697 | } |
1698 | |
1699 | |
1700 | inline bool operator < (const Poco::Int64& other, const Var& da) |
1701 | /// Less than operator for comparing Var with Poco::Int64 |
1702 | { |
1703 | if (da.isEmpty()) return false; |
1704 | return other < da.convert<Poco::Int64>(); |
1705 | } |
1706 | |
1707 | |
1708 | inline bool operator <= (const Poco::Int64& other, const Var& da) |
1709 | /// Less than or equal operator for comparing Var with Poco::Int64 |
1710 | { |
1711 | if (da.isEmpty()) return false; |
1712 | return other <= da.convert<Poco::Int64>(); |
1713 | } |
1714 | |
1715 | |
1716 | inline bool operator > (const Poco::Int64& other, const Var& da) |
1717 | /// Greater than operator for comparing Var with Poco::Int64 |
1718 | { |
1719 | if (da.isEmpty()) return false; |
1720 | return other > da.convert<Poco::Int64>(); |
1721 | } |
1722 | |
1723 | |
1724 | inline bool operator >= (const Poco::Int64& other, const Var& da) |
1725 | /// Greater than or equal operator for comparing Var with Poco::Int64 |
1726 | { |
1727 | if (da.isEmpty()) return false; |
1728 | return other >= da.convert<Poco::Int64>(); |
1729 | } |
1730 | |
1731 | |
1732 | inline Poco::UInt64 operator + (const Poco::UInt64& other, const Var& da) |
1733 | /// Addition operator for adding Var to Poco::UInt64 |
1734 | { |
1735 | return other + da.convert<Poco::UInt64>(); |
1736 | } |
1737 | |
1738 | |
1739 | inline Poco::UInt64 operator - (const Poco::UInt64& other, const Var& da) |
1740 | /// Subtraction operator for subtracting Var from Poco::UInt64 |
1741 | { |
1742 | return other - da.convert<Poco::UInt64>(); |
1743 | } |
1744 | |
1745 | |
1746 | inline Poco::UInt64 operator * (const Poco::UInt64& other, const Var& da) |
1747 | /// Multiplication operator for multiplying Var with Poco::UInt64 |
1748 | { |
1749 | return other * da.convert<Poco::UInt64>(); |
1750 | } |
1751 | |
1752 | |
1753 | inline Poco::UInt64 operator / (const Poco::UInt64& other, const Var& da) |
1754 | /// Division operator for dividing Var with Poco::UInt64 |
1755 | { |
1756 | return other / da.convert<Poco::UInt64>(); |
1757 | } |
1758 | |
1759 | |
1760 | inline Poco::UInt64 operator += (Poco::UInt64& other, const Var& da) |
1761 | /// Addition assignment operator for adding Var to Poco::UInt64 |
1762 | { |
1763 | return other += da.convert<Poco::UInt64>(); |
1764 | } |
1765 | |
1766 | |
1767 | inline Poco::UInt64 operator -= (Poco::UInt64& other, const Var& da) |
1768 | /// Subtraction assignment operator for subtracting Var from Poco::UInt64 |
1769 | { |
1770 | return other -= da.convert<Poco::UInt64>(); |
1771 | } |
1772 | |
1773 | |
1774 | inline Poco::UInt64 operator *= (Poco::UInt64& other, const Var& da) |
1775 | /// Multiplication assignment operator for multiplying Var with Poco::UInt64 |
1776 | { |
1777 | return other *= da.convert<Poco::UInt64>(); |
1778 | } |
1779 | |
1780 | |
1781 | inline Poco::UInt64 operator /= (Poco::UInt64& other, const Var& da) |
1782 | /// Division assignment operator for dividing Var with Poco::UInt64 |
1783 | { |
1784 | return other /= da.convert<Poco::UInt64>(); |
1785 | } |
1786 | |
1787 | |
1788 | inline bool operator == (const Poco::UInt64& other, const Var& da) |
1789 | /// Equality operator for comparing Var with Poco::UInt64 |
1790 | { |
1791 | if (da.isEmpty()) return false; |
1792 | return other == da.convert<Poco::UInt64>(); |
1793 | } |
1794 | |
1795 | |
1796 | inline bool operator != (const Poco::UInt64& other, const Var& da) |
1797 | /// Inequality operator for comparing Var with Poco::UInt64 |
1798 | { |
1799 | if (da.isEmpty()) return true; |
1800 | return other != da.convert<Poco::UInt64>(); |
1801 | } |
1802 | |
1803 | |
1804 | inline bool operator < (const Poco::UInt64& other, const Var& da) |
1805 | /// Less than operator for comparing Var with Poco::UInt64 |
1806 | { |
1807 | if (da.isEmpty()) return false; |
1808 | return other < da.convert<Poco::UInt64>(); |
1809 | } |
1810 | |
1811 | |
1812 | inline bool operator <= (const Poco::UInt64& other, const Var& da) |
1813 | /// Less than or equal operator for comparing Var with Poco::UInt64 |
1814 | { |
1815 | if (da.isEmpty()) return false; |
1816 | return other <= da.convert<Poco::UInt64>(); |
1817 | } |
1818 | |
1819 | |
1820 | inline bool operator > (const Poco::UInt64& other, const Var& da) |
1821 | /// Greater than operator for comparing Var with Poco::UInt64 |
1822 | { |
1823 | if (da.isEmpty()) return false; |
1824 | return other > da.convert<Poco::UInt64>(); |
1825 | } |
1826 | |
1827 | |
1828 | inline bool operator >= (const Poco::UInt64& other, const Var& da) |
1829 | /// Greater than or equal operator for comparing Var with Poco::UInt64 |
1830 | { |
1831 | if (da.isEmpty()) return false; |
1832 | return other >= da.convert<Poco::UInt64>(); |
1833 | } |
1834 | |
1835 | |
1836 | inline float operator + (const float& other, const Var& da) |
1837 | /// Addition operator for adding Var to float |
1838 | { |
1839 | return other + da.convert<float>(); |
1840 | } |
1841 | |
1842 | |
1843 | inline float operator - (const float& other, const Var& da) |
1844 | /// Subtraction operator for subtracting Var from float |
1845 | { |
1846 | return other - da.convert<float>(); |
1847 | } |
1848 | |
1849 | |
1850 | inline float operator * (const float& other, const Var& da) |
1851 | /// Multiplication operator for multiplying Var with float |
1852 | { |
1853 | return other * da.convert<float>(); |
1854 | } |
1855 | |
1856 | |
1857 | inline float operator / (const float& other, const Var& da) |
1858 | /// Division operator for dividing Var with float |
1859 | { |
1860 | return other / da.convert<float>(); |
1861 | } |
1862 | |
1863 | |
1864 | inline float operator += (float& other, const Var& da) |
1865 | /// Addition assignment operator for adding Var to float |
1866 | { |
1867 | return other += da.convert<float>(); |
1868 | } |
1869 | |
1870 | |
1871 | inline float operator -= (float& other, const Var& da) |
1872 | /// Subtraction assignment operator for subtracting Var from float |
1873 | { |
1874 | return other -= da.convert<float>(); |
1875 | } |
1876 | |
1877 | |
1878 | inline float operator *= (float& other, const Var& da) |
1879 | /// Multiplication assignment operator for multiplying Var with float |
1880 | { |
1881 | return other *= da.convert<float>(); |
1882 | } |
1883 | |
1884 | |
1885 | inline float operator /= (float& other, const Var& da) |
1886 | /// Division assignment operator for dividing Var with float |
1887 | { |
1888 | return other /= da.convert<float>(); |
1889 | } |
1890 | |
1891 | |
1892 | inline bool operator == (const float& other, const Var& da) |
1893 | /// Equality operator for comparing Var with float |
1894 | { |
1895 | if (da.isEmpty()) return false; |
1896 | return other == da.convert<float>(); |
1897 | } |
1898 | |
1899 | |
1900 | inline bool operator != (const float& other, const Var& da) |
1901 | /// Inequality operator for comparing Var with float |
1902 | { |
1903 | if (da.isEmpty()) return true; |
1904 | return other != da.convert<float>(); |
1905 | } |
1906 | |
1907 | |
1908 | inline bool operator < (const float& other, const Var& da) |
1909 | /// Less than operator for comparing Var with float |
1910 | { |
1911 | if (da.isEmpty()) return false; |
1912 | return other < da.convert<float>(); |
1913 | } |
1914 | |
1915 | |
1916 | inline bool operator <= (const float& other, const Var& da) |
1917 | /// Less than or equal operator for comparing Var with float |
1918 | { |
1919 | if (da.isEmpty()) return false; |
1920 | return other <= da.convert<float>(); |
1921 | } |
1922 | |
1923 | |
1924 | inline bool operator > (const float& other, const Var& da) |
1925 | /// Greater than operator for comparing Var with float |
1926 | { |
1927 | if (da.isEmpty()) return false; |
1928 | return other > da.convert<float>(); |
1929 | } |
1930 | |
1931 | |
1932 | inline bool operator >= (const float& other, const Var& da) |
1933 | /// Greater than or equal operator for comparing Var with float |
1934 | { |
1935 | if (da.isEmpty()) return false; |
1936 | return other >= da.convert<float>(); |
1937 | } |
1938 | |
1939 | |
1940 | inline double operator + (const double& other, const Var& da) |
1941 | /// Addition operator for adding Var to double |
1942 | { |
1943 | return other + da.convert<double>(); |
1944 | } |
1945 | |
1946 | |
1947 | inline double operator - (const double& other, const Var& da) |
1948 | /// Subtraction operator for subtracting Var from double |
1949 | { |
1950 | return other - da.convert<double>(); |
1951 | } |
1952 | |
1953 | |
1954 | inline double operator * (const double& other, const Var& da) |
1955 | /// Multiplication operator for multiplying Var with double |
1956 | { |
1957 | return other * da.convert<double>(); |
1958 | } |
1959 | |
1960 | |
1961 | inline double operator / (const double& other, const Var& da) |
1962 | /// Division operator for dividing Var with double |
1963 | { |
1964 | return other / da.convert<double>(); |
1965 | } |
1966 | |
1967 | |
1968 | inline double operator += (double& other, const Var& da) |
1969 | /// Addition assignment operator for adding Var to double |
1970 | { |
1971 | return other += da.convert<double>(); |
1972 | } |
1973 | |
1974 | |
1975 | inline double operator -= (double& other, const Var& da) |
1976 | /// Subtraction assignment operator for subtracting Var from double |
1977 | { |
1978 | return other -= da.convert<double>(); |
1979 | } |
1980 | |
1981 | |
1982 | inline double operator *= (double& other, const Var& da) |
1983 | /// Multiplication assignment operator for multiplying Var with double |
1984 | { |
1985 | return other *= da.convert<double>(); |
1986 | } |
1987 | |
1988 | |
1989 | inline double operator /= (double& other, const Var& da) |
1990 | /// Division assignment operator for dividing Var with double |
1991 | { |
1992 | return other /= da.convert<double>(); |
1993 | } |
1994 | |
1995 | |
1996 | inline bool operator == (const double& other, const Var& da) |
1997 | /// Equality operator for comparing Var with double |
1998 | { |
1999 | if (da.isEmpty()) return false; |
2000 | return other == da.convert<double>(); |
2001 | } |
2002 | |
2003 | |
2004 | inline bool operator != (const double& other, const Var& da) |
2005 | /// Inequality operator for comparing Var with double |
2006 | { |
2007 | if (da.isEmpty()) return true; |
2008 | return other != da.convert<double>(); |
2009 | } |
2010 | |
2011 | |
2012 | inline bool operator < (const double& other, const Var& da) |
2013 | /// Less than operator for comparing Var with double |
2014 | { |
2015 | if (da.isEmpty()) return false; |
2016 | return other < da.convert<double>(); |
2017 | } |
2018 | |
2019 | |
2020 | inline bool operator <= (const double& other, const Var& da) |
2021 | /// Less than or equal operator for comparing Var with double |
2022 | { |
2023 | if (da.isEmpty()) return false; |
2024 | return other <= da.convert<double>(); |
2025 | } |
2026 | |
2027 | |
2028 | inline bool operator > (const double& other, const Var& da) |
2029 | /// Greater than operator for comparing Var with double |
2030 | { |
2031 | if (da.isEmpty()) return false; |
2032 | return other > da.convert<double>(); |
2033 | } |
2034 | |
2035 | |
2036 | inline bool operator >= (const double& other, const Var& da) |
2037 | /// Greater than or equal operator for comparing Var with double |
2038 | { |
2039 | if (da.isEmpty()) return false; |
2040 | return other >= da.convert<double>(); |
2041 | } |
2042 | |
2043 | |
2044 | inline bool operator == (const bool& other, const Var& da) |
2045 | /// Equality operator for comparing Var with bool |
2046 | { |
2047 | if (da.isEmpty()) return false; |
2048 | return other == da.convert<bool>(); |
2049 | } |
2050 | |
2051 | |
2052 | inline bool operator != (const bool& other, const Var& da) |
2053 | /// Inequality operator for comparing Var with bool |
2054 | { |
2055 | if (da.isEmpty()) return true; |
2056 | return other != da.convert<bool>(); |
2057 | } |
2058 | |
2059 | |
2060 | inline bool operator == (const std::string& other, const Var& da) |
2061 | /// Equality operator for comparing Var with std::string |
2062 | { |
2063 | if (da.isEmpty()) return false; |
2064 | return other == da.convert<std::string>(); |
2065 | } |
2066 | |
2067 | |
2068 | inline bool operator != (const std::string& other, const Var& da) |
2069 | /// Inequality operator for comparing Var with std::string |
2070 | { |
2071 | if (da.isEmpty()) return true; |
2072 | return other != da.convert<std::string>(); |
2073 | } |
2074 | |
2075 | |
2076 | inline bool operator == (const UTF16String& other, const Var& da) |
2077 | /// Equality operator for comparing Var with UTF16String |
2078 | { |
2079 | if (da.isEmpty()) return false; |
2080 | return other == da.convert<UTF16String>(); |
2081 | } |
2082 | |
2083 | |
2084 | inline bool operator != (const UTF16String& other, const Var& da) |
2085 | /// Inequality operator for comparing Var with UTF16String |
2086 | { |
2087 | if (da.isEmpty()) return true; |
2088 | return other != da.convert<UTF16String>(); |
2089 | } |
2090 | |
2091 | |
2092 | inline bool operator == (const char* other, const Var& da) |
2093 | /// Equality operator for comparing Var with const char* |
2094 | { |
2095 | if (da.isEmpty()) return false; |
2096 | return da.convert<std::string>() == other; |
2097 | } |
2098 | |
2099 | |
2100 | inline bool operator != (const char* other, const Var& da) |
2101 | /// Inequality operator for comparing Var with const char* |
2102 | { |
2103 | if (da.isEmpty()) return true; |
2104 | return da.convert<std::string>() != other; |
2105 | } |
2106 | |
2107 | |
2108 | #ifndef POCO_LONG_IS_64_BIT |
2109 | |
2110 | |
2111 | inline long operator + (const long& other, const Var& da) |
2112 | /// Addition operator for adding Var to long |
2113 | { |
2114 | return other + da.convert<long>(); |
2115 | } |
2116 | |
2117 | |
2118 | inline long operator - (const long& other, const Var& da) |
2119 | /// Subtraction operator for subtracting Var from long |
2120 | { |
2121 | return other - da.convert<long>(); |
2122 | } |
2123 | |
2124 | |
2125 | inline long operator * (const long& other, const Var& da) |
2126 | /// Multiplication operator for multiplying Var with long |
2127 | { |
2128 | return other * da.convert<long>(); |
2129 | } |
2130 | |
2131 | |
2132 | inline long operator / (const long& other, const Var& da) |
2133 | /// Division operator for dividing Var with long |
2134 | { |
2135 | return other / da.convert<long>(); |
2136 | } |
2137 | |
2138 | |
2139 | inline long operator += (long& other, const Var& da) |
2140 | /// Addition assignment operator for adding Var to long |
2141 | { |
2142 | return other += da.convert<long>(); |
2143 | } |
2144 | |
2145 | |
2146 | inline long operator -= (long& other, const Var& da) |
2147 | /// Subtraction assignment operator for subtracting Var from long |
2148 | { |
2149 | return other -= da.convert<long>(); |
2150 | } |
2151 | |
2152 | |
2153 | inline long operator *= (long& other, const Var& da) |
2154 | /// Multiplication assignment operator for multiplying Var with long |
2155 | { |
2156 | return other *= da.convert<long>(); |
2157 | } |
2158 | |
2159 | |
2160 | inline long operator /= (long& other, const Var& da) |
2161 | /// Division assignment operator for dividing Var with long |
2162 | { |
2163 | return other /= da.convert<long>(); |
2164 | } |
2165 | |
2166 | |
2167 | inline bool operator == (const long& other, const Var& da) |
2168 | /// Equality operator for comparing Var with long |
2169 | { |
2170 | if (da.isEmpty()) return false; |
2171 | return other == da.convert<long>(); |
2172 | } |
2173 | |
2174 | |
2175 | inline bool operator != (const long& other, const Var& da) |
2176 | /// Inequality operator for comparing Var with long |
2177 | { |
2178 | if (da.isEmpty()) return true; |
2179 | return other != da.convert<long>(); |
2180 | } |
2181 | |
2182 | |
2183 | inline bool operator < (const long& other, const Var& da) |
2184 | /// Less than operator for comparing Var with long |
2185 | { |
2186 | if (da.isEmpty()) return false; |
2187 | return other < da.convert<long>(); |
2188 | } |
2189 | |
2190 | |
2191 | inline bool operator <= (const long& other, const Var& da) |
2192 | /// Less than or equal operator for comparing Var with long |
2193 | { |
2194 | if (da.isEmpty()) return false; |
2195 | return other <= da.convert<long>(); |
2196 | } |
2197 | |
2198 | |
2199 | inline bool operator > (const long& other, const Var& da) |
2200 | /// Greater than operator for comparing Var with long |
2201 | { |
2202 | if (da.isEmpty()) return false; |
2203 | return other > da.convert<long>(); |
2204 | } |
2205 | |
2206 | |
2207 | inline bool operator >= (const long& other, const Var& da) |
2208 | /// Greater than or equal operator for comparing Var with long |
2209 | { |
2210 | if (da.isEmpty()) return false; |
2211 | return other >= da.convert<long>(); |
2212 | } |
2213 | |
2214 | |
2215 | inline unsigned long operator + (const unsigned long& other, const Var& da) |
2216 | /// Addition operator for adding Var to unsigned long |
2217 | { |
2218 | return other + da.convert<unsigned long>(); |
2219 | } |
2220 | |
2221 | |
2222 | inline unsigned long operator - (const unsigned long& other, const Var& da) |
2223 | /// Subtraction operator for subtracting Var from unsigned long |
2224 | { |
2225 | return other - da.convert<unsigned long>(); |
2226 | } |
2227 | |
2228 | |
2229 | inline unsigned long operator * (const unsigned long& other, const Var& da) |
2230 | /// Multiplication operator for multiplying Var with unsigned long |
2231 | { |
2232 | return other * da.convert<unsigned long>(); |
2233 | } |
2234 | |
2235 | |
2236 | inline unsigned long operator / (const unsigned long& other, const Var& da) |
2237 | /// Division operator for dividing Var with unsigned long |
2238 | { |
2239 | return other / da.convert<unsigned long>(); |
2240 | } |
2241 | |
2242 | |
2243 | inline unsigned long operator += (unsigned long& other, const Var& da) |
2244 | /// Addition assignment operator for adding Var to unsigned long |
2245 | { |
2246 | return other += da.convert<unsigned long>(); |
2247 | } |
2248 | |
2249 | |
2250 | inline unsigned long operator -= (unsigned long& other, const Var& da) |
2251 | /// Subtraction assignment operator for subtracting Var from unsigned long |
2252 | { |
2253 | return other -= da.convert<unsigned long>(); |
2254 | } |
2255 | |
2256 | |
2257 | inline unsigned long operator *= (unsigned long& other, const Var& da) |
2258 | /// Multiplication assignment operator for multiplying Var with unsigned long |
2259 | { |
2260 | return other *= da.convert<unsigned long>(); |
2261 | } |
2262 | |
2263 | |
2264 | inline unsigned long operator /= (unsigned long& other, const Var& da) |
2265 | /// Division assignment operator for dividing Var with unsigned long |
2266 | { |
2267 | return other /= da.convert<unsigned long>(); |
2268 | } |
2269 | |
2270 | |
2271 | inline bool operator == (const unsigned long& other, const Var& da) |
2272 | /// Equality operator for comparing Var with unsigned long |
2273 | { |
2274 | if (da.isEmpty()) return false; |
2275 | return other == da.convert<unsigned long>(); |
2276 | } |
2277 | |
2278 | |
2279 | inline bool operator != (const unsigned long& other, const Var& da) |
2280 | /// Inequality operator for comparing Var with unsigned long |
2281 | { |
2282 | if (da.isEmpty()) return true; |
2283 | return other != da.convert<unsigned long>(); |
2284 | } |
2285 | |
2286 | |
2287 | inline bool operator < (const unsigned long& other, const Var& da) |
2288 | /// Less than operator for comparing Var with unsigned long |
2289 | { |
2290 | if (da.isEmpty()) return false; |
2291 | return other < da.convert<unsigned long>(); |
2292 | } |
2293 | |
2294 | |
2295 | inline bool operator <= (const unsigned long& other, const Var& da) |
2296 | /// Less than or equal operator for comparing Var with unsigned long |
2297 | { |
2298 | if (da.isEmpty()) return false; |
2299 | return other <= da.convert<unsigned long>(); |
2300 | } |
2301 | |
2302 | |
2303 | inline bool operator > (const unsigned long& other, const Var& da) |
2304 | /// Greater than operator for comparing Var with unsigned long |
2305 | { |
2306 | if (da.isEmpty()) return false; |
2307 | return other > da.convert<unsigned long>(); |
2308 | } |
2309 | |
2310 | |
2311 | inline bool operator >= (const unsigned long& other, const Var& da) |
2312 | /// Greater than or equal operator for comparing Var with unsigned long |
2313 | { |
2314 | if (da.isEmpty()) return false; |
2315 | return other >= da.convert<unsigned long>(); |
2316 | } |
2317 | |
2318 | |
2319 | #endif // POCO_LONG_IS_64_BIT |
2320 | |
2321 | |
2322 | } // namespace Dynamic |
2323 | |
2324 | |
2325 | //@ deprecated |
2326 | typedef Dynamic::Var DynamicAny; |
2327 | |
2328 | |
2329 | } // namespace Poco |
2330 | |
2331 | |
2332 | #endif // Foundation_Var_INCLUDED |
2333 | |