StringBuffer Class Reference

#include <Translation.h>


Detailed Description

Definition at line 26 of file Translation.h.


Public Member Functions

 StringBuffer ()
 StringBuffer (const StringBuffer &s)
 StringBuffer (const std::string &_first)
 StringBuffer (const unsigned n)
 ~StringBuffer ()
StringBufferoperator= (const StringBuffer &b)
StringBufferoperator<< (const StringBuffer &s)
StringBufferoperator<< (const std::string &s)
void endl ()
void replace (const std::string &what, const std::string &with)
void insert_begin (const StringBuffer &s)
void format ()
void write (const std::string &_fname)

Private Attributes

std::string buffer

Friends

std::ostream & operator<< (std::ostream &stream, const StringBuffer &)

Constructor & Destructor Documentation

StringBuffer::StringBuffer (  )  [inline]

Definition at line 30 of file Translation.h.

00030 {}

StringBuffer::StringBuffer ( const StringBuffer s  )  [inline]

Definition at line 31 of file Translation.h.

References buffer.

00031 { buffer = s.buffer; }

StringBuffer::StringBuffer ( const std::string &  _first  )  [inline]

Definition at line 32 of file Translation.h.

References buffer.

00032 { buffer += (_first); }

StringBuffer::StringBuffer ( const unsigned  n  )  [inline]

Definition at line 33 of file Translation.h.

References buffer.

00033 { buffer += (to_string<unsigned>(n)); }

StringBuffer::~StringBuffer (  )  [inline]

Definition at line 34 of file Translation.h.

00034 {}


Member Function Documentation

StringBuffer& StringBuffer::operator= ( const StringBuffer b  )  [inline]

Definition at line 37 of file Translation.h.

References buffer.

00037                                                    {
00038         buffer = b.buffer;
00039         return *this;
00040     }

StringBuffer& StringBuffer::operator<< ( const StringBuffer s  )  [inline]

Definition at line 41 of file Translation.h.

References buffer.

00041                                                     {
00042         buffer += (s.buffer);
00043         return *this;
00044     }

StringBuffer& StringBuffer::operator<< ( const std::string &  s  )  [inline]

Definition at line 45 of file Translation.h.

References buffer.

00045                                                  {
00046         buffer += (s);
00047         return *this;
00048     }

void StringBuffer::endl (  )  [inline]

Definition at line 49 of file Translation.h.

References buffer.

00049 { buffer += "\n"; }

void StringBuffer::replace ( const std::string &  what,
const std::string &  with 
) [inline]

Definition at line 50 of file Translation.h.

References buffer, and utils::replace().

00050                                                                {
00051         utils::replace(buffer, what, with);
00052     }

Here is the call graph for this function:

void StringBuffer::insert_begin ( const StringBuffer s  )  [inline]

Definition at line 53 of file Translation.h.

References buffer.

Referenced by Ast2Cpp::operator()().

00053                                              {
00054         std::string out = s.buffer + buffer;
00055         buffer = out;
00056     }

Here is the caller graph for this function:

void StringBuffer::format (  ) 

Definition at line 73 of file Translation.cpp.

References buffer, and indent().

Referenced by Ast2Php::operator()(), and Ast2Cpp::operator()().

00073                           {
00074     string out="";
00075     string temp="";
00076     unsigned nind = 0;
00077     for (std::string::const_iterator iter=buffer.begin();iter!=buffer.end();++iter)
00078     {
00079         const char c = *iter;
00080         if (c == '\n') {
00081             continue;
00082         }
00083         else if (c == '{' || c == '}') {
00084             temp += c;
00085             if (c == '}') nind--;
00086             out += (indent(nind) + temp + "\n");
00087             if (c == '{') nind++;
00088             temp = "";
00089         }
00090         else {
00091             temp += c;
00092             if (c == ';') {
00093                 out += (indent(nind) + temp + "\n");
00094                 temp = "";
00095             }
00096         }
00097     }
00098     buffer = out;
00099 
00100 }

Here is the call graph for this function:

Here is the caller graph for this function:

void StringBuffer::write ( const std::string &  _fname  ) 

Definition at line 103 of file Translation.cpp.

References buffer.

Referenced by main().

00103                                                {
00104     ofstream out(fname.c_str());
00105     out << buffer;
00106     out.close();
00107 }

Here is the caller graph for this function:


Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  stream,
const StringBuffer  
) [friend]

Definition at line 110 of file Translation.cpp.

00110                                                                   {
00111     stream << b.buffer << std::endl;
00112     return stream;
00113 }


Field Documentation

std::string StringBuffer::buffer [private]

Definition at line 28 of file Translation.h.

Referenced by endl(), format(), insert_begin(), operator<<(), operator<<(), operator=(), replace(), StringBuffer(), and write().


The documentation for this class was generated from the following files:
Generated on Wed Feb 27 20:32:17 2008 for php.ast.svn.src. by  doxygen 1.5.3