]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/common/sysopt.cpp
don't crash if conversion of a command line argument to Unicode fails
[wxWidgets.git] / src / common / sysopt.cpp
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: common/sysopt.cpp
3// Purpose: wxSystemOptions
4// Author: Julian Smart
5// Modified by:
6// Created: 2001-07-10
7// RCS-ID: $Id$
8// Copyright: (c) Julian Smart
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12// ============================================================================
13// declarations
14// ============================================================================
15
16// ---------------------------------------------------------------------------
17// headers
18// ---------------------------------------------------------------------------
19
20// For compilers that support precompilation, includes "wx.h".
21#include "wx/wxprec.h"
22
23#if defined(__BORLANDC__)
24 #pragma hdrstop
25#endif
26
27#if wxUSE_SYSTEM_OPTIONS
28
29#ifndef WX_PRECOMP
30 #include "wx/list.h"
31#endif
32
33#include "wx/string.h"
34#include "wx/sysopt.h"
35#include "wx/arrstr.h"
36
37// ----------------------------------------------------------------------------
38// private globals
39// ----------------------------------------------------------------------------
40
41static wxArrayString gs_optionNames,
42 gs_optionValues;
43
44// ============================================================================
45// wxSystemOptions implementation
46// ============================================================================
47
48// Option functions (arbitrary name/value mapping)
49void wxSystemOptions::SetOption(const wxString& name, const wxString& value)
50{
51 int idx = gs_optionNames.Index(name, false);
52 if (idx == wxNOT_FOUND)
53 {
54 gs_optionNames.Add(name);
55 gs_optionValues.Add(value);
56 }
57 else
58 {
59 gs_optionNames[idx] = name;
60 gs_optionValues[idx] = value;
61 }
62}
63
64void wxSystemOptions::SetOption(const wxString& name, int value)
65{
66 SetOption(name, wxString::Format(wxT("%d"), value));
67}
68
69wxString wxSystemOptions::GetOption(const wxString& name)
70{
71 int idx = gs_optionNames.Index(name, false);
72 if (idx == wxNOT_FOUND)
73 return wxEmptyString;
74 else
75 return gs_optionValues[idx];
76}
77
78int wxSystemOptions::GetOptionInt(const wxString& name)
79{
80 return wxAtoi(GetOption(name));
81}
82
83bool wxSystemOptions::HasOption(const wxString& name)
84{
85 return gs_optionNames.Index(name, false) != wxNOT_FOUND;
86}
87
88#endif // wxUSE_SYSTEM_OPTIONS
89