2
* This file is part of wxSmith plugin for Code::Blocks Studio
3
* Copyright (C) 2006-2007 Bartlomiej Swiecki
5
* wxSmith is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 3 of the License, or
8
* (at your option) any later version.
10
* wxSmith is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with wxSmith. If not, see <http://www.gnu.org/licenses/>.
19
* $Id: wxspropertystream.cpp 4850 2008-01-29 21:45:49Z byo $
20
* $HeadURL: svn://svn.berlios.de/codeblocks/tags/8.02/src/plugins/contrib/wxSmith/properties/wxspropertystream.cpp $
23
#include "wxspropertystream.h"
25
bool wxsPropertyStream::GetChar(const wxString &Name, wxChar& Value, wxChar Default)
28
if ( !GetString(Name,Data,wxEmptyString) || Data.empty() )
37
bool wxsPropertyStream::PutChar(const wxString &Name, wxChar& Value, wxChar Default)
39
wxString Data = wxString::Format(_T("%c"),Value);
40
if ( !PutString(Name,Data,wxString::Format(_T("%c"),Default)) ) return false;
41
Value = Data.empty() ? Default : Data[0];
45
bool wxsPropertyStream::GetLong(const wxString &Name, long& Value, long Default)
48
if ( !GetString(Name,Data,wxEmptyString) || Data.empty() )
57
bool wxsPropertyStream::PutLong(const wxString &Name, long& Value, long Default)
59
wxString Data = wxString::Format(_T("%d"),Value);
60
if ( !PutString(Name,Data,wxString::Format(_T("%d"),Default)) ) return false;
65
bool wxsPropertyStream::GetDouble(const wxString &Name, double& Value, double Default)
68
if ( !GetString(Name,Data,wxEmptyString) || Data.empty() )
73
Data.ToDouble(&Value);
77
bool wxsPropertyStream::PutDouble(const wxString &Name, double& Value, double Default)
79
wxString Data = wxString::Format(_T("%f"),Value);
80
if ( !PutString(Name,Data,wxString::Format(_T("%f"),Default)) ) return false;
81
Data.ToDouble(&Value);
85
bool wxsPropertyStream::GetULong(const wxString &Name, unsigned long& Value, unsigned long Default)
88
if ( !GetString(Name,Data,wxEmptyString) || Data.empty() )
97
bool wxsPropertyStream::PutULong(const wxString &Name, unsigned long& Value, unsigned long Default)
99
wxString Data = wxString::Format(_T("%u"),Value);
100
if ( !PutString(Name,Data,wxString::Format(_T("%u"),Default)) ) return false;
101
Data.ToULong(&Value);
105
bool wxsPropertyStream::GetBool(const wxString &Name, bool& Value, bool Default)
108
if ( !GetString(Name,Data,wxEmptyString) || Data.empty() )
114
Data.ToLong(&ValueL);
119
bool wxsPropertyStream::PutBool(const wxString &Name, bool& Value, bool Default)
121
wxString Data = Value ? _T("1") : _T("0");
122
if ( !PutString(Name,Data,Default?_T("1"):_T("0")) ) return false;
124
Data.ToLong(&ValueL);