2001-06-12 18:52:03 +00:00
|
|
|
/****************************************************************************
|
|
|
|
*
|
|
|
|
* wxWindows HTML Applet Package
|
|
|
|
*
|
|
|
|
* Copyright (C) 1991-2001 SciTech Software, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* ========================================================================
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the wxWindows License
|
|
|
|
* Version 3.0 (the "License"); you may not use this file except in
|
|
|
|
* compliance with the License. You may obtain a copy of the License at
|
|
|
|
* http://www.wxwindows.org/licence3.txt
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an
|
|
|
|
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
|
|
|
* implied. See the License for the specific language governing
|
|
|
|
* rights and limitations under the License.
|
|
|
|
*
|
|
|
|
* ========================================================================
|
|
|
|
*
|
|
|
|
* Language: ANSI C++
|
|
|
|
* Environment: Any
|
|
|
|
*
|
|
|
|
* Description: Header file for wxIfElseVariable Class, Dynamically constructed
|
|
|
|
* objects representing variables in SSI #if, #else and #endif directives
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef __WX_IFELSEVAR_H
|
|
|
|
#define __WX_IFELSEVAR_H
|
|
|
|
|
2002-02-07 18:46:31 +00:00
|
|
|
#include "wx/object.h"
|
|
|
|
#include "wx/hash.h"
|
|
|
|
|
2001-06-12 18:52:03 +00:00
|
|
|
/*--------------------------- Class Definitions ---------------------------*/
|
|
|
|
|
|
|
|
/****************************************************************************
|
2002-02-07 18:46:31 +00:00
|
|
|
RETURNS:
|
|
|
|
The boolean value of the variable
|
|
|
|
|
2001-06-12 18:52:03 +00:00
|
|
|
REMARKS:
|
2002-02-07 18:46:31 +00:00
|
|
|
To create new variables for the #if, #else and #endif HTML preprocessing
|
|
|
|
blocks you need to derive classes from wxIfElseVariable and override the
|
|
|
|
pure virtual GetValue function. However this should not be done directly
|
|
|
|
but by using the BEGIN_IFELSE_VARIABLE and END_IFELSE_VARIABLE macros
|
2001-06-12 18:52:03 +00:00
|
|
|
|
|
|
|
SEE ALSO:
|
2002-02-07 18:46:31 +00:00
|
|
|
wxIfElsePrep, BEGIN_IFELSE_VARIABLE, END_IFELSE_VARIABLE
|
|
|
|
****************************************************************************/
|
|
|
|
typedef bool (*wxIfElseVariableGetValueFn)();
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
REMARKS:
|
|
|
|
wxIfElseVariable class Definition
|
2001-06-12 18:52:03 +00:00
|
|
|
****************************************************************************/
|
|
|
|
class wxIfElseVariable : public wxObject {
|
2002-02-07 18:46:31 +00:00
|
|
|
protected:
|
|
|
|
const wxChar *m_varName;
|
|
|
|
wxIfElseVariableGetValueFn m_getValueFn;
|
|
|
|
static wxIfElseVariable *sm_first;
|
|
|
|
wxIfElseVariable *m_next;
|
|
|
|
static wxHashTable *sm_varTable;
|
|
|
|
bool forced;
|
|
|
|
bool forceVal;
|
|
|
|
|
|
|
|
static inline wxIfElseVariable *wxIfElseVariable::FindVariable(const wxChar *varName);
|
2001-06-12 18:52:03 +00:00
|
|
|
|
|
|
|
public:
|
2002-02-07 18:46:31 +00:00
|
|
|
// Constructor to create the echo variable and register the class
|
|
|
|
wxIfElseVariable(
|
|
|
|
const char *varName,
|
|
|
|
wxIfElseVariableGetValueFn getValueFn);
|
|
|
|
|
|
|
|
// Member variable access functions
|
|
|
|
const wxChar *GetClassName() const { return m_varName; }
|
|
|
|
wxIfElseVariableGetValueFn GetValueFn() const { return m_getValueFn; }
|
|
|
|
static const wxIfElseVariable* GetFirst() { return sm_first; }
|
|
|
|
const wxIfElseVariable* GetNext() const { return m_next; }
|
2001-06-12 18:52:03 +00:00
|
|
|
|
2002-02-07 18:46:31 +00:00
|
|
|
// Static functions to retrieve any variable avaliable
|
|
|
|
static bool GetValue(const wxChar *varName);
|
|
|
|
static bool Exists(const wxChar *varName);
|
|
|
|
static void Force(const wxChar *varName, bool val);
|
2001-06-12 18:52:03 +00:00
|
|
|
|
2002-02-07 18:46:31 +00:00
|
|
|
// Initializes parent pointers and hash table for fast searching.
|
|
|
|
static void Initialize();
|
2001-06-12 18:52:03 +00:00
|
|
|
|
2002-02-07 18:46:31 +00:00
|
|
|
// Cleans up hash table used for fast searching.
|
|
|
|
static void CleanUp();
|
|
|
|
};
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
PARAMETERS:
|
|
|
|
class - Name of class for echo variable to find
|
2001-06-12 18:52:03 +00:00
|
|
|
|
2002-02-07 18:46:31 +00:00
|
|
|
RETURNS:
|
|
|
|
Pointer to the echo variable class
|
2001-06-12 18:52:03 +00:00
|
|
|
|
2002-02-07 18:46:31 +00:00
|
|
|
REMARKS:
|
|
|
|
Inline helper function to find the echo variable from it's class name.
|
|
|
|
****************************************************************************/
|
|
|
|
inline wxIfElseVariable *wxIfElseVariable::FindVariable(
|
|
|
|
const wxChar *varName)
|
|
|
|
{
|
|
|
|
if (sm_varTable)
|
|
|
|
return (wxIfElseVariable*)sm_varTable->Get(varName);
|
|
|
|
else {
|
|
|
|
wxIfElseVariable *info = sm_first;
|
|
|
|
while (info) {
|
|
|
|
if (info->m_varName && wxStrcmp(info->m_varName, varName) == 0)
|
|
|
|
return info;
|
|
|
|
info = info->m_next;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
2001-06-12 18:52:03 +00:00
|
|
|
|
|
|
|
/*--------------------------------- MACROS --------------------------------*/
|
|
|
|
|
|
|
|
#define BEGIN_IFELSE_VARIABLE(name) \
|
2002-02-07 18:46:31 +00:00
|
|
|
bool wxIfElseVariableFn##name(); \
|
|
|
|
wxIfElseVariable wxIfElseVariable##name(#name,wxIfElseVariableFn##name); \
|
|
|
|
bool wxIfElseVariableFn##name() { \
|
2001-06-12 18:52:03 +00:00
|
|
|
|
2001-07-31 17:50:16 +00:00
|
|
|
#define END_IFELSE_VARIABLE(returnval) \
|
2001-06-12 18:52:03 +00:00
|
|
|
return returnval; \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define IFELSE_VARIABLE(name, state) \
|
|
|
|
BEGIN_IFELSE_VARIABLE(##name##); \
|
2001-07-31 17:50:16 +00:00
|
|
|
END_IFELSE_VARIABLE(bool (state))
|
2001-06-12 18:52:03 +00:00
|
|
|
|
|
|
|
#endif // __WX_IFELSEVAR_H
|
|
|
|
|