00001
00002
00003
00004
00005 #ifndef BALL_VIEW_DATATYPE_COLORUNIT_H
00006 #define BALL_VIEW_DATATYPE_COLORUNIT_H
00007
00008 #ifndef BALL_COMMON_H
00009 # include <BALL/common.h>
00010 #endif
00011
00012 #ifndef BALL_DATATYPE_STRING_H
00013 # include <BALL/DATATYPE/string.h>
00014 #endif
00015
00016 #include <iostream>
00017 #include <stdio.h>
00018
00019 namespace BALL
00020 {
00021 namespace VIEW
00022 {
00036 class BALL_VIEW_EXPORT ColorUnit
00037 {
00038 public:
00039
00040
00041
00045
00052 class BALL_VIEW_EXPORT NotInHexFormat: public Exception::GeneralException
00053 {
00054 public:
00055
00056 NotInHexFormat(const char* file, int line, const string& data);
00057 };
00058
00060
00063
00067 ColorUnit();
00068
00071 ColorUnit(const ColorUnit& color_unit);
00072
00079 ColorUnit(const char* value);
00080
00086 ColorUnit(const String& value);
00087
00091 ColorUnit(const unsigned char value);
00092
00097 ColorUnit(const short value);
00098
00103 ColorUnit(const unsigned short value);
00104
00109 ColorUnit(const int value);
00110
00115 ColorUnit(const unsigned int value);
00116
00121 ColorUnit(const long value);
00122
00127 ColorUnit(const unsigned long value);
00128
00133 ColorUnit(const float value);
00134
00139 ColorUnit(const double value);
00140
00142
00144
00147 ~ColorUnit();
00148
00155 void clear();
00156
00158
00161
00165 operator String () const;
00166
00170 operator char () const;
00171
00175 operator unsigned char () const;
00176
00180 operator short () const;
00181
00185 operator unsigned short () const;
00186
00190 operator int () const;
00191
00195 operator unsigned int () const;
00196
00200 operator long () const;
00201
00205 operator unsigned long () const;
00206
00210 operator float () const;
00211
00215 operator double () const;
00216
00218
00221
00224 void set(const ColorUnit& color_unit);
00225
00229 const ColorUnit& operator = (const ColorUnit& color_unit);
00230
00233 void swap(ColorUnit& color_unit);
00234
00236
00239
00245 void set(const char* value);
00246
00253 const ColorUnit& operator = (const char* value);
00254
00260 void get(char* value) const;
00261
00269 void set(const String& value);
00270
00277 const ColorUnit& operator = (const String& value);
00278
00282 void get(String& value) const;
00283
00287 void set(const unsigned char value);
00288
00293 const ColorUnit& operator = (const unsigned char value);
00294
00298 void get(unsigned char& value) const;
00299
00304 void set(const short value);
00305
00311 const ColorUnit& operator = (const short value);
00312
00316 void get(short& value) const;
00317
00322 void set(const unsigned short value);
00323
00329 const ColorUnit& operator = (const unsigned short value);
00330
00334 void get(unsigned short& value) const;
00335
00340 void set(const int value);
00341
00347 const ColorUnit& operator = (const int value);
00348
00352 void get(int& value) const;
00353
00358 void set(const unsigned int value);
00359
00365 const ColorUnit& operator = (const unsigned int value);
00366
00370 void get(unsigned int& value) const;
00371
00376 void set(const long value);
00377
00383 const ColorUnit& operator = (const long value);
00384
00388 void get(long& value) const;
00389
00394 void set(const unsigned long value);
00395
00401 const ColorUnit& operator = (const unsigned long value);
00402
00406 void get(unsigned long& value) const;
00407
00412 void set(const float value);
00413
00419 const ColorUnit& operator = (const float value);
00420
00424 void get(float& value) const;
00425
00430 void set(const double value);
00431
00437 const ColorUnit& operator = (const double value);
00438
00442 void get(double& value) const;
00443
00445
00448
00453 bool operator == (const ColorUnit& color_unit) const;
00454
00459 bool operator != (const ColorUnit& color_unit) const;
00460
00465 bool operator < (const ColorUnit& color_unit) const;
00466
00471 bool operator <= (const ColorUnit& color_unit) const;
00472
00477 bool operator > (const ColorUnit& color_unit) const;
00478
00483 bool operator >= (const ColorUnit& color_unit) const;
00484
00486
00489
00497 void dump(std::ostream& s = std::cout, Size depth = 0) const;
00498
00500
00503
00511 friend std::istream& operator >> (std::istream& s, ColorUnit& color_unit);
00512
00519 friend std::ostream& operator << (std::ostream& s, const ColorUnit& color_unit);
00521
00522 private:
00523
00524
00525
00526 float hexToFloat_(const char* value);
00527
00528 float value_;
00529
00530 };
00531
00532 # ifndef BALL_NO_INLINE_FUNCTIONS
00533 # include <BALL/VIEW/DATATYPE/colorUnit.iC>
00534 # endif
00535
00536 }
00537 }
00538
00539 #endif // BALL_VIEW_DATATYPE_COLORUNIT_H