SqlStringBuffer.h

Go to the documentation of this file.
00001 /*
00002 // $Id: //open/dev/fennel/calctest/SqlStringBuffer.h#2 $
00003 // Fennel is a library of data storage and processing components.
00004 // Copyright (C) 2005-2009 The Eigenbase Project
00005 // Copyright (C) 2004-2009 SQLstream, Inc.
00006 // Copyright (C) 2009-2009 LucidEra, Inc.
00007 //
00008 // This program is free software; you can redistribute it and/or modify it
00009 // under the terms of the GNU General Public License as published by the Free
00010 // Software Foundation; either version 2 of the License, or (at your option)
00011 // any later version approved by The Eigenbase Project.
00012 //
00013 // This program is distributed in the hope that it will be useful,
00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 // GNU General Public License for more details.
00017 //
00018 // You should have received a copy of the GNU General Public License
00019 // along with this program; if not, write to the Free Software
00020 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00021 */
00022 
00023 #ifndef Fennel_SqlStringBuffer_Included
00024 #define Fennel_SqlStringBuffer_included
00025 
00026 #include "fennel/common/TraceSource.h"
00027 
00028 #include <boost/scoped_array.hpp>
00029 #include <string>
00030 #include <limits>
00031 #include <vector>
00032 
00033 using namespace fennel;
00034 using namespace std;
00035 
00036 
00037 
00038 // must support 0 length strings
00039 class SqlStringBuffer
00040 {
00041 public:
00042     static const uint mBumperChar;
00043     static const int mBumperLen;
00044 
00045     explicit
00046     SqlStringBuffer(
00047         int storage,      // maximum size of string in characters
00048         int size,         // size of text, in characters, excluding padding
00049         int leftpad = 0,  // pad left with this many characters
00050         int rightpad = 0, // pad right with this many chararacters
00051         uint text = 'x',  // fill text w/this
00052         uint pad = ' ',   // pad w/this
00053         // Try to use something unaligned below:
00054         int leftBumper = mBumperLen,  // In characters
00055         int rightBumper = mBumperLen);
00056 
00057     bool verify();
00058 
00059     void randomize(
00060         uint start = 'A',
00061         uint lower = ' ',
00062         uint upper = '~');
00063 
00064     void patternfill(
00065         uint start = 'A',
00066         uint lower = ' ',
00067         uint upper = '~');
00068 
00069 
00070     char * mStr;           // valid string start. (includes left padding)
00071     char * mRightP;       // right bumper start. valid string ends 1 before here
00072     char * mLeftP;         // left bumper start.
00073     const int mStorage;    // maximum size (column width) of string
00074     const int mSize;       // size of string
00075     const int mLeftPad;    // length of left padding
00076     const int mRightPad;   // length of right padding
00077     const int mLeftBump;   // length of left bumper
00078     const int mRightBump;  // length of right bumper
00079     const int mTotal;      // size of string + bumpers
00080     string mS;
00081 
00082 private:
00083 };
00084 
00085 class SqlStringBufferUCS2
00086 {
00087 public:
00088     static const uint mBumperChar;
00089     static const int mBumperLen;
00090 
00091     explicit
00092     SqlStringBufferUCS2(SqlStringBuffer const &src);
00093 
00094     explicit
00095     SqlStringBufferUCS2(
00096         SqlStringBuffer const &src,
00097         int leftBumper,
00098         int rightBumper);
00099 
00100     void init();
00101     bool verify();
00102     void randomize(
00103         uint start = 'A',
00104         uint lower = ' ',
00105         uint upper = '~');
00106 
00107     void patternfill(
00108         uint start = 'A',
00109         uint lower = ' ',
00110         uint upper = '~');
00111 
00112     string dump();
00113     bool equal(SqlStringBufferUCS2 const &other);
00114 
00115     char * mStr;           // valid string start. (includes left padding)
00116     char * mStrPostPad;    // valid string start, skipping left padding
00117     char * mRightP;       // right bumper start. valid string ends 1 before here
00118     char * mLeftP;         // left bumper start.
00119     const int mStorage;    // maximum size (column width) of string
00120     const int mSize;       // size of string
00121     const int mLeftPad;    // length of left padding
00122     const int mRightPad;   // length of right padding
00123     const int mLeftBump;   // length of left bumper
00124     const int mRightBump;  // length of right bumper
00125     const int mTotal;      // size of string + bumpers
00126     string mS;
00127 
00128 private:
00129 };
00130 
00131 #endif
00132 
00133 // End SqlStringBuffer.h

Generated on Mon Jun 22 04:00:13 2009 for Fennel by  doxygen 1.5.1