|
// CPPTypeTemplated.h: definition of templated-type class
#ifndef INCL_CPPTYPETEMPLATED_H
#define INCL_CPPTYPETEMPLATED_H
#include "CPPTypeModifier.h"
#include "TokenListIncomplete.h"
#include "TemplateArgumentListIncomplete.h"
#include "TemplateParameterListIncomplete.h"
///////////////////////////////////////////////////////////////////////
// CPPTypeTemplated type class. This class describes types
// that are "templated" modification of other types.
//
// Note that CPPTypeTemplated modifies a type,
// indicating that it is a template. This type modifier also
// contains the list of template parameters, which may be either
// 'type' or 'value' parameters. Type parameters contain a special
// CPPTypeTemplatePlaceholder placeholder that is used in processing
// of the template, for example:
// template <class T> class A { T t; };
// When the body of class A is parsed, "T" is bound to the
// CPPTypeTemplatePlaceholder placeholder store in the
// TemplateParameterList.
///////////////////////////////////////////////////////////////////////
class CPPTypeTemplated : public CPPTypeModifier
{
public:
// ctor/dtor
CPPTypeTemplated(
CPPTypeRefI baseType_,
TokenListRefI tokens_, // will copy the list
TemplateParameterListRefI parameterList_,
TemplateArgumentListRefI specializationArgList_,
bool isPrimary_,
bool addToBase
);
virtual ~CPPTypeTemplated();
// Remove template modifiers
virtual CPPTypeRefI StripTemplateModifiers();
// Get the template body token list
TokenListRefI GetTokens() const { return tokens; }
// Set the template body token list. This is used because a class
// template declaration must be made before the body is parsed.
void SetTokens(TokenListRefI tokens_);
// Get the template formal parameter list
TemplateParameterListRefI GetParameterList() const {
assertValid();
return parameterList;
}
// Get the specialization arg list
TemplateArgumentListRefI GetSpecializationArgumentList() const {
assertValid();
return specializationArgList;
}
// Get the primaryness
bool IsPrimary() const { return isPrimary; }
// Format the name of the type
virtual JLStr FormatName(
const JLStr& declName,
const JLStr& suffixStr,
StrListRefI argList,
bool forSpecialization
) const;
// Comparison of two templated type nodes.
// Comparison of the pointers is sufficient because
// only one templated modifier ever modifies the same type.
virtual bool LessThanNode(const CPPType& rhs) const
{
assertValid();
return
CPPTypeModifier::LessThanNode(rhs) ||
(
rhs.GetFlavor() == Templated &&
this < &rhs
);
}
private:
// disallow copy or assignment
CPPTypeTemplated(const CPPTypeTemplated&);
void operator=(const CPPTypeTemplated&);
void assertValid() const {
CPPTypeModifier::assertValid();
assert(GetFlavor() == Templated);
}
// List of tokens comprising the body of the template
TokenListRefI tokens;
// The template's formal parameter list
TemplateParameterListRefI parameterList;
// The template's specialization argument list (which is the function argument
// list for function templates). If the template is a primary template, then
// the argument list should mirror the formal parameters.
TemplateArgumentListRefI specializationArgList;
// True if this is a primary class template declaration
bool isPrimary;
};
#endif
|
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 article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.