]>
git.saurik.com Git - wxWidgets.git/blob - src/gtk/utilsres.cpp
1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Robert Roebling
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 // For compilers that support precompilation, includes "wx.h".
11 #include "wx/wxprec.h"
14 #include "wx/string.h"
17 #include "wx/config.h"
20 //-----------------------------------------------------------------------------
22 //-----------------------------------------------------------------------------
24 bool wxWriteResource(const wxString
& section
, const wxString
& entry
, const wxString
& value
, const wxString
& file
)
26 wxString
filename( file
);
27 if (filename
.IsEmpty()) filename
= wxT(".wxWindows");
29 wxFileConfig
conf( wxTheApp
->GetAppName(), wxTheApp
->GetVendorName(), filename
);
31 conf
.SetPath( section
);
33 return conf
.Write( entry
, value
);
36 bool wxWriteResource(const wxString
& section
, const wxString
& entry
, float value
, const wxString
& file
)
39 buf
.Printf(wxT("%.4f"), value
);
41 return wxWriteResource(section
, entry
, buf
, file
);
44 bool wxWriteResource(const wxString
& section
, const wxString
& entry
, long value
, const wxString
& file
)
47 buf
.Printf(wxT("%ld"), value
);
49 return wxWriteResource(section
, entry
, buf
, file
);
52 bool wxWriteResource(const wxString
& section
, const wxString
& entry
, int value
, const wxString
& file
)
55 buf
.Printf(wxT("%d"), value
);
57 return wxWriteResource(section
, entry
, buf
, file
);
60 bool wxGetResource(const wxString
& section
, const wxString
& entry
, wxChar
**value
, const wxString
& file
)
62 wxString
filename( file
);
63 if (filename
.IsEmpty()) filename
= wxT(".wxWindows");
65 wxFileConfig
conf( wxTheApp
->GetAppName(), wxTheApp
->GetVendorName(), filename
);
67 conf
.SetPath( section
);
70 if (conf
.Read( entry
, &result
))
72 if (!result
.IsEmpty())
74 wxChar
*s
= new wxChar
[result
.Len()+1];
75 wxStrcpy( s
, result
.c_str() );
84 bool wxGetResource(const wxString
& section
, const wxString
& entry
, float *value
, const wxString
& file
)
87 bool succ
= wxGetResource(section
, entry
, (wxChar
**)&s
, file
);
90 *value
= (float)wxStrtod(s
, NULL
);
97 bool wxGetResource(const wxString
& section
, const wxString
& entry
, long *value
, const wxString
& file
)
100 bool succ
= wxGetResource(section
, entry
, (wxChar
**)&s
, file
);
103 *value
= wxStrtol(s
, NULL
, 10);
110 bool wxGetResource(const wxString
& section
, const wxString
& entry
, int *value
, const wxString
& file
)
113 bool succ
= wxGetResource(section
, entry
, (wxChar
**)&s
, file
);
116 *value
= (int)wxStrtol(s
, NULL
, 10);