#include "wx/deprecated/expr.h"
#include "wx/deprecated/wxexpr.h"
+#if !WXWIN_COMPATIBILITY_2_4
+static inline wxChar* copystring(const wxChar* s)
+ { return wxStrcpy(new wxChar[wxStrlen(s) + 1], s); }
+#endif
+
extern "C" void add_expr(char *);
extern "C" void LexFromFile(FILE *fd);
extern "C" void LexFromString(char *buf);
break;
case wxExprReal:
case wxExprInteger:
- case wxExprNull:
+ case wxExprNull:
break;
}
client_data = NULL;
break;
case wxExprReal:
case wxExprInteger:
- case wxExprNull:
+ case wxExprNull:
break;
}
client_data = NULL;
}
return new_list;
}
- case wxExprNull:
+ case wxExprNull:
break;
}
return NULL;
if ((firstNode->type == wxExprWord) && (firstNode->value.word[0] == '='))
{
wxExpr *secondNode = firstNode->next;
- if ((secondNode->type == wxExprWord) &&
+ if ((secondNode->type == wxExprWord) &&
(wxStrcmp((const wxChar *)word, secondNode->value.word) == 0))
{
return expr;
bool wxExpr::IsFunctor(const wxString& f) const // Use only for a clause
{
if ((type != wxExprList) || !value.first)
- return FALSE;
+ return false;
- return (value.first->type == wxExprWord &&
+ return (value.first->type == wxExprWord &&
(wxStrcmp((const wxChar *)f, value.first->value.word) == 0));
}
if ((firstNode->type == wxExprWord) && (firstNode->value.word[0] == '='))
{
wxExpr *secondNode = firstNode->next;
- if ((secondNode->type == wxExprWord) &&
+ if ((secondNode->type == wxExprWord) &&
(wxStrcmp((const wxChar *)attribute, secondNode->value.word) == 0))
{
wxExpr *nextExpr = expr->next;
if (expr && (expr->Type() == wxExprInteger || expr->Type() == wxExprReal))
{
var = (int)(expr->IntegerValue());
- return TRUE;
+ return true;
}
else
- return FALSE;
+ return false;
}
bool wxExpr::GetAttributeValue(const wxString& att, long& var) const
if (expr && (expr->Type() == wxExprInteger || expr->Type() == wxExprReal))
{
var = expr->IntegerValue();
- return TRUE;
+ return true;
}
else
- return FALSE;
+ return false;
}
bool wxExpr::GetAttributeValue(const wxString& att, float& var) const
if (expr && (expr->Type() == wxExprInteger || expr->Type() == wxExprReal))
{
var = (float) expr->RealValue();
- return TRUE;
+ return true;
}
else
- return FALSE;
+ return false;
}
bool wxExpr::GetAttributeValue(const wxString& att, double& var) const
if (expr && (expr->Type() == wxExprInteger || expr->Type() == wxExprReal))
{
var = expr->RealValue();
- return TRUE;
+ return true;
}
else
- return FALSE;
+ return false;
}
bool wxExpr::GetAttributeValue(const wxString& att, wxString& var) const // Word OR string -> string
if (expr && expr->Type() == wxExprWord)
{
var = expr->WordValue();
- return TRUE;
+ return true;
}
else if (expr && expr->Type() == wxExprString)
{
var = expr->StringValue();
- return TRUE;
+ return true;
}
else
- return FALSE;
+ return false;
}
bool wxExpr::GetAttributeValue(const wxString& att, wxExpr **var) const
if (expr)
{
*var = expr;
- return TRUE;
+ return true;
}
else
- return FALSE;
+ return false;
}
bool wxExpr::GetAttributeValueStringList(const wxString& att, wxList *var) const
string_expr = string_expr->next;
}
- return TRUE;
+ return true;
}
else
- return FALSE;
+ return false;
}
// Compatibility
node->WriteExpr(stream);
fprintf( stream, "(" );
node = node->next;
- bool first = TRUE;
+ bool first = true;
while (node)
{
if (!first)
fprintf( stream, " " );
node->WriteExpr(stream);
node = node->next;
- if (node)
+ if (node)
fprintf( stream, ",\n" );
- first = FALSE;
+ first = false;
}
fprintf( stream, ").\n\n" );
}
}
case wxExprWord:
{
- bool quote_it = FALSE;
+ bool quote_it = false;
const wxWX2MBbuf val = wxConvLibc.cWX2MB(value.word);
size_t len = strlen(val);
if ((len == 0) || (len > 0 && (val[(size_t) 0] > 64 && val[(size_t) 0] < 91)))
- quote_it = TRUE;
+ quote_it = true;
else
{
size_t i;
for (i = 0; i < len; i++)
if ((!isalpha(val[i])) && (!isdigit(val[i])) &&
(val[i] != '_'))
- { quote_it = TRUE; i = len; }
+ { quote_it = true; i = len; }
}
if (quote_it)
{
expr->WriteExpr(stream);
expr = expr->next;
- if (expr)
- fprintf( stream, ", " );
+ if (expr)
+ fprintf( stream, ", " );
}
fprintf( stream, "]" );
}
/*
* wxExpr 'database' (list of expressions)
*/
-
+
IMPLEMENT_DYNAMIC_CLASS(wxExprDatabase, wxList)
wxExprDatabase::wxExprDatabase(wxExprErrorHandler handler)
while (position && !found)
{
wxExpr *term = (wxExpr *)position->GetData();
-
+
if (term->Type() == wxExprList)
{
wxExpr *value = term->AttributeValue(wxT("id"));
while (position && !found)
{
wxExpr *term = (wxExpr *)position->GetData();
-
+
if (term->Type() == wxExprList)
{
wxExpr *value = term->AttributeValue(word);
while (position && !found)
{
wxExpr *term = (wxExpr *)position->GetData();
-
+
if (term->Type() == wxExprList)
{
wxExpr *value = term->AttributeValue(word);
while (position && !found)
{
wxExpr *term = (wxExpr *)position->GetData();
-
+
if (term->Type() == wxExprList)
{
wxExpr *value = term->AttributeValue(word);
while (position && !found)
{
wxExpr *term = (wxExpr *)position->GetData();
-
+
if (term->Type() == wxExprList)
{
if (term->Functor() == functor)
if (expr)
{
long functor_key = hash_table->MakeKey(WXSTRINGCAST functor);
- long value_key = 0;
+ long value_key;
if (expr && expr->Type() == wxExprString)
{
value_key = hash_table->MakeKey(WXSTRINGCAST expr->StringValue());
}
else
{
- return FALSE;
+ return false;
}
}
bool wxExprDatabase::Write(const wxString& fileName)
{
FILE *stream = wxFopen( fileName, _T("w+"));
-
+
if (!stream)
- return FALSE;
-
+ return false;
+
bool success = Write(stream);
fclose(stream);
return success;
if (first_expr && (first_expr->Type() == wxExprWord) &&
(first_expr->WordValue() == functor))
- return TRUE;
- else
- return FALSE;
- }
- else
- return FALSE;
+ return true;
+ else
+ return false;
+ }
+ else
+ return false;
}
/*
size_t len, i;
const wxMB2WXbuf sbuf = wxConvLibc.cMB2WX(str);
-// str++; /* skip leading quote */
- len = wxStrlen(sbuf) - 1; /* ignore trailing quote */
-
+// str++; /* skip leading quote */
+ len = wxStrlen(sbuf) - 1; /* ignore trailing quote */
+
s = new wxChar[len + 1];
-
+
t = s;
for(i=1; i<len; i++) // 1 since we want to skip leading quote
{
*t = wxT('\0');
- wxExpr *x = new wxExpr(wxExprString, s, FALSE);
+ wxExpr *x = new wxExpr(wxExprString, s, false);
return (char *)x;
}