Visualization Library 2.0.0

A lightweight C++ OpenGL middleware for 2D/3D graphics

VL     Star     Watch     Fork     Issue

[Download] [Tutorials] [All Classes] [Grouped Classes]
Say.hpp
Go to the documentation of this file.
1 /**************************************************************************************/
2 /* */
3 /* Visualization Library */
4 /* http://visualizationlibrary.org */
5 /* */
6 /* Copyright (c) 2005-2020, Michele Bosi */
7 /* All rights reserved. */
8 /* */
9 /* Redistribution and use in source and binary forms, with or without modification, */
10 /* are permitted provided that the following conditions are met: */
11 /* */
12 /* - Redistributions of source code must retain the above copyright notice, this */
13 /* list of conditions and the following disclaimer. */
14 /* */
15 /* - Redistributions in binary form must reproduce the above copyright notice, this */
16 /* list of conditions and the following disclaimer in the documentation and/or */
17 /* other materials provided with the distribution. */
18 /* */
19 /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND */
20 /* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED */
21 /* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */
22 /* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR */
23 /* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES */
24 /* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
25 /* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON */
26 /* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */
27 /* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */
28 /* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
29 /* */
30 /**************************************************************************************/
31 
32 #ifndef Say_INCLUDE_ONCE
33 #define Say_INCLUDE_ONCE
34 
35 #include <vlCore/String.hpp>
36 #include <string>
37 
38 namespace vl
39 {
40  //-----------------------------------------------------------------------------
41  // SayArg
42  //-----------------------------------------------------------------------------
45  {
46  friend class Say;
47  public:
48  SayArg();
49 
50  explicit SayArg(const unsigned char* d);
51 
52  explicit SayArg(const std::string& d);
53 
54  explicit SayArg(const char* d);
55 
56  explicit SayArg(void* d);
57 
58  explicit SayArg(const String& d);
59 
60  explicit SayArg(double d);
61 
62  explicit SayArg(float d);
63 
64  explicit SayArg(unsigned char d);
65 
66  explicit SayArg(signed char d);
67 
68  explicit SayArg(unsigned short d);
69 
70  explicit SayArg(signed short d);
71 
72  explicit SayArg(unsigned int d);
73 
74  explicit SayArg(signed int d);
75 
76  explicit SayArg(unsigned long d);
77 
78  explicit SayArg(signed long d);
79 
80  explicit SayArg(unsigned long long d);
81 
82  explicit SayArg(signed long long d);
83 
84  protected:
85  void init();
86 
88  double float64;
89  unsigned long long ulonglong;
90  signed long long slonglong;
91 
92  enum
93  {
98  SLONGLONG
99  } type;
100 
101  };
102  //-----------------------------------------------------------------------------
103  // Say
104  //-----------------------------------------------------------------------------
124  class VLCORE_EXPORT Say: public std::vector<SayArg>
125  {
126  public:
128 
129  Say(const String& fstr)
130  {
131  format_string = fstr;
132  }
133 
134  Say& operator<<(const SayArg& p)
135  {
136  push_back(p);
137  return *this;
138  }
139 
140  template <typename T>
142  {
143  push_back(SayArg(p));
144  return *this;
145  }
146 
147  operator String()
148  {
149  return parse(*this);
150  }
151 
152  String str() const
153  {
154  return parse(*this);
155  }
156 
157  protected:
158  String parse( const Say& pset ) const;
159 
160  String euronotation(const String& str, int base) const;
161 
162  String format(unsigned long long n, int base, int field, int decimals, int align, int fill, int plus, int finalizer, int eur) const;
163 
164  String format(signed long long nn, int base, int field, int decimals, int align, int fill, int plus, int finalizer, int eur) const;
165 
166  String format(double num, int base, int field, int decimals, int align, int fill, int plus, int finalizer, int eur) const;
167 
168  String pipeline(const String& str, int base, int field, int decimals, int finalizer, int align, int eur, int fill, int negative, int plus) const;
169  };
170 }
171 
172 #endif
double float64
Definition: Say.hpp:88
signed long long slonglong
Definition: Say.hpp:90
A simple String formatting class.
Definition: Say.hpp:124
The String class implements an advanced UTF16 (Unicode BMP) string manipulation engine.
Definition: String.hpp:62
Used internally by the Say class.
Definition: Say.hpp:44
unsigned long long ulonglong
Definition: Say.hpp:89
Visualization Library main namespace.
String str() const
Definition: Say.hpp:152
Say & operator<<(T p)
Definition: Say.hpp:141
Say & operator<<(const SayArg &p)
Definition: Say.hpp:134
String format_string
Definition: Say.hpp:127
String str
Definition: Say.hpp:87
Say(const String &fstr)
Definition: Say.hpp:129