|
//**************************************************************************************************************************
//* Blue Xml Extension
//* Copyright (c) 2002-2003 Josh Harler
//*
//* Blue - General Purpose C++ Library
//* Copyright (c) 2002-2003 Josh Harler
//*
//* This software is provided 'as-is', without any express or implied warranty. In no event
//* will the authors be held liable for any damages arising from the use of this software.
//*
//* Permission is granted to anyone to use this software for any purpose, including commercial
//* applications, and to alter it and redistribute it freely, subject to the following restrictions:
//*
//* 1. The origin of this software must not be misrepresented; you must not claim that you
//* wrote the original software. If you use this software in a product, an acknowledgment in the
//* product documentation would be appreciated but is not required.
//*
//* 2. Altered source versions must be plainly marked as such, and must not be misrepresented as
//* being the original software.
//*
//* 3. This notice may not be removed or altered from any source distribution.
//*
//* Modified by JCrane2 to support PugXML parser:
//* http://www.codeproject.com/soap/pugxml.asp
//* http://www.codeproject.com/soap/JCraneArticle.asp
//*
//* file PugXPathPredicate.h
//**
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_PUGXPATHPREDICATE_H__E523538D_8427_4D8B_8059_06FF5FD0492F__INCLUDED_)
#define AFX_PUGXPATHPREDICATE_H__E523538D_8427_4D8B_8059_06FF5FD0492F__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// Include the Pug XML library.
#include "pugxml.h"
#include <sstream>
#include <io.h>
#include <sys\stat.h>
using namespace std;
using namespace pug;
#include "PugXPathExpression.h"
namespace blue
{
namespace ext
{
namespace xml
{
/****
* \class PugXPathPredicate
* \brief Evaluates an PugXPath predicate.
*/
class PugXPathPredicate
{
public:
// ===========================================================
// creation/destruction
// ===========================================================
/** Constructor. */
PugXPathPredicate();
/** Destructor. */
~PugXPathPredicate();
// ===========================================================
// query
// ===========================================================
/**
* Parses the string into a series of tokens that are used to
* evaluate the predicate.
*/
Array<PugXPathToken> parsePredicate(BString predicate);
/**
* Determines if the function exists for use in the predicate
* object.
*/
bool hasFunction(BString function);
/** Returns a pointer to the function object. */
PugXPathFunction* getFunction(BString function);
/** overload. */
const PugXPathFunction* getFunction(BString function) const;
// ===========================================================
// manipulation
// ===========================================================
/** Adds a function for use with this predicate object. */
void addFunction(PugXPathFunction* function);
/** Removes a function from use with this predicate object. */
void removeFunction(BString function);
/** Evaluates the predicate. */
PugXPathToken evaluate(Array<PugXPathToken> predicate, Array<xml_node_struct*> search, xml_node_struct* context);
private:
/**
* Copy constructor. Private because PugXPathPredicates should not be
* manipulated by more than one instance.
*/
PugXPathPredicate(const PugXPathPredicate&);
/** Private assignment operator. See copy constructor documentation. */
const PugXPathPredicate& operator=(const PugXPathPredicate&);
PugXPathToken evaluateSection(Array<PugXPathToken> predicate, Array<xml_node_struct*> search, xml_node_struct* context, int begIdx, int endIdx, bool func);
Array<PugXPathFunction*> m_operators;
Array<PugXPathFunction*> m_defaults;
Array<PugXPathFunction*> m_functions;
};
}
}
} // namespaces
#endif // !defined(AFX_PUGXPATHPREDICATE_H__E523538D_8427_4D8B_8059_06FF5FD0492F__INCLUDED_)
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.