Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

expander::expcmd_if< StringType > Class Template Reference

The class implementing the 'if' command. More...

#include <expandlib-cmd-if.h>

Inherits expander::expandcmd< StringType >< StringType >.

Inheritance diagram for expander::expcmd_if< StringType >:

Inheritance graph
Collaboration diagram for expander::expcmd_if< StringType >:

Collaboration graph
List of all members.

Public Methods

 expcmd_if (expandable< StringType > *const eobj)
 The constructor.

virtual void operator() (StringType &dest, const FParamVectorType &params, const FVarMapType &vars, ExpandResultsType &results) const
void Register ()
 Registers this command with 'expobj'.


Protected Types

typedef ::std::vector< StringType > FParamVectorType
 The type used for the parameter vectors (MSVC wouldn't allow me to use template arguments in these typedefs, or I don't know how it should be done).

typedef ::std::map< StringType,
::expander::expandvartype<
StringType > * > 
FVarMapType
 The type used for the map of variables (MSVC wouldn't allow me to use template arguments in these typedefs, or I don't know how it should be done).

typedef ::std::map< StringType,
::expander::expandcmd< StringType > * > 
FCmdMapType
 The type used for the map of commands (MSVC wouldn't allow me to use template arguments in these typedefs, or I don't know how it should be done).


Protected Methods

bool IsValidOpStartChar (const StringType::value_type ch) const throw ()
 Determines wether ch is a valid first character for an operand.

bool IsValidOpChar (const StringType::value_type ch) const throw ()
 Determines wether ch is a valid operand character.


Protected Attributes

const std::locale loc
 Used for textual comparison.

expandable< StringType
> *const 
expobj
 A const pointer to the expander::expandable object this command belongs to.

const StringType cmdname
 A const string containing the name of this command.


Detailed Description

template<class StringType = ::std::string>
class expander::expcmd_if< StringType >

The class implementing the 'if' command.

Syntax:
#if(expandablestring,truepart,falsepart)
Checks wether all the vars in expandablestring exist
#if(operand1,operator,operand2,truepart,falsepart)
Performs the requested comparison, for example: #if(2,>!,3,Two is greater than three.,Two is smaller than\, or equal to\, three.) returns: Two is smaller than, or equal to, three.

Definition at line 53 of file expandlib-cmd-if.h.


Member Typedef Documentation

template<class StringType = ::std::string>
typedef ::std::map<StringType, ::expander::expandcmd<StringType>*> expander::expandcmd< StringType >::FCmdMapType [protected, inherited]
 

The type used for the map of commands (MSVC wouldn't allow me to use template arguments in these typedefs, or I don't know how it should be done).

Definition at line 68 of file expandlib-cmd.h.

template<class StringType = ::std::string>
typedef ::std::vector<StringType> expander::expandcmd< StringType >::FParamVectorType [protected, inherited]
 

The type used for the parameter vectors (MSVC wouldn't allow me to use template arguments in these typedefs, or I don't know how it should be done).

Definition at line 66 of file expandlib-cmd.h.

template<class StringType = ::std::string>
typedef ::std::map<StringType, ::expander::expandvartype<StringType>*> expander::expandcmd< StringType >::FVarMapType [protected, inherited]
 

The type used for the map of variables (MSVC wouldn't allow me to use template arguments in these typedefs, or I don't know how it should be done).

Definition at line 67 of file expandlib-cmd.h.


Constructor & Destructor Documentation

template<class StringType = ::std::string>
expander::expcmd_if< StringType >::expcmd_if expandable< StringType > *const    eobj [inline]
 

The constructor.

This constructor gets a pointer to an expander::expandable object and passes that, along with the name of the command, to the expander::expandcmd constructor.

Definition at line 78 of file expandlib-cmd-if.h.


Member Function Documentation

template<class StringType = ::std::string>
bool expander::expcmd_if< StringType >::IsValidOpChar const StringType::value_type    ch const throw () [inline, protected]
 

Determines wether ch is a valid operand character.

Definition at line 63 of file expandlib-cmd-if.h.

template<class StringType = ::std::string>
bool expander::expcmd_if< StringType >::IsValidOpStartChar const StringType::value_type    ch const throw () [inline, protected]
 

Determines wether ch is a valid first character for an operand.

Definition at line 57 of file expandlib-cmd-if.h.

template<class StringType = ::std::string>
virtual void expander::expcmd_if< StringType >::operator() StringType &    dest,
const FParamVectorType   params,
const FVarMapType   vars,
ExpandResultsType   results
const [inline, virtual]
 

This performs the if command, it does this by splitting its first parameter into operand1, operator and operand2. It simply puts anything it finds in operand1, until it encounters an operator start character (see expcmd_if::IsValidOpStartChar). Then it puts everything into the operator, with a maximum of three chars and it stops before that if it encounters a non-operator char (see expcmd_if::IsValidChar). After that everything goes into operand2.

I am know using an alternative to the "let the command parse the parameters" strategy to do less extra work, I simply use more than one syntax: #if(operand1,operator,operand2,truepart,falsepart) and #if(expstrtocheck,truepart,falsepart), and perhaps even #if(operand1-1,operator1,operand1-2,booloperator1,operand2-1,operator2,operand2-2,truepart,falsepart), but that would be a lot nicer if some kind of tree structure could be used.

Todo:
Make textual comparison work (using locale's/facets?).

Implements expander::expandcmd< StringType >.

Definition at line 91 of file expandlib-cmd-if.h.

References expander::expandcmd< StringType >::expobj, and expander::expandresults::MissedVars.

template<class StringType = ::std::string>
void expander::expandcmd< StringType >::Register   [inline, inherited]
 

Registers this command with 'expobj'.

Register adds itself to the expandable::cmdmap in expobj. But since there are no expandcmd instances (it's an abstract class), this will only be done by derived classes (which fill cmdname and expobj through the constructor).

Definition at line 96 of file expandlib-cmd.h.

References expander::expandable< StringType >::cmdmap.


Member Data Documentation

template<class StringType = ::std::string>
const StringType expander::expandcmd< StringType >::cmdname [protected, inherited]
 

A const string containing the name of this command.

This string is used by expandcmd::Register and initialized by the constructor, which is called by the constructor of a derived class (which passes its name to this class, so expandcmd::cmdname contains the right name.

Definition at line 77 of file expandlib-cmd.h.

template<class StringType = ::std::string>
expandable<StringType>* const expander::expandcmd< StringType >::expobj [protected, inherited]
 

A const pointer to the expander::expandable object this command belongs to.

Definition at line 71 of file expandlib-cmd.h.

Referenced by expander::expcmd_upper< StringType >::operator()(), expander::expcmd_unknownvars< StringType >::operator()(), expander::expcmd_trim< StringType >::operator()(), expander::expcmd_rtrim< StringType >::operator()(), expander::expcmd_numvars< StringType >::operator()(), expander::expcmd_ltrim< StringType >::operator()(), expander::expcmd_lower< StringType >::operator()(), expander::expcmd_knownvars< StringType >::operator()(), expander::expcmd_if< StringType >::operator()(), expander::expcmd_ftrunc< StringType >::operator()(), expander::expcmd_fpad< StringType >::operator()(), expander::expcmd_btrunc< StringType >::operator()(), expander::expcmd_bpad< StringType >::operator()(), and expander::expcmd_abbr< StringType >::operator()().

template<class StringType = ::std::string>
const std::locale expander::expcmd_if< StringType >::loc [protected]
 

Used for textual comparison.

Definition at line 69 of file expandlib-cmd-if.h.


The documentation for this class was generated from the following file:
Generated on Tue Feb 4 17:24:27 2003 for ExpandLib by doxygen1.3-rc2