# # Name: ISO_646.irv:1983 to Unicode # Unicode version: 2.0 # Table version: 0.1 # Table format: Format A # Date: 0097-01-24 # Authors: John Cowan (conversion) # Keld Simonsen (RFC 1345) # # General notes: # # This table contains data obtained from RFC 1345 on how # ISO_646.irv:1983 characters map into Unicode. # # Format: Three tab-separated columns # Column #1 is the ISO_646.irv:1983 code (in hex as 0xXX) # Column #2 is the Unicode (in hex as 0xXXXX) # Column #3 the Unicode name (follows a comment sign, '#') # # The entries are in ISO_646.irv:1983 order # # Any comments or problems, contact # # &rem source: ECMA registry # &alias iso-ir-2 # &alias irv # &g0esc x2840 &g1esc x2940 &g2esc x2a40 &g3esc x2b40 0x00 0x0000 # NULL (NUL) 0x01 0x0001 # START OF HEADING (SOH) 0x02 0x0002 # START OF TEXT (STX) 0x03 0x0003 # END OF TEXT (ETX) 0x04 0x0004 # END OF TRANSMISSION (EOT) 0x05 0x0005 # ENQUIRY (ENQ) 0x06 0x0006 # ACKNOWLEDGE (ACK) 0x07 0x0007 # BELL (BEL) 0x08 0x0008 # BACKSPACE (BS) 0x09 0x0009 # CHARACTER TABULATION (HT) 0x0A 0x000A # LINE FEED (LF) 0x0B 0x000B # LINE TABULATION (VT) 0x0C 0x000C # FORM FEED (FF) 0x0D 0x000D # CARRIAGE RETURN (CR) 0x0E 0x000E # SHIFT OUT (SO) 0x0F 0x000F # SHIFT IN (SI) 0x10 0x0010 # DATALINK ESCAPE (DLE) 0x11 0x0011 # DEVICE CONTROL ONE (DC1) 0x12 0x0012 # DEVICE CONTROL TWO (DC2) 0x13 0x0013 # DEVICE CONTROL THREE (DC3) 0x14 0x0014 # DEVICE CONTROL FOUR (DC4) 0x15 0x0015 # NEGATIVE ACKNOWLEDGE (NAK) 0x16 0x0016 # SYNCRONOUS IDLE (SYN) 0x17 0x0017 # END OF TRANSMISSION BLOCK (ETB) 0x18 0x0018 # CANCEL (CAN) 0x19 0x0019 # END OF MEDIUM (EM) 0x1A 0x001A # SUBSTITUTE (SUB) 0x1B 0x001B # ESCAPE (ESC) 0x1C 0x001C # FILE SEPARATOR (IS4) 0x1D 0x001D # GROUP SEPARATOR (IS3) 0x1E 0x001E # RECORD SEPARATOR (IS2) 0x1F 0x001F # UNIT SEPARATOR (IS1) 0x20 0x0020 # SPACE 0x21 0x0021 # EXCLAMATION MARK 0x22 0x0022 # QUOTATION MARK 0x23 0x0023 # NUMBER SIGN 0x24 0x00A4 # CURRENCY SIGN 0x25 0x0025 # PERCENT SIGN 0x26 0x0026 # AMPERSAND 0x27 0x0027 # APOSTROPHE 0x28 0x0028 # LEFT PARENTHESIS 0x29 0x0029 # RIGHT PARENTHESIS 0x2A 0x002A # ASTERISK 0x2B 0x002B # PLUS SIGN 0x2C 0x002C # COMMA 0x2D 0x002D # HYPHEN-MINUS 0x2E 0x002E # FULL STOP 0x2F 0x002F # SOLIDUS 0x30 0x0030 # DIGIT ZERO 0x31 0x0031 # DIGIT ONE 0x32 0x0032 # DIGIT TWO 0x33 0x0033 # DIGIT THREE 0x34 0x0034 # DIGIT FOUR 0x35 0x0035 # DIGIT FIVE 0x36 0x0036 # DIGIT SIX 0x37 0x0037 # DIGIT SEVEN 0x38 0x0038 # DIGIT EIGHT 0x39 0x0039 # DIGIT NINE 0x3A 0x003A # COLON 0x3B 0x003B # SEMICOLON 0x3C 0x003C # LESS-THAN SIGN 0x3D 0x003D # EQUALS SIGN 0x3E 0x003E # GREATER-THAN SIGN 0x3F 0x003F # QUESTION MARK 0x40 0x0040 # COMMERCIAL AT 0x41 0x0041 # LATIN CAPITAL LETTER A 0x42 0x0042 # LATIN CAPITAL LETTER B 0x43 0x0043 # LATIN CAPITAL LETTER C 0x44 0x0044 # LATIN CAPITAL LETTER D 0x45 0x0045 # LATIN CAPITAL LETTER E 0x46 0x0046 # LATIN CAPITAL LETTER F 0x47 0x0047 # LATIN CAPITAL LETTER G 0x48 0x0048 # LATIN CAPITAL LETTER H 0x49 0x0049 # LATIN CAPITAL LETTER I 0x4A 0x004A # LATIN CAPITAL LETTER J 0x4B 0x004B # LATIN CAPITAL LETTER K 0x4C 0x004C # LATIN CAPITAL LETTER L 0x4D 0x004D # LATIN CAPITAL LETTER M 0x4E 0x004E # LATIN CAPITAL LETTER N 0x4F 0x004F # LATIN CAPITAL LETTER O 0x50 0x0050 # LATIN CAPITAL LETTER P 0x51 0x0051 # LATIN CAPITAL LETTER Q 0x52 0x0052 # LATIN CAPITAL LETTER R 0x53 0x0053 # LATIN CAPITAL LETTER S 0x54 0x0054 # LATIN CAPITAL LETTER T 0x55 0x0055 # LATIN CAPITAL LETTER U 0x56 0x0056 # LATIN CAPITAL LETTER V 0x57 0x0057 # LATIN CAPITAL LETTER W 0x58 0x0058 # LATIN CAPITAL LETTER X 0x59 0x0059 # LATIN CAPITAL LETTER Y 0x5A 0x005A # LATIN CAPITAL LETTER Z 0x5B 0x005B # LEFT SQUARE BRACKET 0x5C 0x005C # REVERSE SOLIDUS 0x5D 0x005D # RIGHT SQUARE BRACKET 0x5E 0x005E # CIRCUMFLEX ACCENT 0x5F 0x005F # LOW LINE 0x60 0x0060 # GRAVE ACCENT 0x61 0x0061 # LATIN SMALL LETTER A 0x62 0x0062 # LATIN SMALL LETTER B 0x63 0x0063 # LATIN SMALL LETTER C 0x64 0x0064 # LATIN SMALL LETTER D 0x65 0x0065 # LATIN SMALL LETTER E 0x66 0x0066 # LATIN SMALL LETTER F 0x67 0x0067 # LATIN SMALL LETTER G 0x68 0x0068 # LATIN SMALL LETTER H 0x69 0x0069 # LATIN SMALL LETTER I 0x6A 0x006A # LATIN SMALL LETTER J 0x6B 0x006B # LATIN SMALL LETTER K 0x6C 0x006C # LATIN SMALL LETTER L 0x6D 0x006D # LATIN SMALL LETTER M 0x6E 0x006E # LATIN SMALL LETTER N 0x6F 0x006F # LATIN SMALL LETTER O 0x70 0x0070 # LATIN SMALL LETTER P 0x71 0x0071 # LATIN SMALL LETTER Q 0x72 0x0072 # LATIN SMALL LETTER R 0x73 0x0073 # LATIN SMALL LETTER S 0x74 0x0074 # LATIN SMALL LETTER T 0x75 0x0075 # LATIN SMALL LETTER U 0x76 0x0076 # LATIN SMALL LETTER V 0x77 0x0077 # LATIN SMALL LETTER W 0x78 0x0078 # LATIN SMALL LETTER X 0x79 0x0079 # LATIN SMALL LETTER Y 0x7A 0x007A # LATIN SMALL LETTER Z 0x7B 0x007B # LEFT CURLY BRACKET 0x7C 0x007C # VERTICAL LINE 0x7D 0x007D # RIGHT CURLY BRACKET 0x7E 0x203E # OVERLINE 0x7F 0x007F # DELETE (DEL) 8'>58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459
/* ----------------------------------------------------------------------------
   libconfig - A library for processing structured configuration files
   Copyright (C) 2005-2010  Mark A Lindner

   This file is part of libconfig.

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public License
   as published by the Free Software Foundation; either version 2.1 of
   the License, or (at your option) any later version.

   This library is distributed in the hope that it will be useful, but
   WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Lesser General Public License for more details.

   You should have received a copy of the GNU Library General Public
   License along with this library; if not, see
   <http://www.gnu.org/licenses/>.
   ----------------------------------------------------------------------------
*/

#ifndef __libconfig_hpp
#define __libconfig_hpp

#include <stdio.h>
#include <exception>
#include <string>

#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
#if defined(LIBCONFIGXX_STATIC)
#define LIBCONFIGXX_API
#elif defined(LIBCONFIGXX_EXPORTS)
#define LIBCONFIGXX_API __declspec(dllexport)
#else /* ! LIBCONFIGXX_EXPORTS */
#define LIBCONFIGXX_API __declspec(dllimport)
#endif /* LIBCONFIGXX_STATIC */
#else /* ! WIN32 */
#define LIBCONFIGXX_API
#endif /* WIN32 */

#define LIBCONFIGXX_VER_MAJOR    1
#define LIBCONFIGXX_VER_MINOR    4
#define LIBCONFIGXX_VER_REVISION 8

struct config_t; // fwd decl
struct config_setting_t; // fwd decl

namespace libconfig {

class LIBCONFIGXX_API ConfigException : public std::exception { };

class Setting; // fwd decl

class LIBCONFIGXX_API SettingException : public ConfigException
{
  friend class Config;

  public:

  SettingException(const SettingException &other);
  SettingException& operator=(const SettingException &other);

  virtual ~SettingException() throw();

  const char *getPath() const;

  virtual const char *what() const throw();

  protected:

  SettingException(const Setting &setting);
  SettingException(const Setting &setting, int idx);
  SettingException(const Setting &setting, const char *name);
  SettingException(const char *path);

  private:

  char *_path;
};

class LIBCONFIGXX_API SettingTypeException : public SettingException
{
  friend class Config;
  friend class Setting;

  public:

  const char *what() const throw();

  private:

  SettingTypeException(const Setting &setting);
  SettingTypeException(const Setting &setting, int idx);
  SettingTypeException(const Setting &setting, const char *name);
};

class LIBCONFIGXX_API SettingNotFoundException : public SettingException
{
  friend class Config;
  friend class Setting;

  public:

  const char *what() const throw();

  private:

  SettingNotFoundException(const Setting &setting, int idx);
  SettingNotFoundException(const Setting &setting, const char *name);
  SettingNotFoundException(const char *path);
};

class LIBCONFIGXX_API SettingNameException : public SettingException
{
  friend class Config;
  friend class Setting;

  public:

  const char *what() const throw();

  private:

  SettingNameException(const Setting &setting, const char *name);
};

class LIBCONFIGXX_API FileIOException : public ConfigException
{
  public:

  const char *what() const throw();
};

class LIBCONFIGXX_API ParseException : public ConfigException
{
  friend class Config;

  public:

  ParseException(const ParseException &other);

  virtual ~ParseException() throw();

  inline const char *getFile() const throw()
  { return(_file); }

  inline int getLine() const throw()
  { return(_line); }

  inline const char *getError() const throw()
  { return(_error); }

  const char *what() const throw();

  private:

  ParseException(const char *file, int line, const char *error);

  const char *_file;
  int _line;
  const char *_error;
};

class LIBCONFIGXX_API Setting
{
  friend class Config;

  public:

  enum Type
  {
    TypeNone = 0,
    // scalar types
    TypeInt,
    TypeInt64,
    TypeFloat,
    TypeString,
    TypeBoolean,
    // aggregate types
    TypeGroup,
    TypeArray,
    TypeList
  };

  enum Format
  {
    FormatDefault = 0,
    FormatHex = 1
  };

  private:

  config_setting_t *_setting;
  Type _type;
  Format _format;

  Setting(config_setting_t *setting);

  void assertType(Type type) const
    throw(SettingTypeException);
  static Setting & wrapSetting(config_setting_t *setting);

  Setting(const Setting& other); // not supported
  Setting& operator=(const Setting& other); // not supported

  public:

  virtual ~Setting() throw();

  inline Type getType() const throw() { return(_type); }

  inline Format getFormat() const throw() { return(_format); }
  void setFormat(Format format) throw();

  operator bool() const throw(SettingTypeException);
  operator int() const throw(SettingTypeException);
  operator unsigned int() const throw(SettingTypeException);
  operator long() const throw(SettingTypeException);
  operator unsigned long() const throw(SettingTypeException);
  operator long long() const throw(SettingTypeException);
  operator unsigned long long() const throw(SettingTypeException);
  operator double() const throw(SettingTypeException);
  operator float() const throw(SettingTypeException);
  operator const char *() const throw(SettingTypeException);
  operator std::string() const throw(SettingTypeException);

  inline const char *c_str() const throw(SettingTypeException)
  { return operator const char*(); }

  Setting & operator=(bool value) throw(SettingTypeException);
  Setting & operator=(int value) throw(SettingTypeException);
  Setting & operator=(long value) throw(SettingTypeException);
  Setting & operator=(const long long &value) throw(SettingTypeException);
  Setting & operator=(const double &value) throw(SettingTypeException);
  Setting & operator=(float value) throw(SettingTypeException);
  Setting & operator=(const char *value) throw(SettingTypeException);
  Setting & operator=(const std::string &value) throw(SettingTypeException);

  Setting & operator[](const char *key) const
    throw(SettingTypeException, SettingNotFoundException);

  inline Setting & operator[](const std::string &key) const
    throw(SettingTypeException, SettingNotFoundException)
  { return(operator[](key.c_str())); }

  Setting & operator[](int index) const
    throw(SettingTypeException, SettingNotFoundException);

  bool lookupValue(const char *name, bool &value) const throw();
  bool lookupValue(const char *name, int &value) const throw();
  bool lookupValue(const char *name, unsigned int &value) const throw();
  bool lookupValue(const char *name, long long &value) const throw();
  bool lookupValue(const char *name, unsigned long long &value)
    const throw();
  bool lookupValue(const char *name, double &value) const throw();
  bool lookupValue(const char *name, float &value) const throw();
  bool lookupValue(const char *name, const char *&value) const throw();
  bool lookupValue(const char *name, std::string &value) const throw();

  inline bool lookupValue(const std::string &name, bool &value)
    const throw()
  { return(lookupValue(name.c_str(), value)); }

  inline bool lookupValue(const std::string &name, int &value)
    const throw()
  { return(lookupValue(name.c_str(), value)); }

  inline bool lookupValue(const std::string &name, unsigned int &value)
    const throw()
  { return(lookupValue(name.c_str(), value)); }

  inline bool lookupValue(const std::string &name, long long &value)
    const throw()
  { return(lookupValue(name.c_str(), value)); }

  inline bool lookupValue(const std::string &name,
                          unsigned long long &value) const throw()
  { return(lookupValue(name.c_str(), value)); }

  inline bool lookupValue(const std::string &name, double &value) const
    throw()
  { return(lookupValue(name.c_str(), value)); }

  inline bool lookupValue(const std::string &name, float &value) const
    throw()
  { return(lookupValue(name.c_str(), value)); }

  inline bool lookupValue(const std::string &name, const char *&value) const
    throw()
  { return(lookupValue(name.c_str(), value)); }

  inline bool lookupValue(const std::string &name, std::string &value) const
    throw()
  { return(lookupValue(name.c_str(), value)); }

  void remove(const char *name)
    throw(SettingTypeException, SettingNotFoundException);

  inline void remove(const std::string & name)
    throw(SettingTypeException, SettingNotFoundException)
  { remove(name.c_str()); }

  void remove(unsigned int idx)
    throw(SettingTypeException, SettingNotFoundException);

  inline Setting & add(const std::string & name, Type type)
    throw(SettingNameException, SettingTypeException)
  { return(add(name.c_str(), type)); }

  Setting & add(const char *name, Type type)
    throw(SettingNameException, SettingTypeException);

  Setting & add(Type type) throw(SettingTypeException);

  inline bool exists(const std::string &name) const throw()
  { return(exists(name.c_str())); }

  bool exists(const char *name) const throw();

  int getLength() const throw();
  const char *getName() const throw();
  std::string getPath() const;
  int getIndex() const throw();

  const Setting & getParent() const throw(SettingNotFoundException);
  Setting & getParent() throw(SettingNotFoundException);

  bool isRoot() const throw();

  inline bool isGroup() const throw()
  { return(_type == TypeGroup); }

  inline bool isArray() const throw()
  { return(_type == TypeArray); }

  inline bool isList() const throw()
  { return(_type == TypeList); }

  inline bool isAggregate() const throw()
  { return(_type >= TypeGroup); }

  inline bool isScalar() const throw()
  { return((_type > TypeNone) && (_type < TypeGroup)); }

  inline bool isNumber() const throw()
  { return((_type == TypeInt) || (_type == TypeInt64)
           || (_type == TypeFloat)); }

  unsigned int getSourceLine() const throw();
  const char *getSourceFile() const throw();
};

class LIBCONFIGXX_API Config
{
  private:

  config_t *_config;

  static void ConfigDestructor(void *arg);
  Config(const Config& other); // not supported
  Config& operator=(const Config& other); // not supported

  public:

  Config();
  virtual ~Config();

  void setAutoConvert(bool flag);
  bool getAutoConvert() const;

  void setDefaultFormat(Setting::Format format);
  inline Setting::Format getDefaultFormat() const
  { return(_defaultFormat); }

  void setTabWidth(unsigned short width) throw();
  unsigned short getTabWidth() const throw();

  void setIncludeDir(const char *includeDir) throw();
  const char *getIncludeDir() const throw();

  void read(FILE *stream) throw(ParseException);
  void write(FILE *stream) const;

  void readString(const char *str) throw(ParseException);
  inline void readString(const std::string &str) throw(ParseException)
  { return(readString(str.c_str())); }

  void readFile(const char *filename) throw(FileIOException, ParseException);
  void writeFile(const char *filename) throw(FileIOException);

  inline Setting & lookup(const std::string &path) const
    throw(SettingNotFoundException)
  { return(lookup(path.c_str())); }

  Setting & lookup(const char *path) const throw(SettingNotFoundException);

  inline bool exists(const std::string & path) const throw()
  { return(exists(path.c_str())); }

  bool exists(const char *path) const throw();

  bool lookupValue(const char *path, bool &value) const throw();
  bool lookupValue(const char *path, int &value) const throw();
  bool lookupValue(const char *path, unsigned int &value) const throw();
  bool lookupValue(const char *path, long long &value) const throw();
  bool lookupValue(const char *path, unsigned long long &value)
    const throw();
  bool lookupValue(const char *path, double &value) const throw();
  bool lookupValue(const char *path, float &value) const throw();
  bool lookupValue(const char *path, const char *&value) const throw();
  bool lookupValue(const char *path, std::string &value) const throw();

  inline bool lookupValue(const std::string &path, bool &value) const throw()
  { return(lookupValue(path.c_str(), value)); }

  inline bool lookupValue(const std::string &path, int &value) const throw()
  { return(lookupValue(path.c_str(), value)); }

  inline bool lookupValue(const std::string &path, unsigned int &value)
    const throw()
  { return(lookupValue(path.c_str(), value)); }

  inline bool lookupValue(const std::string &path, long long &value)
    const throw()
  { return(lookupValue(path.c_str(), value)); }

  inline bool lookupValue(const std::string &path,
                          unsigned long long &value) const throw()
  { return(lookupValue(path.c_str(), value)); }

  inline bool lookupValue(const std::string &path, double &value)
    const throw()
  { return(lookupValue(path.c_str(), value)); }

  inline bool lookupValue(const std::string &path, float &value)
    const throw()
  { return(lookupValue(path.c_str(), value)); }

  inline bool lookupValue(const std::string &path, const char *&value)
    const throw()
  { return(lookupValue(path.c_str(), value)); }

  inline bool lookupValue(const std::string &path, std::string &value)
    const throw()
  { return(lookupValue(path.c_str(), value)); }

  Setting & getRoot() const;

  private:

  Setting::Format _defaultFormat;

  void handleError() const;
};

} // namespace libconfig

#endif // __libconfig_hpp