Google
Web alhem.net
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members

Scope Class Reference

#include <Scope.h>

Inheritance diagram for Scope:

Inheritance graph
[legend]
Collaboration diagram for Scope:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Scope ()
 Scope (token_v &)
 ~Scope ()
void Add (Sequence *p)
void Display ()
bool Trail ()
void AddTrail (token_v &)
std::string GetTrail ()
sequence_v::iterator ScopeBegin ()
sequence_v::iterator ScopeEnd ()

Private Attributes

sequence_v m_sts
token_v m_trail

Detailed Description

File ......... Scope.h Published .... 2004-05-17 Author ....... grymse@alhem.net

Definition at line 29 of file Scope.h.


Constructor & Destructor Documentation

Scope::Scope  ) 
 

File ......... Scope.cpp Published .... 2004-05-17 Author ....... grymse@alhem.net

Definition at line 35 of file Scope.cpp.

00036 :Sequence()
00037 {
00038 }

Scope::Scope token_v  ) 
 

Definition at line 41 of file Scope.cpp.

References token_v.

00042 :Sequence(tok)
00043 {
00044 }

Scope::~Scope  ) 
 

Definition at line 47 of file Scope.cpp.

References m_sts.

00048 {
00049         while (m_sts.size())
00050         {
00051                 sequence_v::iterator it = m_sts.begin();
00052                 Sequence *s = *it;
00053                 delete s;
00054                 m_sts.erase(it);
00055         }
00056 }


Member Function Documentation

void Scope::Add Sequence p  )  [inline]
 

Definition at line 36 of file Scope.h.

References m_sts.

00036 { m_sts.push_back(p); }

void Scope::AddTrail token_v  ) 
 

Definition at line 140 of file Scope.cpp.

References m_trail, and token_v.

00141 {
00142         m_trail = tok;
00143 }

void Scope::Display  )  [virtual]
 

Reimplemented from Sequence.

Definition at line 59 of file Scope.cpp.

References config, Sequence::GetExpr(), Sequence::GetFile(), Sequence::GetLine(), Sequence::GetParent(), GetTrail(), Sequence::IsExtern(), m_sts, Sequence::Tab(), and Trail().

00060 {
00061         if (IsExtern())
00062                 return;
00063         if (config["-xml"] == "true")
00064         {
00065                 if (Trail())
00066                 {
00067                         printf("<scope filename=\"%s\" line=\"%d\" value=\"%s\" trail=\"%s\">\n",
00068                                 GetFile().c_str(),
00069                                 GetLine(),
00070                                 GetExpr().c_str(),
00071                                 GetTrail().c_str());
00072                 }
00073                 else
00074                         printf("<scope filename=\"%s\" line=\"%d\" value=\"%s\">\n",
00075                                 GetFile().c_str(),
00076                                 GetLine(),
00077                                 GetExpr().c_str());
00078                 for (sequence_v::iterator it = m_sts.begin(); it != m_sts.end(); it++)
00079                 {
00080                         Sequence *s = *it;
00081                         s -> Display();
00082                 }
00083                 printf("</scope>\n");
00084                 return;
00085         }
00086         if (config["-dot"] == "true")
00087                 return;
00088         if (GetParent()) // root Scope has parent NULL
00089         {
00090                 Tab();
00091                 printf("%s\n",GetExpr().c_str());
00092                 Tab();
00093                 printf("{\n");
00094         }
00095         for (sequence_v::iterator it = m_sts.begin(); it != m_sts.end(); it++)
00096         {
00097                 Sequence *s = *it;
00098                 s -> Display();
00099         }
00100         if (GetParent())
00101         {
00102                 Tab();
00103                 printf("}");
00104                 if (Trail())
00105                 {
00106                         printf(" %s",GetTrail().c_str());
00107 /*
00108                         for (token_v::iterator it = m_trail.begin(); it != m_trail.end(); it++)
00109                         {
00110                                 Token *t = *it;
00111                                 printf(" %s",t -> GetVal().c_str());
00112                         }
00113 //                      printf(";");
00114 */
00115                 }
00116                 printf(" // %s\n",GetExpr().c_str());
00117         }
00118 }

std::string Scope::GetTrail  ) 
 

Definition at line 146 of file Scope.cpp.

References config, m_trail, and Sequence::xmlsafestr().

Referenced by Display().

00147 {
00148         std::string tmp;
00149         for (token_v::iterator it = m_trail.begin(); it != m_trail.end(); it++)
00150         {
00151                 Token *t = *it;
00152                 std::string str = t -> GetVal();
00153 //              if (tmp.size() && (isalpha(str[0]) || str[0] == '<') )
00154 //                      tmp += " ";
00155                 tmp += str;
00156         }
00157         if (config["-xml"] == "true")
00158                 xmlsafestr(tmp);
00159         return tmp;
00160 }

sequence_v::iterator Scope::ScopeBegin  )  [inline]
 

Definition at line 42 of file Scope.h.

References m_sts.

00042 { return m_sts.begin(); }

sequence_v::iterator Scope::ScopeEnd  )  [inline]
 

Definition at line 43 of file Scope.h.

References m_sts.

00043 { return m_sts.end(); }

bool Scope::Trail  ) 
 

Definition at line 121 of file Scope.cpp.

References Class, Enum, Sequence::GetFirstToken(), Struct, and Typedef.

Referenced by Display().

00122 {
00123         Token *t = GetFirstToken();
00124         if (!t)
00125                 return false;
00126         switch (t -> GetCode())
00127         {
00128         case Typedef:
00129         case Class:
00130         case Struct:
00131         case Enum:
00132                 return true;
00133         default:
00134                 break;
00135         }
00136         return false;
00137 }


Member Data Documentation

sequence_v Scope::m_sts [private]
 

Definition at line 46 of file Scope.h.

Referenced by Add(), Display(), ScopeBegin(), ScopeEnd(), and ~Scope().

token_v Scope::m_trail [private]
 

Definition at line 47 of file Scope.h.

Referenced by AddTrail(), and GetTrail().


The documentation for this class was generated from the following files:
Generated for My SDL C++ Gui by doxygen 1.3.6