You.i Engine
YiObjectPrinter.h
Go to the documentation of this file.
1 // © You i Labs Inc. 2000-2020. All rights reserved.
2 #ifndef _YI_OBJECT_PRINTER_H_
3 #define _YI_OBJECT_PRINTER_H_
4 
5 #include "utility/YiString.h"
6 #include "utility/YiTypeTraits.h"
7 
8 #include <deque>
9 #include <list>
10 #include <map>
11 #include <memory>
12 #include <set>
13 #include <vector>
14 
15 class CYIAny;
16 
58 {
59 public:
60 #if defined(DOXY)
61 
65  template<typename TYPE>
66  static CYIString ToString(const TYPE &object);
67 
68 #else
69 
70  // Basic types
71  static CYIString ToString(const bool object);
72  static CYIString ToString(const CYIString &object);
73  static CYIString ToString(const std::string &object);
74  static CYIString ToString(const char *pObject);
75  static CYIString ToString(char object);
76  static CYIString ToString(const CYIAny &object);
77  static CYIString ToString(std::nullptr_t nullObject);
78 
79  // Lists and associative containers
80  template<typename T, typename A>
81  static CYIString ToString(const std::vector<T, A> &object);
82  template<typename T, typename A>
83  static CYIString ToString(const std::list<T, A> &object);
84  template<typename T, typename A>
85  static CYIString ToString(const std::deque<T, A> &object);
86  template<typename T, typename C, typename A>
87  static CYIString ToString(const std::set<T, C, A> &object);
88  template<typename T, typename C, typename A>
89  static CYIString ToString(const std::multiset<T, C, A> &object);
90  template<typename K, typename V, typename C, typename A>
91  static CYIString ToString(const std::map<K, V, C, A> &object);
92  template<typename K, typename V, typename C, typename A>
93  static CYIString ToString(const std::multimap<K, V, C, A> &object);
94 
95  // Raw pointers
96  static CYIString ToString(const void *pPointer);
97  template<typename T>
98  static CYIString ToString(T *pPointer);
99  template<typename T>
100  static CYIString ToString(const T *pPointer);
101 
102  // Smart pointers
103  template<typename T>
104  static CYIString ToString(const std::shared_ptr<T> &pPointer);
105  template<typename T>
106  static CYIString ToString(const std::weak_ptr<T> &pPointer);
107  template<typename T>
108  static CYIString ToString(const std::unique_ptr<T> &pPointer);
109 
110  // Default
111  template<typename T>
113  template<typename T>
115 
116 private:
118 
119  template<typename T>
120  static CYIString ListToString(const T &container);
121  template<typename T>
122  static CYIString MapToString(const T &container);
123 
124  static bool TryIncrementPointerCount();
125  static void DecrementPointerCount();
126 
127 #endif
128 
130 };
131 
134 #include "utility/YiObjectPrinter.inl"
135 
136 #endif
#define YI_DISALLOW_COPY_AND_ASSIGN(TypeName)
Delete the copy constructor and assignment operator (and consequently the move constructor as well) ...
Definition: YiPredef.h:122
Container class for Unicode strings. Conceptually, a CYIString object is a sequence of Unicode charac...
Definition: YiString.h:36
A class used to get the string representation of an object or of a complex type.
Definition: YiObjectPrinter.h:57
A class that holds instances of any type that is copy-constructible.
Definition: YiAny.h:77
static CYIString ToString(const TYPE &object)
Definition: YiTypeTraits.h:578