ATLAS Offline Software
Loading...
Searching...
No Matches
CxxUtils::ExcBadClassName Class Reference

Recursively separate out template arguments in a C++ class name. More...

#include <ClassName.h>

Inheritance diagram for CxxUtils::ExcBadClassName:
Collaboration diagram for CxxUtils::ExcBadClassName:

Public Member Functions

 ExcBadClassName (const std::string &name)

Detailed Description

Recursively separate out template arguments in a C++ class name.

This class allows making some simple transformations of C++ class names. For example, given these rules:

ClassName::Rules rules;
rules.add ("std::vector<$T, std::allocator<$T> >",
"std::vector<$T>");
rules.add ("std::map<$K,$V, std::less<$K>, std::allocator<std::pair<const $K,$V> > >",
"std::map<$K,$V>");
rules.add ("DataVector<$T, $B>", "DataVector<$T>");
rules.add ("std::__1", "std");

then rules.apply can make transformations like this:

std::__1::vector<std::__1::vector<int, std::__1::allocator<int> >, std::__1::allocator<std::__1::vector<int, std::__1::allocator<int> > > >
-> std::vector<std::vector<int> >
std::map<int, float, std::less<int>, std::allocator<std::pair<const int, float> > >
-> std::map<int, float>
Derived DataVector<T>.
Definition DataVector.h:795

In slightly more detail: this class analyzes C++ class names. A name like

A::B<int, double>

is broken down like this:

  • Name: B.
  • Namespace: A.
  • Template arguments: int and double.

This is done recursively; both the namespace and template argument pieces can be further broken down like this. A name can also be marked as `const', but no other parsing of C-like declarators is done.

Parsed names can be matched against simple patterns like this:

*

A::B<$T>

and the variable T gets set to the corresponding piece of the type being matched. For example, given the above pattern,

If the pattern were A::B<const $T>, then A::B<const int> would match with T set to int, but A::B<int> would not match.

However, the root name of a pattern may not be a variable; for example, you can't use A::$T<int> as a pattern.

You can also substitute variables back into a pattern; for example,

  • T=int into A::B<$T> gives A::B<int>.
  • T=const int into A::B<$T> gives A::B<const int>.
  • T=const int into A::B<const int> gives A::B<const int>. */ class ClassName { public:

/**

Exception to signal a malformed class name.

Definition at line 107 of file CxxUtils/CxxUtils/ClassName.h.

Constructor & Destructor Documentation

◆ ExcBadClassName()

CxxUtils::ExcBadClassName::ExcBadClassName ( const std::string & name)

The documentation for this class was generated from the following file: