reSIProcate/stack  9694
Public Member Functions | Private Member Functions | Private Attributes
ArGen Class Reference

List of all members.

Public Member Functions

 ArGen (const char *arname=0, const int arnum=0, size_t wrapCol=72)
 ~ArGen ()
void add (const unsigned char c)
 bulk of formatting work done here.
void add (const unsigned char *buf, size_t sz)
void end ()
int outputDef (int fd)

Private Member Functions

void addRaw (const unsigned char c)
void addRaw (const char *str)

Private Attributes

std::string code
size_t mColumn
size_t mNcols

Detailed Description

Definition at line 11 of file testConvertRaw.cxx.


Constructor & Destructor Documentation

ArGen::ArGen ( const char *  arname = 0,
const int  arnum = 0,
size_t  wrapCol = 72 
)

Definition at line 45 of file testConvertRaw.cxx.

References code, and toString().

                                                          :
    mColumn(0),
    mNcols(wrapCol)

{
    if (!arname)
        arname = "data";

    code += "const char ";
    code += arname;
    if (arnum) code += toString(arnum);
    code += "[] = {\n";
}

Here is the call graph for this function:

ArGen::~ArGen ( )

Definition at line 111 of file testConvertRaw.cxx.

{}

Member Function Documentation

void ArGen::add ( const unsigned char  c)

bulk of formatting work done here.

Definition at line 76 of file testConvertRaw.cxx.

References addRaw(), mColumn, and mNcols.

Referenced by add(), and dumpraw().

{
    // take care of 1st part of line
    if (!mColumn)
        addRaw("        \"");

    // take care of switching modes and opening or closing any running
    // quotations.

    if (isalnum(c) || c == ' ' ||
        ( ispunct(c) && c != '\\' && c != '"' ))
    {
        addRaw(c);
    }
    else
    {
        static const char hexv[] ="0123456789abcdef";
        addRaw("\\x");
        addRaw(hexv[(c&0xf0)>>8]);
        addRaw(hexv[(c&0x0f)]);
    }
    if (mColumn > mNcols || c == 0x0a)
    {
        addRaw("\"\n");
        mColumn = 0;
    }
}

Here is the call graph for this function:

void ArGen::add ( const unsigned char *  buf,
size_t  sz 
)

Definition at line 105 of file testConvertRaw.cxx.

References add().

{
    for(size_t i = 0 ; i < sz ; ++i)
        add(c[i]);
}

Here is the call graph for this function:

void ArGen::addRaw ( const unsigned char  c) [private]

Definition at line 62 of file testConvertRaw.cxx.

References code, and mColumn.

Referenced by add(), and addRaw().

{
    code += c;
    ++mColumn;
}
void ArGen::addRaw ( const char *  str) [private]

Definition at line 68 of file testConvertRaw.cxx.

References addRaw().

{
    for(size_t i = 0 ; s[i] ; ++i)
        addRaw(s[i]);
}

Here is the call graph for this function:

void ArGen::end ( )

Definition at line 115 of file testConvertRaw.cxx.

References code.

Referenced by dumpraw().

{

    code += '\n';
    code += "};\n";
}
int ArGen::outputDef ( int  fd)

Definition at line 123 of file testConvertRaw.cxx.

References code.

Referenced by dumpraw().

{
    return write(fd,code.data(),code.size());
}

Member Data Documentation

std::string ArGen::code [private]

Definition at line 25 of file testConvertRaw.cxx.

Referenced by addRaw(), ArGen(), end(), and outputDef().

size_t ArGen::mColumn [private]

Definition at line 26 of file testConvertRaw.cxx.

Referenced by add(), and addRaw().

size_t ArGen::mNcols [private]

Definition at line 27 of file testConvertRaw.cxx.

Referenced by add().


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