BaseString Class Reference

#include <BaseString.hpp>


Detailed Description

Null terminated strings.

Definition at line 27 of file BaseString.hpp.

Public Member Functions

BaseStringappend (const Vector< BaseString > &vector, const BaseString &separator=BaseString(" "))
BaseStringappend (const BaseString &str)
 Appends another BaseString to the end.
BaseStringappend (char c)
 Appends a char to the end.
BaseStringappend (const char *s)
 Appends a char * to the end.
BaseStringappfmt (const char *ftm,...)
 Appends a format string a la printf() to the end.
BaseStringassfmt (const char *ftm,...)
 Assigns from a format string a la printf().
BaseStringassign (const Vector< BaseString > &vector, const BaseString &separator=BaseString(" "))
BaseStringassign (const BaseString &str, size_t n)
 Assigns from another BaseString, with maximum length n.
BaseStringassign (const char *s, size_t n)
 Assigns from char *s, with maximum length n.
BaseStringassign (const BaseString &str)
 Assigns from another BaseString.
BaseStringassign (const char *s)
 Assigns from a char *.
 BaseString (const BaseString &str)
 Constructs a copy of another BaseString.
 BaseString (const char *s)
 Constructs a copy of a char *.
 BaseString ()
 Constructs an empty string.
const char * c_str () const
 Returns a C-style string.
bool empty () const
 Checks if the string is empty.
ssize_t indexOf (char c)
ssize_t lastIndexOf (char c)
unsigned length () const
 Returns the length of the string.
BaseStringndb_tolower ()
 Convert to lowercase.
BaseStringndb_toupper ()
 Convert to uppercase.
bool operator!= (const char *str) const
 Are two strings not equal?
bool operator!= (const BaseString &str) const
 Are two strings not equal?
bool operator< (const BaseString &str) const
 Compare two strings.
BaseStringoperator= (const BaseString &str)
 Assignment operator.
bool operator== (const char *str) const
 Are two strings equal?
bool operator== (const BaseString &str) const
 Are two strings equal?
int split (Vector< BaseString > &vector, const BaseString &separator=BaseString(" "), int maxSize=-1) const
BaseString substr (ssize_t start, ssize_t stop=-1)
BaseStringtrim (const char *delim=" \t")
 ~BaseString ()
 Destructor.

Static Public Member Functions

static char ** argify (const char *argv0, const char *src)
static int snprintf (char *str, size_t size, const char *format,...)
static char * trim (char *src, const char *delim)
static int vsnprintf (char *str, size_t size, const char *format, va_list ap)

Private Attributes

char * m_chr
unsigned m_len


Constructor & Destructor Documentation

BaseString::BaseString  ) 
 

Constructs an empty string.

Definition at line 22 of file BaseString.cpp.

References m_chr, and m_len.

Referenced by split(), and substr().

00023 {
00024     m_chr = new char[1];
00025     m_chr[0] = 0;
00026     m_len = 0;
00027 }

BaseString::BaseString const char *  s  ) 
 

Constructs a copy of a char *.

Definition at line 29 of file BaseString.cpp.

References m_chr, m_len, memcpy, and n.

00030 {
00031     const size_t n = strlen(s);
00032     m_chr = new char[n + 1];
00033     memcpy(m_chr, s, n + 1);
00034     m_len = n;
00035 }

BaseString::BaseString const BaseString str  ) 
 

Constructs a copy of another BaseString.

Definition at line 37 of file BaseString.cpp.

References m_chr, m_len, memcpy, and n.

00038 {
00039     const char* const s = str.m_chr;
00040     const size_t n = str.m_len;
00041     char* t = new char[n + 1];
00042     memcpy(t, s, n + 1);
00043     m_chr = t;
00044     m_len = n;
00045 }

BaseString::~BaseString  ) 
 

Destructor.

Definition at line 47 of file BaseString.cpp.

References m_chr.

00048 {
00049     delete[] m_chr;
00050 }


Member Function Documentation

BaseString & BaseString::append const Vector< BaseString > &  vector,
const BaseString separator = BaseString(" ")
 

Appends a Vector of BaseStrings to the end, each Vector entry separated by separator.

Parameters:
vector Vector of BaseStrings to append
separator Separation between appended strings

Definition at line 109 of file BaseString.cpp.

References append(), and Vector< T >::size().

00110                                                 {
00111     for(size_t i=0;i<vector.size(); i++) {
00112         append(vector[i]);
00113         if(i<vector.size()-1)
00114             append(separator);
00115     }
00116     return *this;
00117 }

BaseString & BaseString::append const BaseString str  ) 
 

Appends another BaseString to the end.

Definition at line 103 of file BaseString.cpp.

References append(), and m_chr.

00104 {
00105     return append(str.m_chr);
00106 }

BaseString & BaseString::append char  c  ) 
 

Appends a char to the end.

Definition at line 98 of file BaseString.cpp.

References appfmt().

00098                          {
00099     return appfmt("%c", c);
00100 }

BaseString & BaseString::append const char *  s  ) 
 

Appends a char * to the end.

Definition at line 85 of file BaseString.cpp.

References m_chr, m_len, memcpy, and n.

Referenced by MgmtSrvr::alloc_node_id(), append(), appfmt(), assign(), base64_encode(), NDBT_ResultRow::c_str(), check_node_vs_replicas(), Ndbcntr::execCONTINUEB(), fixPortNumber(), NdbTransaction::getNdbIndexOperation(), main(), LocalConfig::readFile(), runTableRename(), runTableRenameNF(), runTableRenameSR(), setup_config(), and MgmtSrvr::start().

00086 {
00087     const size_t n = strlen(s);
00088     char* t = new char[m_len + n + 1];
00089     memcpy(t, m_chr, m_len);
00090     memcpy(t + m_len, s, n + 1);
00091     delete[] m_chr;
00092     m_chr = t;
00093     m_len += n;
00094     return *this;
00095 }

BaseString & BaseString::appfmt const char *  ftm,
  ...
 

Appends a format string a la printf() to the end.

Definition at line 145 of file BaseString.cpp.

References append(), basestring_vsnprintf(), and buf.

Referenced by MgmtSrvr::alloc_node_id(), append(), LogHandler::append_impl(), check_node_vs_replicas(), connect_ndb_mgm(), Ndbcntr::execCONTINUEB(), Ndb_mgmclient::execute(), gather_result(), Ndb_mgmd_event_service::log(), main(), ndb_mgm_listen_event_internal(), ndb_mgm_restart2(), ndb_mgm_stop2(), runTestMaxTransaction(), MgmtSrvr::saveConfig(), setup_config(), setup_hosts(), start_process(), and MgmApiSession::stop_session_if_not_connected().

00146 {
00147     char buf[1];
00148     va_list ap;
00149     int l;
00150 
00151     /* Figure out how long the formatted string will be. A small temporary
00152      * buffer is used, because I don't trust all implementations to work
00153      * when called as vsnprintf(NULL, 0, ...).
00154      */
00155     va_start(ap, fmt);
00156     l = basestring_vsnprintf(buf, sizeof(buf), fmt, ap) + 1;
00157     va_end(ap);
00158     char *tmp = new char[l];
00159     va_start(ap, fmt);
00160     basestring_vsnprintf(tmp, l, fmt, ap);
00161     va_end(ap);
00162     append(tmp);
00163     delete[] tmp;
00164     return *this;
00165 }

char ** BaseString::argify const char *  argv0,
const char *  src
[static]
 

Return c-array with strings suitable for execve When whitespace is detected, the characters '"' and '\' are honored, to make it possible to give arguments containing whitespace. The semantics of '"' and '\' match that of most Unix shells.

Definition at line 242 of file BaseString.cpp.

References iswhite, malloc, NULL, Vector< T >::push_back(), Vector< T >::size(), and strdup().

Referenced by CPCD::Process::do_exec(), and setup_environment().

00242                                                      {
00243     Vector<char *> vargv;
00244     
00245     if(argv0 != NULL)
00246         vargv.push_back(strdup(argv0));
00247     
00248     char *tmp = new char[strlen(src)+1];
00249     char *dst = tmp;
00250     const char *end = src + strlen(src);
00251     /* Copy characters from src to destination, while compacting them
00252      * so that all whitespace is compacted and replaced by a NUL-byte.
00253      * At the same time, add pointers to strings in the vargv vector.
00254      * When whitespace is detected, the characters '"' and '\' are honored,
00255      * to make it possible to give arguments containing whitespace.
00256      * The semantics of '"' and '\' match that of most Unix shells.
00257      */
00258     while(src < end && *src) {
00259         /* Skip initial whitespace */
00260         while(src < end && *src && iswhite(*src))
00261             src++;
00262         
00263         char *begin = dst;
00264         while(src < end && *src) {
00265             /* Handle '"' quotation */
00266             if(*src == '"') {
00267                 src++;
00268                 while(src < end && *src && *src != '"') {
00269                     if(*src == '\\')
00270                         src++;
00271                     *dst++ = *src++;
00272                 }
00273                 src++;
00274                 if(src >= end)
00275                     goto end;
00276             }
00277             
00278             /* Handle '\' */
00279             if(*src == '\\')
00280                 src++;
00281             else if(iswhite(*src))
00282                 break;
00283 
00284             /* Actually copy characters */
00285             *dst++ = *src++;
00286         }
00287         
00288         /* Make sure the string is properly terminated */
00289         *dst++ = '\0';
00290         src++;
00291         
00292         vargv.push_back(strdup(begin));
00293     }
00294  end:
00295     
00296     delete[] tmp;
00297     vargv.push_back(NULL);
00298     
00299     /* Convert the C++ Vector into a C-vector of strings, suitable for
00300      * calling execv().
00301      */
00302     char **argv = (char **)malloc(sizeof(*argv) * (vargv.size()));
00303     if(argv == NULL)
00304         return NULL;
00305     
00306     for(size_t i = 0; i < vargv.size(); i++){
00307         argv[i] = vargv[i];
00308     }
00309     
00310     return argv;
00311 }

BaseString & BaseString::assfmt const char *  ftm,
  ...
 

Assigns from a format string a la printf().

Definition at line 120 of file BaseString.cpp.

References basestring_vsnprintf(), buf, int, m_chr, and m_len.

Referenced by add_distribution_key(), MgmtSrvr::alloc_node_id(), check_node_vs_replicas(), CommandInterpreter::connect(), TransporterRegistry::connect_ndb_mgmd(), create_random_table(), NDBT_Tables::createTable(), MgmtSrvr::getConnectionDbParameter(), OpenFiles::insert(), Ndb::internalize_index_name(), Ndb::internalize_table_name(), CPCD::loadProcessList(), main(), ndb_mgm_alloc_nodeid(), ndb_mgm_restart2(), ndb_mgm_stop2(), LocalConfig::parseString(), LocalConfig::readConnectString(), LocalConfig::readFile(), run_create_pk_index(), run_create_pk_index_drop(), run_index_dk(), MgmtSrvr::setConnectionDbParameter(), MgmtSrvr::setDbParameter(), setup_config(), setup_test_case(), MgmtSrvr::startEventLog(), and NdbImpl::update_prefix().

00121 {
00122     char buf[1];
00123     va_list ap;
00124     int l;
00125 
00126     /* Figure out how long the formatted string will be. A small temporary
00127      * buffer is used, because I don't trust all implementations to work
00128      * when called as vsnprintf(NULL, 0, ...).
00129      */
00130     va_start(ap, fmt);
00131     l = basestring_vsnprintf(buf, sizeof(buf), fmt, ap) + 1;
00132     va_end(ap);
00133     if(l > (int)m_len) {
00134         delete[] m_chr;
00135         m_chr = new char[l];
00136     }
00137     va_start(ap, fmt);
00138     basestring_vsnprintf(m_chr, l, fmt, ap);
00139     va_end(ap);
00140     m_len = strlen(m_chr);
00141     return *this;
00142 }

BaseString & BaseString::assign const Vector< BaseString > &  vector,
const BaseString separator = BaseString(" ")
[inline]
 

Assings from a Vector of BaseStrings, each Vector entry separated by separator.

Parameters:
vector Vector of BaseStrings to append
separator Separation between appended strings

Definition at line 260 of file BaseString.hpp.

References append(), and assign().

00261                                                 {
00262   assign("");
00263   return append(vector, separator);
00264 }

BaseString & BaseString::assign const BaseString str,
size_t  n
 

Assigns from another BaseString, with maximum length n.

Definition at line 77 of file BaseString.cpp.

References assign(), m_chr, and m_len.

00078 {
00079     if (n > str.m_len)
00080         n = str.m_len;
00081     return assign(str.m_chr, n);
00082 }

BaseString & BaseString::assign const char *  s,
size_t  n
 

Assigns from char *s, with maximum length n.

Definition at line 65 of file BaseString.cpp.

References m_chr, m_len, and memcpy.

00066 {
00067     char* t = new char[n + 1];
00068     memcpy(t, s, n);
00069     t[n] = 0;
00070     delete[] m_chr;
00071     m_chr = t;
00072     m_len = n;
00073     return *this;
00074 }

BaseString & BaseString::assign const BaseString str  )  [inline]
 

Assigns from another BaseString.

Definition at line 254 of file BaseString.hpp.

References assign(), and m_chr.

00255 {
00256     return assign(str.m_chr);
00257 }

BaseString & BaseString::assign const char *  s  ) 
 

Assigns from a char *.

Definition at line 53 of file BaseString.cpp.

References m_chr, m_len, memcpy, and n.

Referenced by NdbTableImpl::assign(), assign(), NdbDictInterface::create_index_obj_from_table(), NdbDictInterface::createIndex(), NdbDictInterface::createOrAlterTable(), Configuration::fetch_configuration(), Properties::get(), MgmtSrvr::getConnectionDbParameter(), NdbDictionaryImpl::getIndexImpl(), Ndb::internalize_index_name(), Ndb::internalize_table_name(), MgmtSrvr::MgmtSrvr(), ndb_mgm_get_status(), NdbRestarter::NdbRestarter(), NDBT_TestCase::NDBT_TestCase(), NDBT_TestCaseResult::NDBT_TestCaseResult(), operator=(), LocalConfig::parseFileName(), LocalConfig::parseHostName(), NdbDictInterface::parseTableInfo(), SavedRecord::SavedRecord(), Ndb::setCatalogName(), MgmtSrvr::setConnectionDbParameter(), MgmtSrvr::setDbParameter(), NdbDictionary::Column::setDefaultValue(), ConfigRetriever::setError(), NdbEventImpl::setName(), NdbIndexImpl::setName(), NdbTableImpl::setName(), NdbDictionary::Column::setName(), Ndb::setSchemaName(), NdbEventImpl::setTable(), NdbIndexImpl::setTable(), Ndb::setup(), setup_config(), setup_test_case(), MgmtSrvr::startEventLog(), and substr().

00054 {
00055     const size_t n = strlen(s);
00056     char* t = new char[n + 1];
00057     memcpy(t, s, n + 1);
00058     delete[] m_chr;
00059     m_chr = t;
00060     m_len = n;
00061     return *this;
00062 }

const char * BaseString::c_str  )  const [inline]
 

Returns a C-style string.

Definition at line 192 of file BaseString.hpp.

References m_chr.

Referenced by add_distribution_key(), Logger::alert(), MgmtSrvr::alloc_node_id(), NdbDictionaryImpl::alterTable(), LogHandler::append_impl(), base64_decode(), Config::change(), check_node_vs_replicas(), NdbRestarter::connect(), CommandInterpreter::connect(), connect_ndb_mgm(), TransporterRegistry::connect_ndb_mgmd(), convert(), SimpleCpcClient::cpc_send(), create_random_table(), NdbDictInterface::createEvent(), NdbDictionaryImpl::createEvent(), NdbDictInterface::createIndex(), NdbDictInterface::createOrAlterTable(), NDBT_Tables::createTable(), Logger::critical(), Logger::debug(), SimpleCpcClient::define_process(), CPCD::defineProcess(), CPCD::Process::do_exec(), GlobalDictCache::drop(), drop_all_tables(), NdbDictInterface::dropEvent(), NdbDictionaryImpl::dropIndex(), NdbDictionaryImpl::dropTable(), BackupRestore::endOfTables(), NdbTableImpl::equal(), NdbColumnImpl::equal(), NdbOperation::equal_impl(), Logger::error(), Operate::evaluate(), Ndbcntr::execCONTINUEB(), Ndb_mgmclient::execute(), NdbDictionaryImpl::fetchGlobalTableImpl(), fixPortNumber(), gather_result(), NdbDictionaryImpl::get_local_table_info(), Configuration::get_mgmd_host(), MgmApiSession::get_nodeid(), MgmtSrvr::getBlockNumber(), Ndb::getCatalogName(), NdbTableImpl::getColumn(), MgmApiSession::getConfig_common(), MgmApiSession::getConnectionParameter(), NdbDictionary::Column::getDefaultValue(), ConfigRetriever::getErrorString(), NdbDictionaryImpl::getIndexImpl(), NdbDictionaryImpl::getIndexTable(), NDBT_TestCaseResult::getName(), NdbEventImpl::getName(), NdbIndexImpl::getName(), NdbTableImpl::getName(), NdbDictionary::Column::getName(), NdbTransaction::getNdbIndexOperation(), Ndb::getSchemaName(), NdbDictInterface::getTable(), NdbIndexImpl::getTable(), NdbOperation::getTableName(), NdbEventImpl::getTableName(), Logger::info(), OpenFiles::insert(), insert_file(), Ndb::internalize_index_name(), Ndb::internalize_table_name(), NdbDictionaryImpl::invalidateObject(), NdbDictInterface::listObjects(), CPCDAPISession::listProcesses(), CPCD::loadProcessList(), Ndb_mgmd_event_service::log(), main(), MgmtSrvr::MgmtSrvr(), ndb_mgm_alloc_nodeid(), ndb_mgm_call(), ndb_mgm_dump_state(), ndb_mgm_enter_single_user(), ndb_mgm_insert_error(), ndb_mgm_listen_event_internal(), ndb_mgm_log_signals(), ndb_mgm_restart2(), ndb_mgm_set_clusterlog_loglevel(), ndb_mgm_set_clusterlog_severity_filter(), ndb_mgm_set_loglevel_node(), ndb_mgm_set_trace(), ndb_mgm_start(), ndb_mgm_start_backup(), ndb_mgm_start_signallog(), ndb_mgm_stop2(), ndb_mgm_stop_signallog(), NDBT_TestCase::NDBT_TestCase(), Ndb::opTupleIdOnNdb(), CPCD::Process::print(), GlobalDictCache::printCache(), printproc(), CPCD::Process::Process(), GlobalDictCache::put(), read_test_case(), MgmtSrvr::readConfig(), LocalConfig::readConnectString(), LocalConfig::readFile(), UtilTransactions::readRowFromTableAndIndex(), GlobalDictCache::release(), NdbDictionaryImpl::removeCachedObject(), run_create_pk_index(), run_create_pk_index_drop(), run_index_dk(), runTableRename(), runTableRenameNF(), runTableRenameSR(), runTestMaxTransaction(), MgmtSrvr::saveConfig(), CPCD::saveProcessList(), set_ulimit(), FileLogHandler::setFilename(), FileLogHandler::setMaxFiles(), FileLogHandler::setMaxSize(), setup_config(), setup_hosts(), setup_test_case(), NdbOperation::setValue(), split(), MgmtSrvr::start(), CPCD::Process::start(), SimpleCpcClient::start_process(), start_process(), MgmtSrvr::startEventLog(), SimpleCpcClient::stop_process(), stop_process(), SimpleCpcClient::undefine_process(), NdbImpl::update_prefix(), update_status(), UtilTransactions::verifyOrderedIndex(), and Logger::warning().

00193 {
00194   return m_chr;
00195 }

bool BaseString::empty  )  const [inline]
 

Checks if the string is empty.

Definition at line 204 of file BaseString.hpp.

References m_len.

Referenced by NdbDictInterface::createOrAlterTable(), CPCD::Process::do_exec(), NdbTableImpl::getName(), and setup_config().

00205 {
00206   return m_len == 0;
00207 }

ssize_t BaseString::indexOf char  c  ) 
 

Returns the index of the first occurance of the character c.

c character to look for

Returns:
index of character, of -1 if no character found

Definition at line 200 of file BaseString.cpp.

References m_chr, NULL, p, and strchr().

00200                           {
00201     char *p;
00202     p = strchr(m_chr, c);
00203     if(p == NULL)
00204         return -1;
00205     return (ssize_t)(p-m_chr);
00206 }

ssize_t BaseString::lastIndexOf char  c  ) 
 

Returns the index of the last occurance of the character c.

c character to look for

Returns:
index of character, of -1 if no character found

Definition at line 209 of file BaseString.cpp.

References m_chr, NULL, p, and strrchr().

00209                               {
00210     char *p;
00211     p = strrchr(m_chr, c);
00212     if(p == NULL)
00213         return -1;
00214     return (ssize_t)(p-m_chr);
00215 }

unsigned BaseString::length  )  const [inline]
 

Returns the length of the string.

Definition at line 198 of file BaseString.hpp.

References m_len.

Referenced by MgmtSrvr::alloc_node_id(), base64_decode(), Config::change(), check_node_vs_replicas(), NdbTableImpl::getColumn(), MgmApiSession::getConfig_common(), NdbDictionaryImpl::getIndex(), NdbDictInterface::getTable(), insert_file(), NdbDictInterface::listObjects(), ndb_tolower(), ndb_toupper(), read_test_case(), LocalConfig::readFile(), runTestMaxTransaction(), setup_config(), start_process(), MgmtSrvr::startEventLog(), and substr().

00199 {
00200   return m_len;
00201 }

BaseString & BaseString::ndb_tolower  )  [inline]
 

Convert to lowercase.

Definition at line 217 of file BaseString.hpp.

References length(), and m_chr.

00217                         {
00218   for(unsigned i = 0; i < length(); i++)
00219     m_chr[i] = tolower(m_chr[i]);
00220   return *this;
00221 }

BaseString & BaseString::ndb_toupper  )  [inline]
 

Convert to uppercase.

Definition at line 210 of file BaseString.hpp.

References length(), and m_chr.

00210                         {
00211   for(unsigned i = 0; i < length(); i++)
00212     m_chr[i] = toupper(m_chr[i]);
00213   return *this;
00214 }

bool BaseString::operator!= const char *  str  )  const [inline]
 

Are two strings not equal?

Definition at line 248 of file BaseString.hpp.

References m_chr.

00249 {
00250     return strcmp(m_chr, str) != 0;
00251 }

bool BaseString::operator!= const BaseString str  )  const [inline]
 

Are two strings not equal?

Definition at line 242 of file BaseString.hpp.

References m_chr.

00243 {
00244     return strcmp(m_chr, str.m_chr)  !=  0;
00245 }

bool BaseString::operator< const BaseString str  )  const [inline]
 

Compare two strings.

Definition at line 224 of file BaseString.hpp.

References m_chr.

00225 {
00226     return strcmp(m_chr, str.m_chr) < 0;
00227 }

BaseString & BaseString::operator= const BaseString str  ) 
 

Assignment operator.

Definition at line 168 of file BaseString.cpp.

References assign().

00169 {
00170     if (this != &str) {
00171         this->assign(str);
00172     }
00173     return *this;
00174 }

bool BaseString::operator== const char *  str  )  const [inline]
 

Are two strings equal?

Definition at line 236 of file BaseString.hpp.

References m_chr.

00237 {
00238     return strcmp(m_chr, str) == 0;
00239 }

bool BaseString::operator== const BaseString str  )  const [inline]
 

Are two strings equal?

Definition at line 230 of file BaseString.hpp.

References m_chr.

00231 {
00232     return strcmp(m_chr, str.m_chr)  ==  0;
00233 }

int BaseString::snprintf char *  str,
size_t  size,
const char *  format,
  ...
[static]
 

snprintf on some platforms need special treatment

Definition at line 346 of file BaseString.cpp.

References basestring_vsnprintf().

Referenced by add_a_connection(), SimulatedBlock::addRecSignalImpl(), SimulatedBlock::allocRecord(), Configuration::calcSizeAlt(), Qmgr::checkStartInterface(), Properties::contains(), create_index(), FileLogHandler::createNewFile(), NdbDictInterface::createOrAlterTable(), createOrderedPkIndex(), createPkIndex(), createRandomIndex_Drop(), createTables(), AsyncFile::doStart(), doTransaction_T1(), drop_index(), Qmgr::execCM_REGCONF(), Dblqh::execDEBUG_SIG(), Dbdih::execDUMP_STATE_ORD(), Dbdih::execREAD_NODESCONF(), NdbBackup::execRestore(), Ndbcntr::execSYSTEM_ERROR(), SimulatedBlock::executeFunction(), File_class::File_class(), fixExtConnection(), fixNodeHostname(), ErrorReporter::formatMessage(), ErrorReporter::formatTimeStampString(), Properties::get(), BackupRestore::get_table(), getBlockName(), ConfigRetriever::getConfig(), Properties::getCopy(), NDBT_TestSuite::getDate(), LogHandler::getDefaultHeader(), MgmtSrvr::getErrorText(), ArbitCode::getErrText(), SignalCounter::getText(), EventLogger::getText(), ArbitTicket::getText(), getTextArbitResult(), getTextArbitState(), getTextBackupAborted(), getTextBackupCompleted(), getTextBackupFailedToStart(), getTextBackupStarted(), getTextCM_REGCONF(), getTextCM_REGREF(), getTextCommunicationClosed(), getTextCommunicationOpened(), getTextConnected(), getTextConnectedApiVersion(), getTextCreateLogBytes(), getTextDeadDueToHeartbeat(), getTextDisconnected(), getTextFIND_NEIGHBOURS(), getTextGCP_TakeoverCompleted(), getTextGCP_TakeoverStarted(), getTextGlobalCheckpointCompleted(), getTextGlobalCheckpointStarted(), getTextInfoEvent(), getTextJobStatistic(), getTextLCP_TakeoverCompleted(), getTextLCP_TakeoverStarted(), getTextLCPFragmentCompleted(), getTextLCPStoppedInCalcKeepGci(), getTextLocalCheckpointCompleted(), getTextLocalCheckpointStarted(), getTextMemoryUsage(), getTextMissedHeartbeat(), getTextNDBStartCompleted(), getTextNDBStartStarted(), getTextNDBStopAborted(), getTextNDBStopStarted(), getTextNODE_FAILREP(), getTextNodeFailCompleted(), getTextNR_CopyDict(), getTextNR_CopyDistr(), getTextNR_CopyFragDone(), getTextNR_CopyFragsCompleted(), getTextNR_CopyFragsStarted(), getTextOperationReportCounters(), getTextReceiveBytesStatistic(), getTextSendBytesStatistic(), getTextSentHeartbeat(), getTextStartLog(), getTextStartPhaseCompleted(), getTextStartREDOLog(), getTextSTTORRYRecieved(), getTextTableCreated(), getTextTransporterError(), getTextTransReportCounters(), getTextUndoLogBlocked(), getTextUNDORecordsExecuted(), getTextWarningEvent(), LogHandler::getTimeAsString(), NDBT_TestCaseResult::getTimeStr(), Properties::getTypeOf(), ErrorReporter::handleAssert(), handler_error(), ErrorReporter::handleThreadAssert(), LocalConfig::init(), Filename::init(), main(), LocalConfig::makeConnectString(), ndb_mgm_connect(), File_class::open(), InitConfigFileParser::parseConfig(), Properties::print(), print(), printCREATE_TRIG_REQ(), NDBT_TestCaseImpl1::printTestResult(), SimulatedBlock::progError(), propToString(), Properties::put(), Properties::put64(), readArguments(), LocalConfig::readFile(), CPCD::Process::readPid(), AsyncFile::rmrfReq(), runCreateInvalidTables(), runCreateMaxTables(), runCreateResultTable(), runDropMaxTables(), runPkSizes(), runUniqueNullTransactions(), CPCD::saveProcessList(), Dbdih::selectMasterCandidateAndSend(), Dbtc::sendAbortedAfterTimeout(), Backup::sendCreateTrig(), Backup::sendDropTrig(), Filename::set(), setAttrNames(), BackupFile::setCtlFile(), BackupFile::setDataFile(), BackupFile::setLogFile(), BackupFile::setName(), setTableNames(), SimulatedBlock::signal_error(), SimulatedBlock::SimulatedBlock(), Dbdih::startFragment(), NDBT_TestCaseImpl1::startStepInThread(), CPCD::Process::stop(), InitConfigFileParser::storeSection(), Qmgr::systemErrorBecauseOtherNodeFailed(), test_snprintf(), transformComputer(), transformConnection(), transformExternalSystem(), transformExtNode(), transformNode(), transformSystem(), NdbGrep::verify(), ConfigRetriever::verifyConfig(), and CPCD::Process::writePid().

00347 {
00348   va_list ap;
00349   va_start(ap, format);
00350   int ret= basestring_vsnprintf(str, size, format, ap);
00351   va_end(ap);
00352   return(ret);
00353 }

int BaseString::split Vector< BaseString > &  vector,
const BaseString separator = BaseString(" "),
int  maxSize = -1
const
 

Split a string into a vector of strings. Separate the string where any character included in separator exists. Maximally maxSize entries are added to the vector, if more separators exist in the string, the remainder of the string will be appended to the last entry in the vector. The vector will not be cleared, so any existing strings in the vector will remain.

Parameters:
separator characters separating the entries
vector where the separated strings will be stored
maximum number of strings extracted
Returns:
the number of string added to the vector

Definition at line 177 of file BaseString.cpp.

References BaseString(), c_str(), free, int, len, m_chr, Vector< T >::push_back(), Vector< T >::size(), start, strchr(), and strdup().

Referenced by add_host(), add_hosts(), Logger::addHandler(), CPCD::Process::do_exec(), BackupRestore::endOfTables(), CommandInterpreter::executeEventReporting(), CommandInterpreter::executeLogLevel(), insert(), insert_row(), main(), ndb_mgm_get_status(), LogHandler::parseParams(), read_test_case(), set_ulimit(), setup_config(), and BackupRestore::table().

00179                                      {
00180     char *str = strdup(m_chr);
00181     int i, start, len, num = 0;
00182     len = strlen(str);
00183     for(start = i = 0;
00184         (i <= len) && ( (maxSize<0) || ((int)v.size()<=maxSize-1) );
00185         i++) {
00186         if(strchr(separator.c_str(), str[i]) || i == len) {
00187             if(maxSize < 0 || (int)v.size() < maxSize-1)
00188                 str[i] = '\0';
00189             v.push_back(BaseString(str+start));
00190             num++;
00191             start = i+1;
00192         }
00193     }
00194     free(str);
00195 
00196     return num;
00197 }

BaseString BaseString::substr ssize_t  start,
ssize_t  stop = -1
 

Returns a subset of a string

Parameters:
start index of first character
stop index of last character
Returns:
a new string

Definition at line 218 of file BaseString.cpp.

References assign(), BaseString(), len, length(), and m_chr.

Referenced by start_process().

00218                                               {
00219     if(stop < 0)
00220         stop = length();
00221     ssize_t len = stop-start;
00222     if(len <= 0)
00223         return BaseString("");
00224     BaseString s;
00225     s.assign(m_chr+start, len);
00226     return s;
00227 }

char * BaseString::trim char *  src,
const char *  delim
[static]
 

Trim string from delim

Definition at line 321 of file BaseString.cpp.

References len, memmove, pos(), and strchr().

00321                                               {
00322     int len = strlen(str) - 1;
00323     for(; len > 0 && strchr(delim, str[len]); len--);
00324     
00325     int pos = 0;
00326     for(; pos <= len && strchr(delim, str[pos]); pos++);
00327     
00328     if(pos > len){
00329         str[0] = 0;
00330         return 0;
00331     } else {
00332         memmove(str, &str[pos], len - pos + 1);
00333         str[len-pos+1] = 0;
00334     }
00335     
00336     return str;
00337 }

BaseString & BaseString::trim const char *  delim = " \t"  ) 
 

Trim string from delim

Definition at line 314 of file BaseString.cpp.

References m_chr, and m_len.

Referenced by CommandInterpreter::execute_impl(), insert(), insert_row(), ndb_mgm_get_status(), read_test_case(), LocalConfig::readFile(), and setup_config().

00314                                   {
00315     trim(m_chr, delim);
00316     m_len = strlen(m_chr);
00317     return * this;
00318 }

int BaseString::vsnprintf char *  str,
size_t  size,
const char *  format,
va_list  ap
[static]
 

Definition at line 340 of file BaseString.cpp.

References basestring_vsnprintf().

Referenced by chkerror(), fatal(), fatal_dict(), SimulatedBlock::infoEvent(), Logger::log(), ndberror(), ndbout_c(), InitConfigFileParser::Context::reportError(), InitConfigFileParser::Context::reportWarning(), setError(), vprint_socket(), vprintln_socket(), and SimulatedBlock::warningEvent().

00341 {
00342   return(basestring_vsnprintf(str, size, format, ap));
00343 }


Field Documentation

char* BaseString::m_chr [private]
 

Definition at line 187 of file BaseString.hpp.

Referenced by append(), assfmt(), assign(), BaseString(), c_str(), indexOf(), lastIndexOf(), ndb_tolower(), ndb_toupper(), operator!=(), operator<(), operator==(), split(), substr(), trim(), and ~BaseString().

unsigned BaseString::m_len [private]
 

Definition at line 188 of file BaseString.hpp.

Referenced by append(), assfmt(), assign(), BaseString(), empty(), length(), and trim().


The documentation for this class was generated from the following files:
Generated on Wed Jul 20 21:10:54 2005 for MySQL 5.0.9 Beta by  doxygen 1.4.3