Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members

FXINI.h
1 /********************************************************************************
2 * *
3 * I N I R e a d e r & W r i t e r *
4 * *
5 *********************************************************************************
6 * Copyright (C) 2022,2024 by Jeroen van der Zijp. All Rights Reserved. *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU Lesser General Public License as published by *
10 * the Free Software Foundation; either version 3 of the License, or *
11 * (at your option) any later version. *
12 * *
13 * This library is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16 * GNU Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public License *
19 * along with this program. If not, see <http://www.gnu.org/licenses/> *
20 ********************************************************************************/
21 #ifndef FXINI_H
22 #define FXINI_H
23 
24 #ifndef FXPARSEBUFFER_H
25 #include "FXParseBuffer.h"
26 #endif
27 
28 namespace FX {
29 
30 
61 class FXAPI FXINI : public FXParseBuffer {
62 public:
63  enum Error {
64  ErrOK,
75  ErrEnd
76  };
77 protected:
78  FXlong offset; // Position from start
79  FXint token; // Current token
80  FXint column; // Current column
81  FXint indent; // Indentation level
82  FXint line; // Line number
83  FXuchar state; // Parse state
84  FXuchar prec; // Numeric precision
85  FXuchar fmt; // Numeric format
86  FXuchar esc; // Escape mode
87 private:
88  FXint next();
89  Error loadVariant(FXVariant& var);
90  Error saveVariant(const FXVariant& section);
91  Error saveSection(const FXString& str);
92  Error saveEntry(const FXVariant& var);
93  Error saveString(const FXString& str);
94 private:
95  static const FXchar *const errors[];
96 private:
97  FXINI(const FXINI&);
98  FXINI &operator=(const FXINI&);
99 public:
100 
104  FXINI();
105 
110  FXINI(FXchar* buffer,FXuval sz=8192,Direction d=Load);
111 
116  FXbool open(FXchar* buffer,FXuval sz=8192,Direction d=Load);
117 
121  FXint getLine() const { return line; }
122 
126  FXint getColumn() const { return column; }
127 
131  FXlong getOffset() const { return offset; }
132 
137  Error load(FXVariant& variant);
138 
143  Error save(const FXVariant& variant);
144 
148  static const FXchar* getError(Error err){ return errors[err]; }
149 
155  void setNumericPrecision(FXuchar p){ prec=p; }
156  FXuchar getNumericPrecision() const { return prec; }
157 
168  void setNumericFormat(FXuchar f){ fmt=f; }
169  FXuchar getNumericFormat() const { return fmt; }
170 
177  void setEscapeMode(FXuchar e){ esc=e; }
178  FXuchar getEscapeMode() const { return esc; }
179 
184  FXbool close();
185 
189  virtual ~FXINI();
190  };
191 
192 }
193 
194 #endif
Expected closing quote.
Definition: FXINI.h:74
Expected comma &#39;,&#39;.
Definition: FXINI.h:70
A Variant type can hold any kind of object, be it a boolean, integer, real, string, or even array of Variants or dictionaries of variants.
Definition: FXVariant.h:44
Expected closing brace.
Definition: FXINI.h:72
Expected closing quotes.
Definition: FXINI.h:73
Expected closing bracket.
Definition: FXINI.h:71
FXint getLine() const
Return current line number.
Definition: FXINI.h:121
void setEscapeMode(FXuchar e)
Change string escape mode; 0=don&#39;t escape unicode in strings; 1=escape unicode as ...
Definition: FXINI.h:177
Unable to save.
Definition: FXINI.h:66
FXint getColumn() const
Return current column number.
Definition: FXINI.h:126
static const FXchar * getError(Error err)
Returns error code for given error.
Definition: FXINI.h:148
Expected colon &#39;:&#39;.
Definition: FXINI.h:69
Unable to load.
Definition: FXINI.h:67
void setNumericPrecision(FXuchar p)
Floating point output precision control.
Definition: FXINI.h:155
Definition: FX4Splitter.h:28
The FXINI class loads or saves an FXVariant to an .INI text file.
Definition: FXINI.h:61
Illegal token.
Definition: FXINI.h:68
void setNumericFormat(FXuchar f)
Floating point output format control.
Definition: FXINI.h:168
Error
Definition: FXINI.h:63
FXParseBuffer manages pointers to a buffer for various file format parsers.
Definition: FXParseBuffer.h:34
FXlong getOffset() const
Return offset from begin of file.
Definition: FXINI.h:131
No errors.
Definition: FXINI.h:65
FXString provides essential string manipulation capabilities in FOX.
Definition: FXString.h:42

Copyright © 1997-2022 Jeroen van der Zijp