OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
configfl.h
Go to the documentation of this file.
1//------------------------------------------------------------------------------
2// ObjectWindows
3// Copyright (c) 1998 by Yura Bidus
4//
5/// \file
6/// This header file declares the class: TConfigFile,TIniConfigFile,
7/// TRegConfigFile and TConfigFileSection.
8//
9// Log History:
10// 03/27/99 - Added Read/WriteData sugested by Jogy
11// 06/17/2002 - Added variations of functions with tstring as parameter
12//------------------------------------------------------------------------------
13
14#if !defined(OWL_CONFIGFL_H)
15#define OWL_CONFIGFL_H
16
17#include <owl/private/defs.h>
18#if defined(BI_HAS_PRAGMA_ONCE)
19# pragma once
20#endif
21
22#include <owl/defs.h>
23#include <owl/registry.h>
24
25namespace owl {
26
27class _OWLCLASS TDate;
28class _OWLCLASS TTime;
30class _OWLCLASS TPoint;
31class _OWLCLASS TRect;
32class _OWLCLASS TSize;
33class _OWLCLASS TFont;
34class _OWLCLASS TColor;
35
36
37#include <owl/preclass.h>
38
39/// \addtogroup winsys
40/// @{
41
42
43/// \class TConfigFile
44// ~~~~~ ~~~~~~~~~~~
45/// Save/Load configuration parameters
46/// Base abstract class
47//
49 public:
50
51 //
52 /// Constructs instance and sets FileName to name.
53 //
54 TConfigFile(const tstring& name) : FileName(name) {}
55
56/// Destroys the instance.
57 virtual ~TConfigFile(){}
58
59 // -1 = pring default(%1.20Lg), == 0 not use precision(%Lg), else use specified
60 static void SetPrecision(int newprec = -1){ DefaultPrecision = newprec; }
61 static int GetPrecision(){ return DefaultPrecision; }
62
63 const tstring& GetFileName() const {return FileName;}
64 virtual void LoadValues(const TConfigFile& file);
65
66 virtual bool SectionExists(LPCTSTR section) const;
67 virtual uint ReadSection(LPCTSTR section, LPTSTR buffer, uint bufSize) const = 0;
68 virtual uint ReadSections(LPTSTR sections, uint bufSize) const = 0;
69 virtual bool EraseSection(LPCTSTR section) = 0;
70 virtual bool EraseEntry(LPCTSTR section, LPCTSTR entry) = 0;
71 virtual void UpdateFile() = 0;
72
73 virtual uint ReadString(LPCTSTR section, LPCTSTR entry, LPTSTR buffer, uint bufSize, LPCTSTR defstr= 0) const = 0;
74 virtual bool WriteString(LPCTSTR section, LPCTSTR entry, LPCTSTR value) = 0;
75
76 virtual bool ReadData(LPCTSTR section, LPCTSTR entry, void* buffer, uint size) const;
77 virtual bool WriteData(LPCTSTR section, LPCTSTR entry, void* buffer, uint size);
78
79 virtual int ReadInteger(LPCTSTR section, LPCTSTR entry,int defint=0) const;
80 virtual bool WriteInteger(LPCTSTR section, LPCTSTR entry, int value);
81
82 bool SectionExists(const tstring& section) const;
83 int ReadSection(const tstring& section, tstring& buffer) const;
84 int ReadSections(tstring& sections) const;
85 bool EraseSection(const tstring& section);
86 bool EraseEntry(const tstring& section, const tstring& entry);
87
88 uint ReadString(const tstring& section, const tstring& entry, tstring& buffer, LPCTSTR defstr=0) const;
89 uint ReadString(const tstring& section, const tstring& entry, tstring& buffer, const tstring& defstr) const
90 {return ReadString(section, entry, buffer, defstr.c_str());}
91 bool WriteString(const tstring& section, const tstring& entry, const tstring& value);
92
93 bool ReadData(const tstring& section, const tstring& entry, void* buffer, uint size) const;
94 bool WriteData(const tstring& section, const tstring& entry, void* buffer, uint size);
95
96 int ReadInteger(const tstring& section, const tstring& entry,int defint=0) const;
97 bool WriteInteger(const tstring& section, const tstring& entry, int value);
98
99 double ReadDouble(LPCTSTR section, LPCTSTR entry, double defval=0.0) const;
100 bool WriteDouble(LPCTSTR section, LPCTSTR entry, double value);
101 double ReadDouble(const tstring& section, const tstring& entry, double defval=0.0) const;
102 bool WriteDouble(const tstring& section, const tstring& entry, double value);
103
104 bool ReadBool(LPCTSTR section, LPCTSTR entry, bool defval=false) const;
105 bool WriteBool(LPCTSTR section, LPCTSTR entry, bool val);
106 bool ReadBool(const tstring& section, const tstring& entry, bool defval=false) const;
107 bool WriteBool(const tstring& section, const tstring& entry, bool val);
108
109 bool ReadDate(LPCTSTR section, LPCTSTR entry, TDate& value) const;
110 bool WriteDate(LPCTSTR section, LPCTSTR entry, const TDate& val);
111 bool ReadDate(const tstring& section, const tstring& entry, TDate& value) const;
112 bool WriteDate(const tstring& section, const tstring& entry, const TDate& val);
113
114 bool ReadSystemTime(LPCTSTR section, LPCTSTR entry, TSystemTime& val) const;
115 bool WriteSystemTime(LPCTSTR section, LPCTSTR entry, const TSystemTime& val);
116 bool ReadSystemTime(const tstring& section, const tstring& entry, TSystemTime& val) const;
117 bool WriteSystemTime(const tstring& section, const tstring& entry, const TSystemTime& val);
118
119 bool ReadTime(LPCTSTR section, LPCTSTR entry, TTime& val) const;
120 bool WriteTime(LPCTSTR section, LPCTSTR entry, TTime& val);
121 bool ReadTime(const tstring& section, const tstring& entry, TTime& val) const;
122 bool WriteTime(const tstring& section, const tstring& entry, TTime& val);
123
124 bool ReadFont(LPCTSTR section, LPCTSTR entry, LOGFONT& font) const;
125 bool WriteFont(LPCTSTR section, LPCTSTR entry, const LOGFONT& font);
126 bool ReadFont(const tstring& section, const tstring& entry, LOGFONT& font) const;
127 bool WriteFont(const tstring& section, const tstring& entry, const LOGFONT& font);
128
129 bool ReadColor(LPCTSTR section, LPCTSTR entry, TColor& color) const;
130 bool WriteColor(LPCTSTR section, LPCTSTR entry, const TColor& clr);
131 bool ReadColor(const tstring& section, const tstring& entry, TColor& color) const;
132 bool WriteColor(const tstring& section, const tstring& entry, const TColor& clr);
133
134 bool ReadRect(LPCTSTR section, LPCTSTR entry, TRect& val) const;
135 bool WriteRect(LPCTSTR section, LPCTSTR entry, const TRect& rc);
136 bool ReadRect(const tstring& section, const tstring& entry, TRect& val) const;
137 bool WriteRect(const tstring& section, const tstring& entry, const TRect& rc);
138
139 bool ReadPoint(LPCTSTR section, LPCTSTR entry, TPoint& val)const;
140 bool WritePoint(LPCTSTR section, LPCTSTR entry, const TPoint& point);
141 bool ReadPoint(const tstring& section, const tstring& entry, TPoint& val)const;
142 bool WritePoint(const tstring& section, const tstring& entry, const TPoint& point);
143
144 bool ReadSize(LPCTSTR section, LPCTSTR entry, TSize& sz) const;
145 bool WriteSize(LPCTSTR section, LPCTSTR entry, const TSize& size);
146 bool ReadSize(const tstring& section, const tstring& entry, TSize& sz) const;
147 bool WriteSize(const tstring& section, const tstring& entry, const TSize& size);
148 protected:
149 static bool StringToBool(LPCTSTR str, bool* val);
150 static tstring BoolToString(bool val);
151
152 protected:
155};
156
157//
158/// \class TConfigFileSection
159// ~~~~~ ~~~~~~~~~~~~~~~~~~
160/// Small inline wrapper around Section.
161/// ConfigFile must exist all the time while the section exist!
162//
164 public:
165
167 : Section(section), File(file) {}
168
169 const tstring& GetSection() {return Section;}
170
171 bool Erase() { return File.EraseSection(Section.c_str()); }
172 bool EraseEntry(LPCTSTR entry);
173
174 uint ReadString(LPCTSTR entry, LPTSTR buffer, uint bufSize, LPCTSTR defstr=0) const;
175 bool WriteString(LPCTSTR entry, LPCTSTR value);
176 uint ReadString(const tstring& entry, tstring& buffer, LPCTSTR defstr=0) const;
177 uint ReadString(const tstring& entry, tstring& buffer, const tstring& defstr) const
178 {return ReadString(entry, buffer, defstr.c_str());}
179 bool WriteString(const tstring& entry, const tstring& value);
180
181 bool ReadData(LPCTSTR entry, void* buffer, uint size) const;
182 bool WriteData(LPCTSTR entry, void* buffer, uint size);
183 bool ReadData(const tstring& entry, void* buffer, uint size) const;
184 bool WriteData(const tstring& entry, void* buffer, uint size);
185
186 int ReadInteger(LPCTSTR entry,int defint=0) const ;
187 bool WriteInteger(LPCTSTR entry, int value);
188 int ReadInteger(const tstring& entry,int defint=0) const ;
189 bool WriteInteger(const tstring& entry, int value);
190
191 double ReadDouble(LPCTSTR entry, double defval) const;
192 bool WriteDouble(LPCTSTR entry, double defval);
193 double ReadDouble(const tstring& entry, double defval) const;
194 bool WriteDouble(const tstring& entry, double defval);
195
196 bool ReadBool(LPCTSTR entry, bool defval) const;
197 bool WriteBool(LPCTSTR entry, bool val);
198 bool ReadBool(const tstring& entry, bool defval) const;
199 bool WriteBool(const tstring& entry, bool val);
200
201 bool ReadDate(LPCTSTR entry, TDate& value) const;
202 bool WriteDate(LPCTSTR entry, const TDate& val);
203 bool ReadDate(const tstring& entry, TDate& value) const;
204 bool WriteDate(const tstring& entry, const TDate& val);
205
206 bool ReadSystemTime(LPCTSTR entry, TSystemTime& val) const;
207 bool WriteSystemTime(LPCTSTR entry, const TSystemTime& val);
208 bool ReadSystemTime(const tstring& entry, TSystemTime& val) const;
209 bool WriteSystemTime(const tstring& entry, const TSystemTime& val);
210
211 bool ReadTime(LPCTSTR entry, TTime& val) const;
212 bool WriteTime(LPCTSTR entry, TTime& val);
213 bool ReadTime(const tstring& entry, TTime& val) const;
214 bool WriteTime(const tstring& entry, TTime& val);
215
216 bool ReadFont(LPCTSTR entry, LOGFONT& font) const;
217 bool WriteFont(LPCTSTR entry, const LOGFONT& font);
218 bool ReadFont(const tstring& entry, LOGFONT& font) const;
219 bool WriteFont(const tstring& entry, const LOGFONT& font);
220
221 bool ReadColor(LPCTSTR entry, TColor& color) const;
222 bool WriteColor(LPCTSTR entry, const TColor& clr);
223 bool ReadColor(const tstring& entry, TColor& color) const;
224 bool WriteColor(const tstring& entry, const TColor& clr);
225
226 bool ReadRect(LPCTSTR entry, TRect& val) const;
227 bool WriteRect(LPCTSTR entry, const TRect& rc);
228 bool ReadRect(const tstring& entry, TRect& val) const;
229 bool WriteRect(const tstring& entry, const TRect& rc);
230
231 bool ReadPoint(LPCTSTR entry, TPoint& val)const;
232 bool WritePoint(LPCTSTR entry, const TPoint& point);
233 bool ReadPoint(const tstring& entry, TPoint& val)const;
234 bool WritePoint(const tstring& entry, const TPoint& point);
235
236 bool ReadSize(LPCTSTR entry, TSize& sz) const;
237 bool WriteSize(LPCTSTR entry, const TSize& size);
238 bool ReadSize(const tstring& entry, TSize& sz) const;
239 bool WriteSize(const tstring& entry, const TSize& size);
240
241 protected:
244};
245
246/// \class TIniConfigFile
247/// Encapsulates the Windows INI file interface
248/// Get/SetPrivateProfileXXX functions
250 public:
251
253 : TConfigFile (name) {}
254
255 virtual ~TIniConfigFile(){}
256
257 virtual uint ReadSection(LPCTSTR section, LPTSTR buffer, uint bufSize) const;
258 virtual uint ReadSections(LPTSTR buffer, uint bufSize) const;
259 virtual bool EraseSection(LPCTSTR section);
260 virtual bool EraseEntry(LPCTSTR section, LPCTSTR entry);
261 virtual void UpdateFile();
262
263 virtual uint ReadString(LPCTSTR section, LPCTSTR entry, LPTSTR buffer, uint bufSize, LPCTSTR defstr=0) const;
264 virtual bool WriteString(LPCTSTR section, LPCTSTR entry, LPCTSTR value);
265 virtual bool ReadData(LPCTSTR section, LPCTSTR entry, void* buffer, uint size) const;
266 virtual bool WriteData(LPCTSTR section, LPCTSTR entry, void* buffer, uint size);
267
268 // Overloads from base
269
274
279};
280
281////////////////////////////////////////////////////////////////////////////
282//
283/// \class TMemConfigFile
284// ~~~~~ ~~~~~~~~~~~~~~
285/// Derived from TConfigFile, TMemConfigFile is used to maintain configuration
286/// settings in memory.
287//
288class TMemConfigFileSections;
290 private:
291 TMemConfigFileSections* Sections;
292
293 int AddSection(const tstring& section);
294
295 public:
296 TMemConfigFile(const tstring& name);
297 virtual ~TMemConfigFile();
298 virtual void LoadValues(const TConfigFile& file);
299
300 virtual uint ReadSection(LPCTSTR section, LPTSTR buffer, uint bufSize) const;
301 virtual uint ReadSections(LPTSTR buffer, uint bufSize) const;
302 virtual bool EraseSection(LPCTSTR section);
303 virtual bool EraseEntry(LPCTSTR section, LPCTSTR entry);
304 virtual void UpdateFile();
305
306 virtual uint ReadString(LPCTSTR section, LPCTSTR entry, LPTSTR buffer, uint bufSize, LPCTSTR defstr=0) const;
307 virtual bool WriteString(LPCTSTR section, LPCTSTR entry, LPCTSTR value);
308
309 // Overloads from base
310
315
318
319 void Flush();
320 void LoadFromFile();
321};
322
323//
324/// \class TRegConfigFile
325// ~~~~~ ~~~~~~~~~~~~~~
326/// Derived from TConfigFile, TRegConfigFile is used to maintain configuration
327/// settings in the registry.
328//
330 public:
331 TRegConfigFile(const tstring& name, HKEY hRoot = HKEY_CURRENT_USER);
332 virtual ~TRegConfigFile();
333
334 // Override these to change storage technique:
335 //
336 virtual bool SectionExists(LPCTSTR section) const;
337 virtual uint ReadSection(LPCTSTR section, LPTSTR buffer, uint bufSize) const;
338 virtual uint ReadSections(LPTSTR buffer, uint bufSize) const;
339 virtual bool EraseSection(LPCTSTR section);
340 virtual bool EraseEntry(LPCTSTR section, LPCTSTR entry);
341 virtual void UpdateFile();
342
343 virtual int ReadInteger(LPCTSTR section, LPCTSTR entry,int defint=0) const;
344 virtual bool WriteInteger(LPCTSTR section, LPCTSTR entry, int value);
345 virtual uint ReadString(LPCTSTR section, LPCTSTR entry, LPTSTR buffer, uint bufSize, LPCTSTR defstr=0) const;
346 virtual bool WriteString(LPCTSTR section, LPCTSTR entry, LPCTSTR value);
347 virtual bool ReadData(LPCTSTR section, LPCTSTR entry, void* buffer, uint size) const;
348 virtual bool WriteData(LPCTSTR section, LPCTSTR entry, void* buffer, uint size);
349
350 // Overloads from base
351
357
364
365 protected:
367};
368
369/// @}
370
371#include <owl/posclass.h>
372
373//
374// Inlines
375//
376inline bool
378{
379 return SectionExists(section.c_str());
380}
381//
382inline bool
384{
385 return EraseSection(section.c_str());
386}
387//
388inline bool
389TConfigFile::EraseEntry(const tstring& section, const tstring& entry)
390{
391 return EraseEntry(section.c_str(), entry.c_str());
392}
393
394//
395inline bool
396TConfigFile::ReadData(const tstring& section, const tstring& entry,
397 void* buffer, uint size) const
398{
399 return ReadData(section.c_str(), entry.c_str(),buffer,size);
400}
401//
402inline bool
403TConfigFile::WriteData(const tstring& section, const tstring& entry,
404 void* buffer, uint size)
405{
406 return WriteData(section.c_str(), entry.c_str(), buffer, size);
407}
408
409//
410inline int
411TConfigFile::ReadInteger(const tstring& section, const tstring& entry,
412 int defint) const
413{
414 return ReadInteger(section.c_str(), entry.c_str(), defint);
415}
416//
417inline bool
418TConfigFile::WriteInteger(const tstring& section, const tstring& entry,
419 int value)
420{
421 return WriteInteger(section.c_str(), entry.c_str(), value);
422}
423//
424inline double
425TConfigFile::ReadDouble(const tstring& section, const tstring& entry,
426 double defval) const
427{
428 return ReadDouble(section.c_str(), entry.c_str(), defval);
429}
430//
431inline bool
432TConfigFile::WriteDouble(const tstring& section, const tstring& entry,
433 double value)
434{
435 return WriteDouble(section.c_str(), entry.c_str(), value);
436}
437//
438inline bool
439TConfigFile::ReadBool(const tstring& section, const tstring& entry,
440 bool defval) const
441{
442 return ReadBool(section.c_str(), entry.c_str(), defval);
443}
444//
445inline bool
446TConfigFile::WriteBool(const tstring& section, const tstring& entry,
447 bool val)
448{
449 return WriteBool(section.c_str(), entry.c_str(), val);
450}
451//
452inline bool
453TConfigFile::ReadDate(const tstring& section, const tstring& entry,
454 TDate& value) const
455{
456 return ReadDate(section.c_str(), entry.c_str(), value);
457}
458//
459inline bool
460TConfigFile::WriteDate(const tstring& section, const tstring& entry,
461 const TDate& val)
462{
463 return WriteDate(section.c_str(), entry.c_str(), val);
464}
465//
466inline bool
468 const tstring& entry, TSystemTime& val) const
469{
470 return ReadSystemTime(section.c_str(), entry.c_str(), val);
471}
472//
473inline bool
475 const tstring& entry, const TSystemTime& val)
476{
477 return WriteSystemTime(section.c_str(), entry.c_str(), val);
478}
479//
480inline bool
481TConfigFile::ReadTime(const tstring& section, const tstring& entry, TTime& val) const
482{
483 return ReadTime(section.c_str(), entry.c_str(), val);
484}
485//
486inline bool
487TConfigFile::WriteTime(const tstring& section, const tstring& entry, TTime& val)
488{
489 return WriteTime(section.c_str(), entry.c_str(), val);
490}
491//
492inline bool
493TConfigFile::ReadFont(const tstring& section, const tstring& entry,
494 LOGFONT& font) const
495{
496 return ReadFont(section.c_str(), entry.c_str(), font);
497}
498//
499inline bool
500TConfigFile::WriteFont(const tstring& section, const tstring& entry,
501 const LOGFONT& font)
502{
503 return WriteFont(section.c_str(), entry.c_str(), font);
504}
505//
506inline bool
507TConfigFile::ReadColor(const tstring& section, const tstring& entry,
508 TColor& color) const
509{
510 return ReadColor(section.c_str(), entry.c_str(), color);
511}
512//
513inline bool
514TConfigFile::WriteColor(const tstring& section, const tstring& entry,
515 const TColor& color)
516{
517 return WriteColor(section.c_str(), entry.c_str(), color);
518}
519//
520inline bool
521TConfigFile::ReadRect(const tstring& section, const tstring& entry,
522 TRect& val) const
523{
524 return ReadRect(section.c_str(), entry.c_str(), val);
525}
526//
527inline bool
528TConfigFile::WriteRect(const tstring& section, const tstring& entry,
529 const TRect& rc)
530{
531 return WriteRect(section.c_str(), entry.c_str(), rc);
532}
533//
534inline bool
535TConfigFile::ReadPoint(const tstring& section, const tstring& entry,
536 TPoint& val) const
537{
538 return ReadPoint(section.c_str(), entry.c_str(), val);
539}
540//
541inline bool
542TConfigFile::WritePoint(const tstring& section, const tstring& entry,
543 const TPoint& point)
544{
545 return WritePoint(section.c_str(), entry.c_str(), point);
546}
547//
548inline bool
549TConfigFile::ReadSize(const tstring& section, const tstring& entry,
550 TSize& sz) const
551{
552 return ReadSize(section.c_str(), entry.c_str(), sz);
553}
554//
555inline bool
556TConfigFile::WriteSize(const tstring& section, const tstring& entry,
557 const TSize& size)
558{
559 return WriteSize(section.c_str(), entry.c_str(), size);
560}
561//
562inline bool
563TConfigFile::WriteString(const tstring& section, const tstring& entry,
564 const tstring& value)
565{
566 return WriteString(section.c_str(), entry.c_str(), value.c_str());
567}
568
569//
570//
571//
572inline bool
574{
575 return File.EraseEntry(Section.c_str(), entry);
576}
577
578//
579//
580//
581inline uint
582TConfigFileSection::ReadString(LPCTSTR entry, LPTSTR buffer, uint bufSize,
583 LPCTSTR defstr) const
584{
585 return File.ReadString(Section.c_str(), entry, buffer, bufSize, defstr);
586}
587//
588//
589//
590inline bool
591TConfigFileSection::WriteString(LPCTSTR entry, LPCTSTR value)
592{
593 return File.WriteString(Section.c_str(), entry, value);
594}
595//
596//
597//
598inline uint
600 LPCTSTR defstr) const
601{
602 return File.ReadString(Section, entry, buffer, defstr);
603}
604//
605//
606//
607inline bool
609{
610 return File.WriteString(Section, entry, value);
611}
612//
613//
614//
615inline bool
616TConfigFileSection::ReadData(LPCTSTR entry, void* buffer, uint size) const
617{
618 return File.ReadData(Section.c_str(), entry, buffer, size);
619}
620//
621//
622//
623inline bool
624TConfigFileSection::WriteData(LPCTSTR entry, void* buffer, uint size)
625{
626 return File.WriteData(Section.c_str(), entry, buffer, size);
627}
628//
629//
630//
631inline bool
632TConfigFileSection::ReadData(const tstring& entry, void* buffer, uint size) const
633{
634 return File.ReadData(Section, entry, buffer, size);
635}
636//
637//
638//
639inline bool
640TConfigFileSection::WriteData(const tstring& entry, void* buffer, uint size)
641{
642 return File.WriteData(Section, entry, buffer, size);
643}
644//
645//
646//
647inline int
648TConfigFileSection::ReadInteger(LPCTSTR entry,int defint) const
649{
650 return File.ReadInteger(Section.c_str(), entry, defint);
651}
652//
653//
654//
655inline bool
656TConfigFileSection::WriteInteger(LPCTSTR entry, int value)
657{
658 return File.WriteInteger(Section.c_str(), entry, value);
659}
660//
661//
662//
663inline int
664TConfigFileSection::ReadInteger(const tstring& entry,int defint) const
665{
666 return File.ReadInteger(Section.c_str(), entry.c_str(), defint);
667}
668//
669//
670//
671inline bool
673{
674 return File.WriteInteger(Section.c_str(), entry.c_str(), value);
675}
676//
677//
678//
679inline double
680TConfigFileSection::ReadDouble(LPCTSTR entry, double defval) const
681{
682 return File.ReadDouble(Section.c_str(), entry, defval);
683}
684//
685//
686//
687inline bool
688TConfigFileSection::WriteDouble(LPCTSTR entry, double defval)
689{
690 return File.WriteDouble(Section.c_str(), entry, defval);
691}
692//
693//
694//
695inline double
696TConfigFileSection::ReadDouble(const tstring& entry, double defval) const
697{
698 return File.ReadDouble(Section.c_str(), entry.c_str(), defval);
699}
700//
701//
702//
703inline bool
704TConfigFileSection::WriteDouble(const tstring& entry, double defval)
705{
706 return File.WriteDouble(Section.c_str(), entry.c_str(), defval);
707}
708//
709//
710//
711inline bool
712TConfigFileSection::ReadBool(LPCTSTR entry, bool defval) const
713{
714 return File.ReadBool(Section.c_str(), entry, defval);
715}
716//
717//
718//
719inline bool
720TConfigFileSection::WriteBool(LPCTSTR entry, bool val)
721{
722 return File.WriteBool(Section.c_str(), entry, val);
723}
724//
725//
726//
727inline bool
728TConfigFileSection::ReadBool(const tstring& entry, bool defval) const
729{
730 return File.ReadBool(Section, entry, defval);
731}
732//
733//
734//
735inline bool
737{
738 return File.WriteBool(Section, entry, val);
739}
740//
741//
742//
743inline bool
744TConfigFileSection::ReadDate(LPCTSTR entry, TDate& value) const
745{
746 return File.ReadDate(Section.c_str(), entry, value);
747}
748//
749//
750//
751inline bool
752TConfigFileSection::WriteDate(LPCTSTR entry, const TDate& val)
753{
754 return File.WriteDate(Section.c_str(), entry, val);
755}
756//
757//
758//
759inline bool
760TConfigFileSection::ReadDate(const tstring& entry, TDate& value) const
761{
762 return File.ReadDate(Section, entry, value);
763}
764//
765//
766//
767inline bool
769{
770 return File.WriteDate(Section, entry, val);
771}
772//
773//
774//
775inline bool
777{
778 return File.ReadSystemTime(Section.c_str(), entry, val);
779}
780//
781//
782//
783inline bool
785{
786 return File.WriteSystemTime(Section.c_str(), entry, val);
787}
788//
789//
790//
791inline bool
793{
794 return File.ReadSystemTime(Section, entry, val);
795}
796//
797//
798//
799inline bool
801{
802 return File.WriteSystemTime(Section, entry, val);
803}
804//
805//
806//
807inline bool
808TConfigFileSection::ReadTime(LPCTSTR entry, TTime& val) const
809{
810 return File.ReadTime(Section.c_str(), entry, val);
811}
812//
813//
814//
815inline bool
817{
818 return File.WriteTime(Section.c_str(), entry, val);
819}
820//
821//
822//
823inline bool
825{
826 return File.ReadTime(Section, entry, val);
827}
828//
829//
830//
831inline bool
833{
834 return File.WriteTime(Section, entry, val);
835}
836//
837//
838//
839inline bool
840TConfigFileSection::ReadFont(LPCTSTR entry, LOGFONT& font) const
841{
842 return File.ReadFont(Section.c_str(), entry, font);
843}
844//
845//
846//
847inline bool
848TConfigFileSection::WriteFont(LPCTSTR entry, const LOGFONT& font)
849{
850 return File.WriteFont(Section.c_str(), entry, font);
851}
852//
853//
854//
855inline bool
856TConfigFileSection::ReadFont(const tstring& entry, LOGFONT& font) const
857{
858 return File.ReadFont(Section, entry, font);
859}
860//
861//
862//
863inline bool
864TConfigFileSection::WriteFont(const tstring& entry, const LOGFONT& font)
865{
866 return File.WriteFont(Section, entry, font);
867}
868//
869//
870//
871inline bool
872TConfigFileSection::ReadColor(LPCTSTR entry, TColor& color) const
873{
874 return File.ReadColor(Section.c_str(), entry, color);
875}
876//
877//
878//
879inline bool
880TConfigFileSection::WriteColor(LPCTSTR entry, const TColor& color)
881{
882 return File.WriteColor(Section.c_str(), entry, color);
883}
884//
885//
886//
887inline bool
889{
890 return File.ReadColor(Section, entry, color);
891}
892//
893//
894//
895inline bool
897{
898 return File.WriteColor(Section, entry, color);
899}
900//
901//
902//
903inline bool
904TConfigFileSection::ReadRect(LPCTSTR entry, TRect& rect) const
905{
906 return File.ReadRect(Section.c_str(), entry, rect);
907}
908//
909//
910//
911inline bool
912TConfigFileSection::WriteRect(LPCTSTR entry, const TRect& rect)
913{
914 return File.WriteRect(Section.c_str(), entry, rect);
915}
916//
917//
918//
919inline bool
921{
922 return File.ReadRect(Section, entry, rect);
923}
924//
925//
926//
927inline bool
929{
930 return File.WriteRect(Section, entry, rect);
931}
932//
933//
934//
935inline bool
936TConfigFileSection::ReadPoint(LPCTSTR entry, TPoint& point)const
937{
938 return File.ReadPoint(Section.c_str(), entry, point);
939}
940//
941//
942//
943inline bool
944TConfigFileSection::WritePoint(LPCTSTR entry, const TPoint& point)
945{
946 return File.WritePoint(Section.c_str(), entry, point);
947}
948//
949//
950//
951inline bool
953{
954 return File.ReadPoint(Section, entry, point);
955}
956//
957//
958//
959inline bool
961{
962 return File.WritePoint(Section, entry, point);
963}
964//
965//
966//
967inline bool
968TConfigFileSection::ReadSize(LPCTSTR entry, TSize& size) const
969{
970 return File.ReadSize(Section.c_str(), entry, size);
971}
972//
973//
974//
975inline bool
976TConfigFileSection::WriteSize(LPCTSTR entry, const TSize& size)
977{
978 return File.WriteSize(Section.c_str(), entry, size);
979}
980//
981//
982//
983inline bool
985{
986 return File.ReadSize(Section, entry, size);
987}
988//
989//
990//
991inline bool
993{
994 return File.WriteSize(Section, entry, size);
995}
996//
997//
998//
999
1000//
1001//
1002//
1003} // OWL namespace
1004
1005
1006#endif // OWL_CONFIGFL_H
1007
Class wrapper for management of color values.
Definition color.h:245
Save/Load configuration parameters Base abstract class.
Definition configfl.h:48
TConfigFile(const tstring &name)
Constructs instance and sets FileName to name.
Definition configfl.h:54
virtual bool WriteData(LPCTSTR section, LPCTSTR entry, void *buffer, uint size)
This method writes binary data.
Definition configfl.cpp:219
static int DefaultPrecision
Definition configfl.h:154
bool ReadTime(LPCTSTR section, LPCTSTR entry, TTime &val) const
Definition configfl.cpp:472
virtual bool EraseSection(LPCTSTR section)=0
bool ReadColor(LPCTSTR section, LPCTSTR entry, TColor &color) const
This method reads an RGB color.
Definition configfl.cpp:742
double ReadDouble(LPCTSTR section, LPCTSTR entry, double defval=0.0) const
Definition configfl.cpp:333
virtual bool WriteInteger(LPCTSTR section, LPCTSTR entry, int value)
This method writes an integer. We format it as a string.
Definition configfl.cpp:257
bool WriteRect(LPCTSTR section, LPCTSTR entry, const TRect &rc)
This method writes a TRect.
Definition configfl.cpp:836
static int GetPrecision()
Definition configfl.h:61
bool ReadDate(LPCTSTR section, LPCTSTR entry, TDate &value) const
Definition configfl.cpp:416
virtual bool SectionExists(LPCTSTR section) const
Definition configfl.cpp:872
bool WriteFont(LPCTSTR section, LPCTSTR entry, const LOGFONT &font)
This method writes a font description in the following format:
Definition configfl.cpp:651
virtual ~TConfigFile()
Destroys the instance.
Definition configfl.h:57
bool WriteColor(LPCTSTR section, LPCTSTR entry, const TColor &clr)
This method writes an RGB color.
Definition configfl.cpp:784
bool ReadPoint(LPCTSTR section, LPCTSTR entry, TPoint &val) const
This method reads a TPoint.
Definition configfl.cpp:796
bool WriteDouble(LPCTSTR section, LPCTSTR entry, double value)
This method writes an integer.
Definition configfl.cpp:354
const tstring & GetFileName() const
Definition configfl.h:63
virtual uint ReadSections(TCHAR *sections, uint bufSize) const =0
virtual bool EraseEntry(LPCTSTR section, LPCTSTR entry)=0
bool WriteTime(LPCTSTR section, LPCTSTR entry, TTime &val)
Definition configfl.cpp:488
bool WriteDate(LPCTSTR section, LPCTSTR entry, const TDate &val)
Definition configfl.cpp:432
bool WriteSystemTime(LPCTSTR section, LPCTSTR entry, const TSystemTime &val)
Definition configfl.cpp:461
static void SetPrecision(int newprec=-1)
Definition configfl.h:60
bool ReadSize(LPCTSTR section, LPCTSTR entry, TSize &sz) const
This method reads a TSize.
Definition configfl.cpp:848
virtual void UpdateFile()=0
bool ReadBool(LPCTSTR section, LPCTSTR entry, bool defval=false) const
This method reads a boolean value.
Definition configfl.cpp:388
bool ReadRect(LPCTSTR section, LPCTSTR entry, TRect &val) const
This method reads a TRect.
Definition configfl.cpp:822
tstring FileName
Definition configfl.h:153
bool WritePoint(LPCTSTR section, LPCTSTR entry, const TPoint &point)
This method writes a TPoint.
Definition configfl.cpp:810
virtual uint ReadSection(LPCTSTR section, TCHAR *buffer, uint bufSize) const =0
virtual int ReadInteger(LPCTSTR section, LPCTSTR entry, int defint=0) const
This method reads an integer.
Definition configfl.cpp:236
static tstring BoolToString(bool val)
This static method returns yes or no given a boolean value.
Definition configfl.cpp:102
bool WriteSize(LPCTSTR section, LPCTSTR entry, const TSize &size)
This method writes a TSize.
Definition configfl.cpp:862
bool ReadFont(LPCTSTR section, LPCTSTR entry, LOGFONT &font) const
This method will take a profile string of the form:
Definition configfl.cpp:521
virtual bool ReadData(LPCTSTR section, LPCTSTR entry, void *buffer, uint size) const
This method reads binary data.
Definition configfl.cpp:193
bool WriteBool(LPCTSTR section, LPCTSTR entry, bool val)
This method writes a bool.
Definition configfl.cpp:408
uint ReadString(const tstring &section, const tstring &entry, tstring &buffer, const tstring &defstr) const
Definition configfl.h:89
bool ReadSystemTime(LPCTSTR section, LPCTSTR entry, TSystemTime &val) const
Definition configfl.cpp:444
static bool StringToBool(LPCTSTR str, bool *val)
This static method converts a string to a bool, accepting most common boolean keywords: yes,...
Definition configfl.cpp:77
virtual bool WriteString(LPCTSTR section, LPCTSTR entry, LPCTSTR value)=0
virtual uint ReadString(LPCTSTR section, LPCTSTR entry, TCHAR *buffer, uint bufSize, LPCTSTR defstr=0) const =0
bool WriteRect(LPCTSTR entry, const TRect &rc)
Definition configfl.h:912
bool WriteSize(LPCTSTR entry, const TSize &size)
Definition configfl.h:976
bool ReadData(LPCTSTR entry, void *buffer, uint size) const
Definition configfl.h:616
int ReadInteger(LPCTSTR entry, int defint=0) const
Definition configfl.h:648
TConfigFileSection(TConfigFile &file, const tstring &section)
Definition configfl.h:166
bool ReadFont(LPCTSTR entry, LOGFONT &font) const
Definition configfl.h:840
double ReadDouble(LPCTSTR entry, double defval) const
Definition configfl.h:680
bool WriteString(LPCTSTR entry, LPCTSTR value)
Definition configfl.h:591
bool ReadTime(LPCTSTR entry, TTime &val) const
Definition configfl.h:808
bool ReadDate(LPCTSTR entry, TDate &value) const
Definition configfl.h:744
bool WriteTime(LPCTSTR entry, TTime &val)
Definition configfl.h:816
bool ReadRect(LPCTSTR entry, TRect &val) const
Definition configfl.h:904
TConfigFile & File
Definition configfl.h:243
bool WriteInteger(LPCTSTR entry, int value)
Definition configfl.h:656
uint ReadString(LPCTSTR entry, TCHAR *buffer, uint bufSize, LPCTSTR defstr=0) const
Definition configfl.h:582
bool WriteData(LPCTSTR entry, void *buffer, uint size)
Definition configfl.h:624
bool WriteBool(LPCTSTR entry, bool val)
Definition configfl.h:720
bool EraseEntry(LPCTSTR entry)
Definition configfl.h:573
const tstring & GetSection()
Definition configfl.h:169
bool WriteFont(LPCTSTR entry, const LOGFONT &font)
Definition configfl.h:848
uint ReadString(const tstring &entry, tstring &buffer, const tstring &defstr) const
Definition configfl.h:177
bool WritePoint(LPCTSTR entry, const TPoint &point)
Definition configfl.h:944
bool ReadColor(LPCTSTR entry, TColor &color) const
Definition configfl.h:872
bool ReadPoint(LPCTSTR entry, TPoint &val) const
Definition configfl.h:936
bool WriteSystemTime(LPCTSTR entry, const TSystemTime &val)
Definition configfl.h:784
bool WriteDate(LPCTSTR entry, const TDate &val)
Definition configfl.h:752
bool WriteDouble(LPCTSTR entry, double defval)
Definition configfl.h:688
bool WriteColor(LPCTSTR entry, const TColor &clr)
Definition configfl.h:880
bool ReadSystemTime(LPCTSTR entry, TSystemTime &val) const
Definition configfl.h:776
bool ReadSize(LPCTSTR entry, TSize &sz) const
Definition configfl.h:968
bool ReadBool(LPCTSTR entry, bool defval) const
Definition configfl.h:712
The TDate class represents a date.
Definition date.h:48
TFont derived from TGdiObject provides constructors for creating font objects from explicit informati...
Definition gdiobjec.h:296
virtual bool ReadData(LPCTSTR section, LPCTSTR entry, void *buffer, uint size) const
This method reads binary data.
Definition configfl.cpp:944
virtual bool WriteString(LPCTSTR section, LPCTSTR entry, LPCTSTR value)
This method is the low-level method for writing strings.
Definition configfl.cpp:936
virtual ~TIniConfigFile()
Definition configfl.h:255
virtual bool EraseEntry(LPCTSTR section, LPCTSTR entry)
This method deletes the specified entry.
Definition configfl.cpp:907
TIniConfigFile(const tstring &name)
Definition configfl.h:252
virtual uint ReadString(LPCTSTR section, LPCTSTR entry, TCHAR *buffer, uint bufSize, LPCTSTR defstr=0) const
This method is the base method for reading strings.
Definition configfl.cpp:927
virtual bool WriteData(LPCTSTR section, LPCTSTR entry, void *buffer, uint size)
This method writes binary data.
Definition configfl.cpp:952
virtual bool EraseSection(LPCTSTR section)
This method deletes the specified section.
Definition configfl.cpp:897
virtual uint ReadString(LPCTSTR section, LPCTSTR entry, TCHAR *buffer, uint bufSize, LPCTSTR defstr=0) const
Looks up the value of the given entry of the given section, and if found, copies it to the given buff...
virtual uint ReadSections(TCHAR *buffer, uint bufSize) const
Copies all section names to the specified buffer.
virtual uint ReadSection(LPCTSTR section, TCHAR *buffer, uint bufSize) const
Copies all value names of the given section to the specified buffer.
virtual bool EraseSection(LPCTSTR section)
TMemConfigFile(const tstring &name)
virtual void UpdateFile()
virtual bool WriteString(LPCTSTR section, LPCTSTR entry, LPCTSTR value)
virtual void LoadValues(const TConfigFile &file)
virtual bool EraseEntry(LPCTSTR section, LPCTSTR entry)
TPoint is a support class, derived from tagPOINT.
Definition geometry.h:87
TRect is a mathematical class derived from tagRect.
Definition geometry.h:308
virtual bool EraseSection(LPCTSTR section)
virtual bool EraseEntry(LPCTSTR section, LPCTSTR entry)
virtual uint ReadSections(TCHAR *buffer, uint bufSize) const
Copies all section names to the specified buffer.
TRegConfigFile(const tstring &name, HKEY hRoot=HKEY_CURRENT_USER)
This source file implements TRegConfigFile.
virtual void UpdateFile()
virtual bool WriteData(LPCTSTR section, LPCTSTR entry, void *buffer, uint size)
This method writes binary data.
virtual bool SectionExists(LPCTSTR section) const
virtual int ReadInteger(LPCTSTR section, LPCTSTR entry, int defint=0) const
virtual bool WriteString(LPCTSTR section, LPCTSTR entry, LPCTSTR value)
virtual uint ReadSection(LPCTSTR section, TCHAR *buffer, uint bufSize) const
Copies all value names of the given section to the specified buffer.
virtual bool WriteInteger(LPCTSTR section, LPCTSTR entry, int value)
virtual uint ReadString(LPCTSTR section, LPCTSTR entry, TCHAR *buffer, uint bufSize, LPCTSTR defstr=0) const
Looks up the value of the given entry of the given section, and if found, copies it to the given buff...
virtual bool ReadData(LPCTSTR section, LPCTSTR entry, void *buffer, uint size) const
This method reads binary data.
Encapsulates a registration key in the Windows Registry.
Definition registry.h:115
The tagSIZE struct is defined as.
Definition geometry.h:234
TSystemTime is a class derived from the structure SYSTEMTIME.
Definition wsyscls.h:420
The TTime class encapsulates time functions and characteristics.
Definition time.h:38
Object Windows Library (OWLNext Core).
Definition animctrl.h:22
std::string tstring
Definition defs.h:79
unsigned int uint
Definition number.h:25
General definitions used by all ObjectWindows programs.
#define _OWLCLASS
Definition defs.h:338
General Registry access & registration implementation TRegKey, TRegValue, TRegKeyIterator,...