OWLNext    7.0
Borland's Object Windows Library for the modern age
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
profile.h
Go to the documentation of this file.
1//----------------------------------------------------------------------------
2// Borland WinSys Library
3// Copyright (c) 1994, 1996 by Borland International, All Rights Reserved
4//
5/// \file
6/// Definition of TProfile class
7//----------------------------------------------------------------------------
8
9#if !defined(OWL_PROFILE_H)
10#define OWL_PROFILE_H
11
12#include <owl/private/defs.h>
13#if defined(BI_HAS_PRAGMA_ONCE)
14# pragma once
15#endif
16
17#include <owl/defs.h>
18
19
20namespace owl {
21//FMM had to include LPCTSTR on HPUX for some reason
22#ifndef LPCTSTR
23#include <windows.h>
24#endif
25
26/// \addtogroup winsys
27/// @{
28/// \class TProfile
29// ~~~~~ ~~~~~~~~
30/// An instance of TProfile encapsulates a setting within a system file, often
31/// referred to as a profile or initialization file. Examples of this type of file
32/// include the Windows initialization files SYSTEM.INI and WIN.INI. Within the
33/// system file itself, the individual settings are grouped within sections. For
34/// example,
35/// \code
36/// [Diagnostics] ; section name
37/// Enabled=0 ; setting
38/// \endcode
39/// For a setting, the value to the left of the equal sign is called the key. The
40/// value to the right of the equal sign, the value, can be either an integer or a
41/// string data type.
42//
44{
45 public:
46 // Use system global profile for filename==0
47 //
49 TProfile(const tstring& section, const tstring& filename = tstring());
50 ~TProfile();
51
52 int GetInt(LPCTSTR key, int defaultInt = 0);
53
54 int GetInt(const tstring& key, int defaultInt = 0)
55 {return GetInt(key.c_str(), defaultInt);}
56
57 // Returns all section values if key==0
58 //
59 bool GetString(LPCTSTR key, LPTSTR buff, unsigned buffSize, LPCTSTR defaultString = 0);
60
61 bool GetString(const tstring& key, LPTSTR buff, unsigned buffSize, const tstring& defaultString = tstring())
62 {return GetString(key.c_str(), buff, buffSize, defaultString.empty() ? nullptr : defaultString.c_str());}
63
64 tstring GetString(const tstring& key, const tstring& defaultString = tstring());
65
66 bool WriteInt(LPCTSTR key, int value);
67
68 bool WriteInt(const tstring& key, int value)
69 {return WriteInt(key.c_str(), value);}
70
71 bool WriteString(LPCTSTR key, LPCTSTR str);
72
73 bool WriteString(const tstring& key, LPCTSTR str)
74 {return WriteString(key.c_str(), str);}
75
76 bool WriteString(const tstring& key, const tstring& str)
77 {return WriteString(key.c_str(), str.c_str());}
78
79 void Flush();
80
81 protected:
82 LPTSTR Section; ///< Name of the section to use
83 LPTSTR FileName; ///< File name of the .INI file
84
85 void Init(LPCTSTR section, LPCTSTR filename);
86};
87/// @}
88
89} // OWL namespace
90
91
92#endif // OWL_PROFILE_H
An instance of TProfile encapsulates a setting within a system file, often referred to as a profile o...
Definition profile.h:44
bool WriteInt(const tstring &key, int value)
Definition profile.h:68
bool WriteString(const tstring &key, LPCTSTR str)
Definition profile.h:73
int GetInt(const tstring &key, int defaultInt=0)
Definition profile.h:54
bool GetString(const tstring &key, TCHAR *buff, unsigned buffSize, const tstring &defaultString=tstring())
Definition profile.h:61
TCHAR * Section
Name of the section to use.
Definition profile.h:82
TCHAR * FileName
File name of the .INI file.
Definition profile.h:83
bool WriteString(const tstring &key, const tstring &str)
Definition profile.h:76
Object Windows Library (OWLNext Core)
Definition animctrl.h:22
std::string tstring
Definition defs.h:79
General definitions used by all ObjectWindows programs.
#define _OWLCLASS
Definition defs.h:338