BALL  1.4.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
colorUnit.h
Go to the documentation of this file.
1 // -*- Mode: C++; tab-width: 2; -*-
2 // vi: set ts=2:
3 //
4 
5 #ifndef BALL_VIEW_DATATYPE_COLORUNIT_H
6 #define BALL_VIEW_DATATYPE_COLORUNIT_H
7 
8 #ifndef BALL_COMMON_H
9 # include <BALL/common.h>
10 #endif
11 
12 #ifndef BALL_DATATYPE_STRING_H
13 # include <BALL/DATATYPE/string.h>
14 #endif
15 
16 #include <iostream>
17 #include <stdio.h>
18 
19 namespace BALL
20 {
21  namespace VIEW
22  {
37  {
38  public:
39 
40  //BALL_CREATE(ColorUnit)
41 
45 
53  {
54  public:
55 
56  NotInHexFormat(const char* file, int line, const string& data);
57  };
58 
60 
63 
67  ColorUnit();
68 
71  ColorUnit(const ColorUnit& color_unit);
72 
79  ColorUnit(const char* value);
80 
86  ColorUnit(const String& value);
87 
91  ColorUnit(const unsigned char value);
92 
97  ColorUnit(const short value);
98 
103  ColorUnit(const unsigned short value);
104 
109  ColorUnit(const int value);
110 
115  ColorUnit(const unsigned int value);
116 
121  ColorUnit(const long value);
122 
127  ColorUnit(const unsigned long value);
128 
133  ColorUnit(const float value);
134 
139  ColorUnit(const double value);
140 
142 
144 
147  ~ColorUnit();
148 
155  void clear();
156 
158 
161 
165  operator String () const;
166 
170  operator char () const;
171 
175  operator unsigned char () const;
176 
180  operator short () const;
181 
185  operator unsigned short () const;
186 
190  operator int () const;
191 
195  operator unsigned int () const;
196 
200  operator long () const;
201 
205  operator unsigned long () const;
206 
210  operator float () const;
211 
215  operator double () const;
216 
218 
221 
224  void set(const ColorUnit& color_unit);
225 
229  const ColorUnit& operator = (const ColorUnit& color_unit);
230 
233  void swap(ColorUnit& color_unit);
234 
236 
239 
245  void set(const char* value);
246 
253  const ColorUnit& operator = (const char* value);
254 
260  void get(char* value) const;
261 
269  void set(const String& value);
270 
277  const ColorUnit& operator = (const String& value);
278 
282  void get(String& value) const;
283 
287  void set(const unsigned char value);
288 
293  const ColorUnit& operator = (const unsigned char value);
294 
298  void get(unsigned char& value) const;
299 
304  void set(const short value);
305 
311  const ColorUnit& operator = (const short value);
312 
316  void get(short& value) const;
317 
322  void set(const unsigned short value);
323 
329  const ColorUnit& operator = (const unsigned short value);
330 
334  void get(unsigned short& value) const;
335 
340  void set(const int value);
341 
347  const ColorUnit& operator = (const int value);
348 
352  void get(int& value) const;
353 
358  void set(const unsigned int value);
359 
365  const ColorUnit& operator = (const unsigned int value);
366 
370  void get(unsigned int& value) const;
371 
376  void set(const long value);
377 
383  const ColorUnit& operator = (const long value);
384 
388  void get(long& value) const;
389 
394  void set(const unsigned long value);
395 
401  const ColorUnit& operator = (const unsigned long value);
402 
406  void get(unsigned long& value) const;
407 
412  void set(const float value);
413 
419  const ColorUnit& operator = (const float value);
420 
424  void get(float& value) const;
425 
430  void set(const double value);
431 
437  const ColorUnit& operator = (const double value);
438 
442  void get(double& value) const;
443 
445 
448 
453  bool operator == (const ColorUnit& color_unit) const;
454 
459  bool operator != (const ColorUnit& color_unit) const;
460 
465  bool operator < (const ColorUnit& color_unit) const;
466 
471  bool operator <= (const ColorUnit& color_unit) const;
472 
477  bool operator > (const ColorUnit& color_unit) const;
478 
483  bool operator >= (const ColorUnit& color_unit) const;
484 
486 
489 
497  void dump(std::ostream& s = std::cout, Size depth = 0) const;
498 
500 
503 
511  friend std::istream& operator >> (std::istream& s, ColorUnit& color_unit);
512 
519  friend std::ostream& operator << (std::ostream& s, const ColorUnit& color_unit);
521 
522  private:
523 
524  // @throws Exception::InvalidRange
525  // @throws Exception::NotInHexFormat
526  float hexToFloat_(const char* value);
527 
528  float value_;
529 
530  };
531 
532 # ifndef BALL_NO_INLINE_FUNCTIONS
533 # include <BALL/VIEW/DATATYPE/colorUnit.iC>
534 # endif
535 
536  } // namespace VIEW
537 } // namespace BALL
538 
539 #endif // BALL_VIEW_DATATYPE_COLORUNIT_H