31static const tchar szNO[] =
_T(
"no");
32static const tchar szOFF[] =
_T(
"off");
33static const tchar szZERO[] =
_T(
"0");
34static const tchar szFALSE[] =
_T(
"false");
35static const tchar szYES[] =
_T(
"yes");
36static const tchar szON[] =
_T(
"on");
37static const tchar szONE[] =
_T(
"1");
38static const tchar szTRUE[] =
_T(
"true");
40static const tchar szSep[] =
_T(
"\\");
50 while (*
sz ==
_T(
' ') || *
sz ==
_T(
'\t'))
125 while(*
ep && (*
ep ==
_T(
'\t') || *
ep ==
_T(
' ')))
128 while(*p && *p !=
_T(
'\n')){
139 while(*p !=
_T(
'\0'))
322 const auto p =
const_cast<LPTSTR>(result.data());
325 result.shrink_to_fit();
421 if(
text.length() > 0)
451 _stscanf(
text,
_T(
"%hu,%hu,%hu,%hu,%hu,%hu,%hu,%hu"),&
dt.wYear,&
dt.wMonth,&
dt.wDayOfWeek,
452 &
dt.wDay,&
dt.wHour,&
dt.wMinute,&
dt.wSecond,&
dt.wMilliseconds);
465 wsprintf(
text,
_T(
"%hu,%hu,%hu,%hu,%hu,%hu,%hu,%hu"),
dt.wYear,
dt.wMonth,
dt.wDayOfWeek,
466 dt.wDay,
dt.wHour,
dt.wMinute,
dt.wSecond,
dt.wMilliseconds);
580 lf.lfOrientation =
i;
769 if (
R >= 0 &&
R < 256 &&
811 for (
i = 0;
i < 2;
i++){
859 for(
i = 0;
i < 4;
i++){
888 wsprintf (buf,
_T(
"L=%d,T=%d,W=%d,H=%d"),
r.left,
r.top,
r.Width(),
r.Height());
900 wsprintf(buf,
_T(
"W=%d,H=%d"), size.cx, size.cy);
933 return ::WritePrivateProfileString(
section, 0, 0,
FileName.c_str()) != 0;
994class TStringMapNode:
public TMapNode<tstring,tstring> {
999 TStringMapNode(
const tstring& str)
1005class TStringNode:
public TMapNode<tstring,TStringMap> {
1007 TStringNode(
const tstring& str)
1011class TMemConfigFileSections:
public TIPtrArray<TStringNode*> {
1013 TMemConfigFileSections(){}
1014 ~TMemConfigFileSections(){}
1016 bool DestroyItem(TStringNode* item);
1017 bool Destroy(
int loc);
1018 int Add(TStringNode* item);
1019 bool HasMember(TStringNode* item)
const;
1020 int Find(TStringNode* item)
const;
1023bool TMemConfigFileSections::HasMember(TStringNode* item)
const
1025 return Find(item) !=
NPOS;
1028bool TMemConfigFileSections::DestroyItem(TStringNode* item)
1030 const auto index = Find(item);
1033 TStringNode* item =
Data[index];
1041bool TMemConfigFileSections::Destroy(
int loc)
1044 TStringNode* item =
Data[
loc];
1052int TMemConfigFileSections::Add(TStringNode* item)
1065int TMemConfigFileSections::Find(TStringNode* item)
const
1068 auto upper =
static_cast<int>(
Size()) - 1;
1089 Sections =
new TMemConfigFileSections();
1111 return Sections->Add(
new TStringNode(
section));
1118 const auto index = Sections->Find(&
sn);
1119 if (index != Sections->
NPOS)
1121 return (*Sections)[index]->Value.DestroyItem(TStringMapNode(
entry));
1130 return Sections->DestroyItem(&
sn);
1145 const auto k = Sections->Find(&
sn);
1146 if (
k == Sections->
NPOS)
return 0;
1148 if (map.Empty())
return 0;
1149 for (
uint i = 0;
i != map.Size(); ++
i)
1154 size_t n = min(s.size(),
m - 1);
1177 if (Sections->
Empty())
return 0;
1180 const tstring& s = (*Sections)[
i]->Name;
1183 size_t n = min(s.size(),
m - 1);
1213 const auto i = f.Sections->Find(&
sn);
1214 if (
i == f.Sections->
NPOS)
return def;
1216 const auto j = map.Find(TStringMapNode{
entry});
1217 if (
j == map.NPOS)
return def;
1218 return map[
j].Value.c_str();
1225 return static_cast<uint>(
n);
1233 auto index = Sections->Find(&
sn);
1234 if (index == Sections->
NPOS)
1237 index = map.Find(TStringMapNode(
entry));
1238 if (index != map.NPOS)
1241 index = map.Add(TStringMapNode(
entry,
value));
1242 return index != map.NPOS;
1258 file << map[
value].Name.c_str() <<
_T(
"=") << map[
value].Value.c_str() <<
_T(
"\r\n");
1284 while(*p && (*p==
_T(
' ') || *p ==
_T(
'\t')) && *p !=
_T(
'='))
1488 const auto s =
k ?
k->GetValueOrDefault(
entry,
d) :
d;
1489 const auto n = min(
static_cast<uint>(s.size()),
bufSize - 1);
1510 if (!
k)
return false;
#define PRECONDITION(condition)
Class wrapper for management of color values.
Save/Load configuration parameters Base abstract class.
virtual bool WriteData(LPCTSTR section, LPCTSTR entry, void *buffer, uint size)
This method writes binary data.
static int DefaultPrecision
bool ReadTime(LPCTSTR section, LPCTSTR entry, TTime &val) const
bool ReadColor(LPCTSTR section, LPCTSTR entry, TColor &color) const
This method reads an RGB color.
double ReadDouble(LPCTSTR section, LPCTSTR entry, double defval=0.0) const
virtual bool WriteInteger(LPCTSTR section, LPCTSTR entry, int value)
This method writes an integer. We format it as a string.
bool WriteRect(LPCTSTR section, LPCTSTR entry, const TRect &rc)
This method writes a rectangle.
bool ReadDate(LPCTSTR section, LPCTSTR entry, TDate &value) const
virtual bool SectionExists(LPCTSTR section) const
bool WriteFont(LPCTSTR section, LPCTSTR entry, const LOGFONT &font)
This method writes a font description in the following format:
bool WriteColor(LPCTSTR section, LPCTSTR entry, const TColor &clr)
This method writes an RGB color.
bool ReadPoint(LPCTSTR section, LPCTSTR entry, TPoint &val) const
bool WriteDouble(LPCTSTR section, LPCTSTR entry, double value)
This method writes an integer.
virtual void LoadValues(const TConfigFile &file)
virtual uint ReadSections(TCHAR *sections, uint bufSize) const =0
bool WriteTime(LPCTSTR section, LPCTSTR entry, TTime &val)
bool WriteDate(LPCTSTR section, LPCTSTR entry, const TDate &val)
bool WriteSystemTime(LPCTSTR section, LPCTSTR entry, const TSystemTime &val)
bool ReadBool(LPCTSTR section, LPCTSTR entry, bool defval=false) const
This method reads a boolean value.
bool ReadRect(LPCTSTR section, LPCTSTR entry, TRect &val) const
This method reads a rectangle.
bool WritePoint(LPCTSTR section, LPCTSTR entry, const TPoint &point)
This method writes a TPoint.
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.
static tstring BoolToString(bool val)
This static method returns yes or no given a boolean value.
bool WriteSize(LPCTSTR section, LPCTSTR entry, const TSize &size)
This method writes a TSize.
bool ReadFont(LPCTSTR section, LPCTSTR entry, LOGFONT &font) const
This method will take a profile string of the form:
virtual bool ReadData(LPCTSTR section, LPCTSTR entry, void *buffer, uint size) const
This method reads binary data.
bool WriteBool(LPCTSTR section, LPCTSTR entry, bool val)
This method writes a bool.
bool ReadSystemTime(LPCTSTR section, LPCTSTR entry, TSystemTime &val) const
static bool StringToBool(LPCTSTR str, bool *val)
This static method converts a string to a bool, accepting most common boolean keywords: yes,...
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
The TDate class represents a date.
static HowToPrint SetPrintOption(HowToPrint h)
Sets the print option for all TDate objects and returns the old setting.
HowToPrint
Lists different print formats.
@ CreateAlways
Creates a new file. The function overwrites the file if it exists.
The TFileLineIterator class is used to iterate through a TTextFile file.
void Flush(bool del=true)
virtual bool ReadData(LPCTSTR section, LPCTSTR entry, void *buffer, uint size) const
This method reads binary data.
virtual uint ReadSections(TCHAR *buffer, uint bufSize) const
virtual uint ReadSection(LPCTSTR section, TCHAR *buffer, uint bufSize) const
virtual bool WriteString(LPCTSTR section, LPCTSTR entry, LPCTSTR value)
This method is the low-level method for writing strings.
virtual void UpdateFile()
virtual bool EraseEntry(LPCTSTR section, LPCTSTR entry)
This method deletes the specified entry.
virtual uint ReadString(LPCTSTR section, LPCTSTR entry, TCHAR *buffer, uint bufSize, LPCTSTR defstr=0) const
This method is the base method for reading strings.
virtual bool WriteData(LPCTSTR section, LPCTSTR entry, void *buffer, uint size)
This method writes binary data.
virtual bool EraseSection(LPCTSTR section)
This method deletes the specified section.
Usage: typedef TMapNode<string,string> TStringMapNode; typedef TSortedObjectArray< TStringMapNode > T...
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 ~TMemConfigFile()
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.
TRect is a mathematical class derived from tagRect.
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.
virtual ~TRegConfigFile()
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.
auto HasSubkey(const tstring &keyName) const -> bool
Returns true if this key has a subkey with the given name.
auto GetSubkey(const tstring &keyName, REGSAM samDesired=KEY_READ) const -> std::optional< TRegKey >
Returns the subkey with the given name, if it exists.
Iterator for walking thru the subkeys of a key.
Encapsulates a value-data entry within one registration key.
Iterator for walking through the values of a key.
The tagSIZE struct is defined as.
TSystemTime is a class derived from the structure SYSTEMTIME.
The TTextFile class is derived from TBufferedFile and encapsulates standard file characteristics and ...
The TTime class encapsulates time functions and characteristics.
Definition of windowing system color classes.
This header file declares the class: TConfigFile,TIniConfigFile, TRegConfigFile and TConfigFileSectio...
Object Windows Library (OWLNext Core)
std::ostringstream tostringstream
bool is_integer(TCHAR *text)
std::istringstream tistringstream
bool is_digit(tchar c)
where string is integer????
TSortedObjectArray< TStringMapNode > TStringMap
#define COUNTOF(s)
Array element count Important: Only use this with an argument of array type.
Various types of smart pointer templatized classes.
Definition of container classes used and made available by OWL.
Classes for window system structure and type encapsulation.