SheafSystem  0.0.0.0
primitive_value.h
1 
2 //
3 // Copyright (c) 2014 Limit Point Systems, Inc.
4 //
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17 
18 // Interface for class primitive_value
19 
20 #ifndef PRIMITIVE_VALUE_H
21 #define PRIMITIVE_VALUE_H
22 
23 #ifndef SHEAF_DLL_SPEC_H
24 #include "SheafSystem/sheaf_dll_spec.h"
25 #endif
26 
27 #ifndef PRIMITIVE_TYPE_H
28 #include "SheafSystem/primitive_type.h"
29 #endif
30 
31 #ifndef NAMESPACE_RELATIVE_MEMBER_INDEX_H
32 #include "SheafSystem/namespace_relative_member_index.h"
33 #endif
34 
35 #ifndef NAMESPACE_RELATIVE_SUBPOSET_INDEX_H
36 #include "SheafSystem/namespace_relative_subposet_index.h"
37 #endif
38 
39 #ifndef STD_MAP_H
40 #include "SheafSystem/std_map.h"
41 #endif
42 
43 namespace sheaf
44 {
45 
46 template <typename T>
47 class block;
48 
49 
53 class SHEAF_DLL_SPEC primitive_value
54 {
55  friend SHEAF_DLL_SPEC bool operator==(const primitive_value& xpv1, const primitive_value& xpv2);
56 
57 public:
58 
63  static const primitive_value& prototype(pod_index_type xid);
64 
65  // ===========================================================
66  // CONSTRUCTORS
67  // ===========================================================
68 
73 
77  primitive_value(const primitive_value& xother);
78 
84 
90  primitive_value(pod_index_type xid, void* xvalue_ptr);
91 
96  primitive_value(const void* x);
97 
102  primitive_value(const char* x);
103 
108  primitive_value(const std::string& x);
109 
114  primitive_value(const scoped_index& x);
115 
121 
127 
132  primitive_value(const bool& x);
133 
138  primitive_value(const char& x);
139 
144  primitive_value(const signed char& x);
145 
150  primitive_value(const short int& x);
151 
156  primitive_value(const int& x);
157 
162  primitive_value(const long int& x);
163 
168  primitive_value(const long long int& x);
169 
174  primitive_value(const unsigned char& x);
175 
180  primitive_value(const unsigned short int& x);
181 
186  primitive_value(const unsigned int& x);
187 
192  primitive_value(const unsigned long int& x);
193 
198  primitive_value(const unsigned long long int& x);
199 
204  primitive_value(const float& x);
205 
210  primitive_value(const double& x);
211 
216  primitive_value(const long double& x);
217 
223 
229 
230  // ===========================================================
231  // ASSIGNMENT OPERATORS
232  // ===========================================================
233 
237  primitive_value& operator=(const primitive_value& x);
238 
242  primitive_value& operator=(void* x);
243 
247  primitive_value& operator=(const void* x);
248 
252  primitive_value& operator=(char* x);
253 
257  primitive_value& operator=(const char* x);
258 
262  template <typename T>
263  primitive_value& operator=(const T& x);
264 
265  // ===========================================================
266  // CONVERSION TO PRIMITIVE
267  // ===========================================================
268 
269  // ///
270  // /// Conversion to primitive of type T.
271  // ///
272  // template <typename T>
273  // operator T() const;
274 
278  operator bool() const;
279 
283  operator char() const;
284 
288  operator signed char() const;
289 
293  operator short int() const;
294 
298  operator int() const;
299 
303  operator long int() const;
304 
308  operator long long int() const;
309 
313  operator unsigned char() const;
314 
318  operator unsigned short int() const;
319 
323  operator unsigned int() const;
324 
328  operator unsigned long int() const;
329 
333  operator unsigned long long int() const;
334 
338  operator float() const;
339 
343  operator double() const;
344 
348  operator long double() const;
349 
353  operator void*() const;
354 
358  operator char*() const;
359 
364 
369 
370  // No conversion to string operator;
371  // creates ambiguity in conversion to string!
372 
373 
374  // ===========================================================
375  // DESTRUCTOR
376  // ===========================================================
377 
381  ~primitive_value();
382 
383  // ===========================================================
384  // VALUE
385  // ===========================================================
386 
391  {
392  return _value;
393  };
394 
399  {
400  return _value;
401  };
402 
407  {
408  return _id;
409  };
410 
414  const primitive_type& id() const
415  {
416  return _id;
417  };
418 
419  // ===========================================================
420  // SUPPORT FOR STREAMS
421  // ===========================================================
422 
426  std::string to_string() const;
427 
432  bool from_string(const std::string& x);
433 
434 private:
435 
439  primitive_buffer_type _value;
440 
444  primitive_type _id;
445 
449  static block<primitive_value>& make_prototypes();
450 };
451 
452 
453 // ===========================================================
454 // NON-MEMBER FUNCTIONS
455 // ===========================================================
456 
460 SHEAF_DLL_SPEC
461 bool
462 operator==(const primitive_value& xpv1, const primitive_value& xpv2);
463 
467 SHEAF_DLL_SPEC
468 bool
469 operator==(const primitive_value& xpv, const void* xval);
470 
474 SHEAF_DLL_SPEC
475 bool
476 operator==(const void* xval, const primitive_value& xpv);
477 
481 SHEAF_DLL_SPEC
482 bool
483 operator==(const primitive_value& xpv, const char* xval);
484 
488 SHEAF_DLL_SPEC
489 bool
490 operator==(const char* xval, const primitive_value& xpv);
491 
495 SHEAF_DLL_SPEC
496 bool
497 operator==(const primitive_value& xpv, const std::string& xval);
498 
502 SHEAF_DLL_SPEC
503 bool
504 operator==(const std::string& xval, const primitive_value& xpv);
505 
509 SHEAF_DLL_SPEC
510 bool
511 operator==(const primitive_value& xpv, const scoped_index& xval);
512 
516 SHEAF_DLL_SPEC
517 bool
518 operator==(const scoped_index& xval, const primitive_value& xpv);
519 
523 SHEAF_DLL_SPEC
524 bool
526 
530 SHEAF_DLL_SPEC
531 bool
533 
537 SHEAF_DLL_SPEC
538 bool
540 
544 SHEAF_DLL_SPEC
545 bool
547 
551 SHEAF_DLL_SPEC
552 bool
553 operator==(const primitive_value& xpv, const bool& xval);
554 
558 SHEAF_DLL_SPEC
559 bool
560 operator==(const bool& xval, const primitive_value& xpv);
561 
565 SHEAF_DLL_SPEC
566 bool
567 operator==(const primitive_value& xpv, const char& xval);
568 
572 SHEAF_DLL_SPEC
573 bool
574 operator==(const char& xval, const primitive_value& xpv);
575 
579 SHEAF_DLL_SPEC
580 bool
581 operator==(const primitive_value& xpv, const signed char& xval);
582 
586 SHEAF_DLL_SPEC
587 bool
588 operator==(const signed char& xval, const primitive_value& xpv);
589 
593 SHEAF_DLL_SPEC
594 bool
595 operator==(const primitive_value& xpv, const short int& xval);
596 
600 SHEAF_DLL_SPEC
601 bool
602 operator==(const short int& xval, const primitive_value& xpv);
603 
607 SHEAF_DLL_SPEC
608 bool
609 operator==(const primitive_value& xpv, const int& xval);
610 
614 SHEAF_DLL_SPEC
615 bool
616 operator==(const int& xval, const primitive_value& xpv);
617 
621 SHEAF_DLL_SPEC
622 bool
623 operator==(const primitive_value& xpv, const long int& xval);
624 
628 SHEAF_DLL_SPEC
629 bool
630 operator==(const long int& xval, const primitive_value& xpv);
631 
635 SHEAF_DLL_SPEC
636 bool
637 operator==(const primitive_value& xpv, const long long int& xval);
638 
642 SHEAF_DLL_SPEC
643 bool
644 operator==(const long long int& xval, const primitive_value& xpv);
645 
649 SHEAF_DLL_SPEC
650 bool
651 operator==(const primitive_value& xpv, const unsigned char& xval);
652 
656 SHEAF_DLL_SPEC
657 bool
658 operator==(const unsigned char& xval, const primitive_value& xpv);
659 
663 SHEAF_DLL_SPEC
664 bool
665 operator==(const primitive_value& xpv, const unsigned short int& xval);
666 
670 SHEAF_DLL_SPEC
671 bool
672 operator==(const unsigned short int& xval, const primitive_value& xpv);
673 
677 SHEAF_DLL_SPEC
678 bool
679 operator==(const primitive_value& xpv, const unsigned int& xval);
680 
684 SHEAF_DLL_SPEC
685 bool
686 operator==(const unsigned int& xval, const primitive_value& xpv);
687 
691 SHEAF_DLL_SPEC
692 bool
693 operator==(const primitive_value& xpv, const unsigned long int& xval);
694 
698 SHEAF_DLL_SPEC
699 bool
700 operator==(const unsigned long int& xval, const primitive_value& xpv);
701 
705 SHEAF_DLL_SPEC
706 bool
707 operator==(const primitive_value& xpv, const unsigned long long& xval);
708 
712 SHEAF_DLL_SPEC
713 bool
714 operator==(const unsigned long long& xval, const primitive_value& xpv);
715 
719 SHEAF_DLL_SPEC
720 bool
721 operator==(const primitive_value& xpv, const float& xval);
722 
726 SHEAF_DLL_SPEC
727 bool
728 operator==(const float& xval, const primitive_value& xpv);
729 
733 SHEAF_DLL_SPEC
734 bool
735 operator==(const primitive_value& xpv, const double& xval);
736 
740 SHEAF_DLL_SPEC
741 bool
742 operator==(const double& xval, const primitive_value& xpv);
743 
747 SHEAF_DLL_SPEC
748 bool
749 operator==(const primitive_value& xpv, const long double& xval);
750 
754 SHEAF_DLL_SPEC
755 bool
756 operator==(const long double& xval, const primitive_value& xpv);
757 
761 SHEAF_DLL_SPEC
762 bool
764 
768 SHEAF_DLL_SPEC
769 bool
771 
775 SHEAF_DLL_SPEC
776 bool
778 
782 SHEAF_DLL_SPEC
783 bool
785 
789 SHEAF_DLL_SPEC
790 std::ostream&
791 operator<<(std::ostream& xos, const primitive_value& xpv);
792 
797 size_t
798 SHEAF_DLL_SPEC
799 deep_size(const primitive_value& xpv, bool xinclude_shallow = true);
800 
801 
802 
803 } // namespace sheaf
804 
805 #endif // ifndef PRIMITIVE_VALUE_H
Index for identifying a poset member relative to a given name space.
const primitive_buffer_type & value() const
The value of this, const version.
primitive_type
Type ids for sheaf primitives.
Type of buffer large enough to hold any primitive type.
An index within the external ("client") scope of a given id space.
Definition: scoped_index.h:116
const primitive_type & id() const
Type id of the primitive type, const version.
SHEAF_DLL_SPEC size_t deep_size(const dof_descriptor_array &xp, bool xinclude_shallow=true)
The deep size of the referenced object of type dof_descriptor_array.
POD type associated with namespace_relative_subposet_index.
Definition: pod_types.h:111
POD type for namespace_relative_member_index.
Definition: pod_types.h:79
Index for identifying a subposet relative to a given name space.
primitive_buffer_type & value()
The value of this.
bool operator==(const singly_linked_list< T, Alloc > &lhs, const singly_linked_list< T, Alloc > &rhs)
Checks if the contents of lhs and rhs are equal, that is, whether lhs.size() == rhs.size() and each element in lhs compares equal with the element in rhs at the same position.
primitive_type & id()
Type id of the primitive type.
int_type pod_index_type
The plain old data index type.
Definition: pod_types.h:49
SHEAF_DLL_SPEC std::ostream & operator<<(std::ostream &os, const dof_descriptor_array &p)
Insert dof_descriptor_array& p into ostream& os.
Namespace for the sheaves component of the sheaf system.
Abstract object wrapper for an instance of a primitive type.
An auto_block with a no-initialization initialization policy.