OWLNext
7.0
Borland's Object Windows Library for the modern age
Toggle main menu visibility
Loading...
Searching...
No Matches
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
20
namespace
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
//
43
class
_OWLCLASS
TProfile
44
{
45
public
:
46
// Use system global profile for filename==0
47
//
48
TProfile
(LPCTSTR section, LPCTSTR filename = 0);
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
owl::TProfile::WriteInt
bool WriteInt(LPCTSTR key, int value)
Looks up the key and replaces its value with the integer value passed (int).
Definition
profile.cpp:137
owl::TProfile::WriteInt
bool WriteInt(const tstring &key, int value)
Definition
profile.h:68
owl::TProfile::GetString
bool GetString(LPCTSTR key, TCHAR *buff, unsigned buffSize, LPCTSTR defaultString=0)
Looks up and returns the string value associated with the given key string.
Definition
profile.cpp:100
owl::TProfile::WriteString
bool WriteString(const tstring &key, LPCTSTR str)
Definition
profile.h:73
owl::TProfile::GetInt
int GetInt(LPCTSTR key, int defaultInt=0)
Looks up and returns the integer value associated with the given string, key.
Definition
profile.cpp:86
owl::TProfile::GetInt
int GetInt(const tstring &key, int defaultInt=0)
Definition
profile.h:54
owl::TProfile::GetString
bool GetString(const tstring &key, TCHAR *buff, unsigned buffSize, const tstring &defaultString=tstring())
Definition
profile.h:61
owl::TProfile::WriteString
bool WriteString(LPCTSTR key, LPCTSTR str)
Looks up the key and replaces its value with the string value passed (str).
Definition
profile.cpp:153
owl::TProfile::Section
TCHAR * Section
Name of the section to use.
Definition
profile.h:82
owl::TProfile::FileName
TCHAR * FileName
File name of the .INI file.
Definition
profile.h:83
owl::TProfile::Init
void Init(LPCTSTR section, LPCTSTR filename)
Definition
profile.cpp:37
owl::TProfile::TProfile
TProfile(LPCTSTR section, LPCTSTR filename=0)
Constructs a TProfile object for the indicated section within the profile file specified by filename.
Definition
profile.cpp:22
owl::TProfile::WriteString
bool WriteString(const tstring &key, const tstring &str)
Definition
profile.h:76
owl
Object Windows Library (OWLNext Core).
Definition
animctrl.h:22
owl::tstring
std::string tstring
Definition
defs.h:79
defs.h
General definitions used by all ObjectWindows programs.
defs.h
_OWLCLASS
#define _OWLCLASS
Definition
defs.h:338
include
owl
profile.h
Generated by
1.18.0