Made iniconf compile on BC++ 5.01 (involved adding Set... accessors to wxConfigBase);

added SafeWord patch to Dialog Editor


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@6634 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
2000-03-12 11:29:13 +00:00
parent 10d432b1b4
commit 8f19c916dc
3 changed files with 43 additions and 13 deletions

View File

@@ -226,6 +226,9 @@ public:
// misc accessors
wxString GetAppName() const { return m_appName; }
wxString GetVendorName() const { return m_vendorName; }
// Used wxIniConfig to set members in constructor
void SetAppName(const wxString& appName) { m_appName = appName; }
void SetVendorName(const wxString& vendorName) { m_vendorName = vendorName; }
void SetStyle(long style) { m_style = style; }
long GetStyle() const { return m_style; }

View File

@@ -60,13 +60,22 @@ wxIniConfig::wxIniConfig(const wxString& strAppName,
const wxString& localFilename,
const wxString& globalFilename,
long style)
: wxConfigBase(!strAppName && wxTheApp ? wxTheApp->GetAppName()
: wxConfigBase(strAppName, strVendor, localFilename, globalFilename, style)
#if 0 // This is too complex for some compilers, e.g. BC++ 5.01
: wxConfigBase((strAppName.IsEmpty() && wxTheApp) ? wxTheApp->GetAppName()
: strAppName,
!strVendor ? (wxTheApp ? wxTheApp->GetVendorName()
strVendor.IsEmpty() ? (wxTheApp ? wxTheApp->GetVendorName()
: strAppName)
: strVendor,
localFilename, globalFilename, style)
#endif
{
if (strAppName.IsEmpty() && wxTheApp)
SetAppName(wxTheApp->GetAppName());
if (strVendor.IsEmpty() && wxTheApp)
SetVendorName(wxTheApp->GetVendorName());
m_strLocalFilename = localFilename;
if (m_strLocalFilename.IsEmpty())
{

View File

@@ -108,7 +108,7 @@ bool wxResourceTableWithSaving::SaveResource(wxTextOutputStream& stream, wxItemR
}
stream << " style = '" << styleBuf << "',\\\n";
stream << " title = '" << item->GetTitle() << "',\\\n";
stream << " title = " << SafeWord(item->GetTitle()) << ",\\\n";
stream << " id = " << item->GetId() << ",\\\n";
stream << " x = " << item->GetX() << ", y = " << item->GetY();
stream << ", width = " << item->GetWidth() << ", height = " << item->GetHeight();
@@ -576,17 +576,35 @@ char *SafeString(const wxString& s)
}
}
// Returns quoted string or ''
// Returns quoted string or '' : convert " to \"
char *SafeWord(const wxString& s)
{
if (s == "")
return "''";
else
{
strcpy(wxBuffer, "'");
strcat(wxBuffer, (const char*) s);
strcat(wxBuffer, "'");
return wxBuffer;
}
const char *cp;
char *dp;
if (s == "")
return "''";
else
{
dp = wxBuffer;
cp = s.c_str();
*dp++ = '\'';
while(*cp != 0) {
if(*cp == '"') {
*dp++ = '\\';
*dp++ = '"';
} else if(*cp == '\'') {
*dp++ = '\\';
*dp++ = '\'';
} else
*dp++ = *cp;
cp++;
}
*dp++ = '\'';
*dp++ = 0;
return wxBuffer;
}
}