Class If#

Nested Relationships#

Nested Types#

Class Documentation#

class If#

Stores a preprocessor ‘#if’ directive and nested directives.

If represents one instance of a preprocessor ‘#if’ directive, including all its cases. That is, a If object corresponding to the following ‘#if’ directive,

#if C_1 … #elif C_2 … #elif C_k … #endif // k+1

stores a sequence of k cases plus the final ‘#endif’. One may view a If object as a container of cases (If::Cases).

In addition, If represents the complete tree of nested ‘#if’ directives. See the case object, If::Case, for more information.

Iterators over the cases of this directive.

typedef Cases_t::iterator iterator#
typedef Cases_t::const_iterator const_iterator#
typedef Cases_t::reverse_iterator reverse_iterator#
typedef Cases_t::const_reverse_iterator const_reverse_iterator#
iterator begin(void)#
const_iterator begin(void) const#
reverse_iterator rbegin(void)#
const_reverse_iterator rbegin(void) const#
iterator end(void)#
const_iterator end(void) const#
reverse_iterator rend(void)#
const_reverse_iterator rend(void) const#
Case *appendCase(PreprocessingInfo*, SgLocatedNode*)#

Appends a new case.

Returns the parent directive, if any.

Case *getParent(void)#
const Case *getParent(void) const#
void setParent(If::Case*)#

Sets the parent directive.

bool isValid(void) const#

Returns ‘true’ if this appears to be a complete ‘#if’ directive.

A ‘valid’ directive is one which begins with an ‘#if’, ends with an ‘#endif’, and contains zero or more ‘#elif’ in between.

Returns the first or last case.

Case *firstCase(void)#
const Case *firstCase(void) const#
Case *lastCase(void)#
const Case *lastCase(void) const#

Public Types

typedef std::list<Case*> Cases_t#

Stores the cases composing an ‘#if’ directive.

Public Functions

If(void)#

Default constructor.

~If(void)#

Destructor&#8212;frees memory associated with cases.

class Case#

Stores one case of a preprocessor ‘#if’ directive.

A If::Case object stores a particular case, identified through a (PreprocessingInfo, SgLocatedNode) pair. It also stores pointers to child If objects, representing nested ‘#if’ directives.

Iterators over the child directives of this case.

typedef Ifs_t::iterator iterator#
typedef Ifs_t::const_iterator const_iterator#
typedef Ifs_t::reverse_iterator reverse_iterator#
typedef Ifs_t::const_reverse_iterator const_reverse_iterator#
iterator begin(void)#
const_iterator begin(void) const#
reverse_iterator rbegin(void)#
const_reverse_iterator rbegin(void) const#
iterator end(void)#
const_iterator end(void) const#
reverse_iterator rend(void)#
const_reverse_iterator rend(void) const#
void appendChild(If*)#

Makes the given ‘#if’ a child of this case.

Gets the ‘#if’ of which this case is a part.

If *getIf(void)#
const If *getIf(void) const#
void setIf(If*)#

Associates this case with a particular directive.

Get the node represented by this case.

SgLocatedNode *getNode(void)#
const SgLocatedNode *getNode(void) const#

Get the preprocessing info represented by this case.

PreprocessingInfo *getInfo(void)#
const PreprocessingInfo *getInfo(void) const#

Public Functions

Case(PreprocessingInfo*, SgLocatedNode*, If* = 0)#
Case(const Case&)#
void dump(size_t level = 0)#
bool isIf(void) const#

Returns ‘true’ if this case is a ‘#if’.

bool isIfdef(void) const#

Returns ‘true’ if this case is a ‘#ifdef’.

bool isIfndef(void) const#

Returns ‘true’ if this case is a ‘#ifndef’.

bool isElif(void) const#

Returns ‘true’ if this case is an ‘#elif’.

bool isElse(void) const#

Returns ‘true’ if this case is an ‘#else’.

bool isEndif(void) const#

Returns ‘true’ if this case is an ‘#endif’.

std::string getRaw(void) const#

Returns the complete, raw directive, as a string.

std::string getDirective(void) const#

Returns the directive as a string (i.e., ‘#if’).

std::string getCondition(void) const#

Get the condition represented by this case.

Protected Functions

Case(void)#

The default constructor, hidden to prevent users from instantiating a case without specifying the actual directive (PreprocessingInfo object and AST node).