xpathtoken.h revision 4cb9ed4c3d183554e888e636844f8e3c2e666c40
#ifndef __XPATHTOKEN_H__
#define __XPATHTOKEN_H__
/**
* Phoebe DOM Implementation.
*
* This is a C++ approximation of the W3C DOM model, which follows
* fairly closely the specifications in the various .idl files, copies of
* which are provided for reference. Most important is this one:
*
*
* Authors:
* Bob Jamison
*
* Copyright (C) 2006 Bob Jamison
*
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "dom.h"
#include <math.h>
#include <cstdio>
#include <vector>
{
{
{
{
//########################################################################
//# S T A C K I T E M
//########################################################################
/**
* This represents a single value on the evaluation stack
*/
{
/**
* Constructor
*/
{ init(); }
/**
* Copy constructor
*/
/**
* Destructor
*/
{}
/**
*
*/
//treat the stack item like an union of string, integer, and double
/**
* String value
*/
/**
* Integer value
*/
long ival;
/**
* Double value;
*/
double dval;
void init()
{
sval = "";
ival = 0;
dval = 0.0;
}
{
}
};
//########################################################################
//# X P A T H T O K E N
//########################################################################
/**
* This is a pseudocode-type class that executes itself on a stack,
* much like stack-oriented languages such as FORTH or Postscript.
* Each token can pop zero or more tokens off the stack, and push
* zero or one token back onto it. When a list of tokens is completed,
* a single stack value should be left on the stack.
*/
{
/**
* Token types. Look in xpathtoken.cpp's function table
* to see how these types map to their respective
* functionalities
*/
typedef enum
{
//primitives
TOK_NOP = 0,
//operators
//path types
//axis types
//function types
} TokenType;
/**
* Constructor with a NOP default type
*/
Token()
{ init(); }
/**
* Constructor with a NOP default type
*/
/**
* Constructor with a NOP default type
*/
{
init();
}
/**
* Copy constructor
*/
/**
* Assignment
*/
/**
* Destructor
*/
{}
/**
* Return the enumerated TokenType of this token
*/
{ return type; }
/**
* Return true if the type is one of the Axis types
* above;
*/
{
return type>=TOK_AXIS_ANCESTOR_OR_SELF &&
type <= TOK_AXIS_SELF;
}
/**
* Return the string TokenType of this token
*/
/**
* Let this token execute itself on the given stack,
* possibly adding Nodes to the node list.
*/
{
if (tokenFunc)
return false;
}
/**
* Print the contents of this token
*/
{
printf("%s %s %f %ld\n",
}
//treat the token like an union of string, integer, and double
/**
* String value
*/
/**
* Integer value
*/
long ival;
/**
* Double value;
*/
double dval;
/**
*
*/
/**
*
*/
/**
*
*/
/**
*
*/
/**
*
*/
/**
* The enmerated token type
*/
int type;
/**
* The function that defines the behaviour of this token
*/
void init()
{
ival = 0L;
dval = 0.0;
//sval = ""; //not necessary
}
{
}
};
//########################################################################
//# S T A C K
//########################################################################
/**
*
*/
{
//# From 2.3, principal type of child axes
typedef enum
{
/**
* Constructor
*/
{ clear(); }
/**
* Copy constructor
*/
/**
* Destructor
*/
{}
/**
*
*/
/**
*
*/
/**
*
*/
{
{
//TODO: error here
return item;
}
return item;
}
/**
*
*/
{
stackItems.clear();
}
{
}
int principalNodeType;
};
//########################################################################
//# T O K E N L I S T
//########################################################################
/**
*
*/
{
/**
*
*/
{ init(); }
/**
*
*/
/**
*
*/
/**
*
*/
{ }
/**
*
*/
/**
*
*/
{ return tokens; }
/**
*
*/
{
{
}
}
/**
*
*/
{
}
void init()
{
clear();
}
{
}
};
//########################################################################
//# T O K E N E X E C U T O R
//########################################################################
/**
* A token evaluator, with stack and axis context
*/
{
/**
* Constructor
*/
/**
* Copy constructor
*/
/**
* Destructor
*/
virtual ~TokenExecutor();
/**
* Assign our values to those of the other
*/
/**
* Reset the stack to its original settings
*/
/**
* Execute a list upon a given node. For each Axis encountered,
* get the nodes encountered so far, and execute the rest of the
* list of tokens upon each of the nodes.
*/
int position,
/**
* Execute a token list on the stack
*/
/**
*
*/
/**
*
*/
};
} // namespace xpath
} // namespace dom
} // namespace w3c
} // namespace org
#endif /* __XPATHTOKEN_H__ */
//########################################################################
//# E N D O F F I L E
//########################################################################