// another example: using default values and the full path instead of just
// key name: if the key is not found , the value 17 is returned
- long value = config->Read("/LastRun/CalculatedValues/MaxValue", 17);
+ long value = config->ReadLong("/LastRun/CalculatedValues/MaxValue", 17);
...
...
...
conf->Write("../GroupEntry", 2);
conf->SetPath("..");
- wxASSERT( conf->Read("Subgroup/SubgroupEntry", 0l) == 3 );
+ wxASSERT( conf->ReadLong("Subgroup/SubgroupEntry", 0) == 3 );
// use absolute path: it is allowed, too
- wxASSERT( conf->Read("/RootEntry", 0l) == 1 );
+ wxASSERT( conf->ReadLong("/RootEntry", 0) == 1 );
\end{verbatim}
{\it Warning}: it is probably a good idea to always restore the path to its
foo(config);
// we're reading "/Foo/Data/Test" here! -1 will probably be returned...
- wxASSERT( config->Read("Test", -1) == 17 );
+ wxASSERT( config->ReadLong("Test", -1) == 17 );
}
\end{verbatim}
write config file data. All {\it Read} function take a default value which
will be returned if the specified key is not found in the config file.
-Currently, only two types of data are supported: string and long (but it might
-change in the near future). To work with other types: for {\it int} or {\it
-bool} you can work with function taking/returning {\it long} and just use the
-casts. Better yet, just use {\it long} for all variables which you're going to
-save in the config file: chances are that {\tt sizeof(bool) == sizeof(int) == sizeof(long)} anyhow on your system. For {\it float}, {\it double} and, in
-general, any other type you'd have to translate them to/from string
-representation and use string functions.
+Currently, supported types of data are:
+\helpref{wxString}{wxstring}, {\it long}, {\it double}, {\it bool},
+\helpref{wxColour}{wxcolour} and any other types,
+for which functions \helpref{wxToString}{wxtostring}
+and \helpref{wxFromString}{wxfromstring} are defined.
Try not to read long values into string variables and vice versa: although it
just might work with wxFileConfig, you will get a system error with
Reads a long value, returning \true if the value was found. If the value was
not found, {\it defaultVal} is used instead.
-\constfunc{long }{Read}{\param{const wxString\& }{key}, \param{long}{ defaultVal}}
-
-Reads a long value from the key and returns it. {\it defaultVal} is returned
-if the key is not found.
-
-NB: writing
-
-{\small
-\begin{verbatim}
- conf->Read("key", 0);
-\end{verbatim}
-}
-
-won't work because the call is ambiguous: compiler can not choose between two
-{\it Read} functions. Instead, write:
-
-{\small
-\begin{verbatim}
- conf->Read("key", 0l);
-\end{verbatim}
-}
-
\constfunc{bool}{Read}{\param{const wxString\& }{ key}, \param{double*}{ d}}
Reads a double value, returning \true if the value was found. If the value was
Reads a bool value, returning \true if the value was found. If the value was
not found, {\it defaultVal} is used instead.
+\constfunc{bool}{Read}{\param{const wxString\& }{ key}, \param{wxMemoryBuffer*}{ buf}}
+
+Reads a binary block, returning \true if the value was found. If the value was
+not found, {\it buf} is not changed.
+
+\constfunc{bool}{Read}{\param{const wxString\& }{ key}, \param{T*}{ value}}
+
+Reads a value of type T, for which function
+\helpref{wxFromString}{wxfromstring} is defined,
+returning \true if the value was found.
+If the value was not found, {\it value} is not changed.
+
+\constfunc{bool}{Read}{\param{const wxString\& }{ key}, \param{T*}{ value},
+ \param{T const\& }{ defaultVal}}
+
+Reads a value of type T, for which function
+\helpref{wxFromString}{wxfromstring} is defined,
+returning \true if the value was found.
+If the value was not found, {\it defaultVal} is used instead.
+
+bool Read(const wxString& key, T* value) const;
+
\pythonnote{In place of a single overloaded method name, wxPython
implements the following methods:\par
\indented{2cm}{\begin{twocollist}
}}
+\membersection{wxConfigBase::ReadBool}\label{wxconfigbasereadbool}
+
+\constfunc{long }{ReadBool}{\param{const wxString\& }{key}, \param{bool}{ defaultVal}}
+
+Reads a bool value from the key and returns it. {\it defaultVal} is returned
+if the key is not found.
+
+
+\membersection{wxConfigBase::ReadDouble}\label{wxconfigbasereaddouble}
+
+\constfunc{long }{ReadDouble}{\param{const wxString\& }{key}, \param{double}{ defaultVal}}
+
+Reads a double value from the key and returns it. {\it defaultVal} is returned
+if the key is not found.
+
+
+\membersection{wxConfigBase::ReadLong}\label{wxconfigbasereadlong}
+
+\constfunc{long }{ReadLong}{\param{const wxString\& }{key}, \param{long}{ defaultVal}}
+
+Reads a long value from the key and returns it. {\it defaultVal} is returned
+if the key is not found.
+
+
+\membersection{wxConfigBase::ReadObject}\label{wxconfigbasereadobject}
+
+\constfunc{T }{ReadObject}{\param{const wxString\& }{key}, \param{T const&}{ defaultVal}}
+
+Reads a value of type T, for which function
+\helpref{wxFromString}{wxfromstring} is defined, from the key and returns it.
+{\it defaultVal} is returned if the key is not found.
+
+
\membersection{wxConfigBase::RenameEntry}\label{wxconfigbaserenameentry}
\func{bool}{RenameEntry}{\param{const wxString\& }{ oldName}, \param{const wxString\& }{ newName}}
\func{bool}{Write}{\param{const wxString\& }{ key}, \param{bool}{ value}}
-These functions write the specified value to the config file and return \true on success.
+\func{bool}{Write}{\param{const wxString\& }{ key}, \param{const wxMemoryBuffer\&}{ buf}}
+
+\func{bool}{Write}{\param{const wxString\& }{ key}, \param{const T\&}{ buf}}
+
+These functions write the specified value to the config file and return \true
+on success. In the last one, function \helpref{wxToString}{wxtostring} must be
+defined for type {\it T}.
\pythonnote{In place of a single overloaded method name, wxPython
implements the following methods:\par