本文整理汇总了C++中zstring类的典型用法代码示例。如果您正苦于以下问题:C++ zstring类的具体用法?C++ zstring怎么用?C++ zstring使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了zstring类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: result
zstring zstring::replace(zstring const& src, zstring const& dst) const {
zstring result(m_encoding);
if (length() < src.length()) {
return zstring(*this);
}
if (src.length() == 0) {
return zstring(*this);
}
bool found = false;
for (unsigned i = 0; i < length(); ++i) {
bool eq = !found && i + src.length() <= length();
for (unsigned j = 0; eq && j < src.length(); ++j) {
eq = m_buffer[i+j] == src[j];
}
if (eq) {
result.m_buffer.append(dst.m_buffer);
found = true;
i += src.length() - 1;
}
else {
result.m_buffer.push_back(m_buffer[i]);
}
}
return result;
}
示例2: if
bool operator<(const zstring& lhs, const zstring& rhs) {
// This has the same semantics as strcmp()
unsigned len = lhs.length();
if (rhs.length() < len) {
len = rhs.length();
}
for (unsigned i = 0; i < len; ++i) {
unsigned Li = lhs[i];
unsigned Ri = rhs[i];
if (Li < Ri) {
return true;
} else if (Li > Ri) {
return false;
} else {
continue;
}
}
// at this point, all compared characters are equal,
// so decide based on the relative lengths
if (lhs.length() < rhs.length()) {
return true;
} else {
return false;
}
}
示例3: suffixof
bool zstring::suffixof(zstring const& other) const {
if (length() > other.length()) return false;
bool suffix = true;
for (unsigned i = 0; suffix && i < length(); ++i) {
suffix = m_buffer[length()-i-1] == other[other.length()-i-1];
}
return suffix;
}
示例4: contains
bool zstring::contains(zstring const& other) const {
if (other.length() > length()) return false;
unsigned last = length() - other.length();
bool cont = false;
for (unsigned i = 0; !cont && i <= last; ++i) {
cont = true;
for (unsigned j = 0; cont && j < other.length(); ++j) {
cont = other[j] == m_buffer[j+i];
}
}
return cont;
}
示例5: beginVisitFlworLetVariable
void PrinterVisitor::
beginVisitFlworLetVariable( bool materialize, zstring const &varName,
vector<PlanIter_t> const &varRefs ) {
thePrinter.startBeginVisit( "LetVariable", ++theId );
thePrinter.addAttribute( "name", varName.str() );
thePrinter.addAttribute( "materialize", materialize ? "true" : "false");
ostringstream str;
vector<PlanIter_t>::size_type const numRefs = varRefs.size();
for ( vector<PlanIter_t>::size_type i = 0; i < numRefs; ++i ) {
#ifndef NDEBUG
str << varRefs[i]->getId();
#else
str << varRefs[i].getp();
#endif
if ( i < numRefs - 1 )
str << ' ';
}
if ( !Properties::instance().getNoTreeIDs() )
thePrinter.addAttribute( "referenced-by", str.str() );
thePrinter.endBeginVisit( theId );
}
示例6: beginVisitFlworForVariable
void PrinterVisitor::
beginVisitFlworForVariable( zstring const &varName,
vector<PlanIter_t> const &varRefs,
vector<PlanIter_t> const &posRefs ) {
thePrinter.startBeginVisit( "ForVariable", ++theId );
thePrinter.addAttribute( "name", varName.str() );
ostringstream ref_oss;
vector<PlanIter_t>::size_type const numRefs = varRefs.size();
for ( vector<PlanIter_t>::size_type i = 0; i < numRefs; ++i ) {
#ifndef NDEBUG
ref_oss << varRefs[i]->getId();
#else
ref_oss << varRefs[i].getp();
#endif
if ( i < numRefs - 1 )
ref_oss << ' ';
}
if ( !Properties::instance().getNoTreeIDs() )
thePrinter.addAttribute( "referenced-by", ref_oss.str() );
if ( !posRefs.empty() ) {
string const ref_s( var_refs( posRefs ) );
if ( !Properties::instance().getNoTreeIDs() )
thePrinter.addAttribute( "pos-referenced-by", ref_s );
}
thePrinter.endBeginVisit( theId );
}
示例7:
zstring::zstring(const zstring &rzw)
{
const char *rstr;rstr=rzw.getString();
mem_data.mem_length=(unsigned int)strlen(rstr);
mem_data.mem_string=(char *)malloc(mem_data.mem_length+1);
unsigned int i;for(i=0;i<=mem_data.mem_length;i++)mem_data.mem_string[i]='\0';
strcpy(mem_data.mem_string,rstr);
mem_data.mem_erchar=rzw.mem_data.mem_erchar;
if(rzw.Buffer!=0)
{
unsigned int len=(unsigned int)strlen(rzw.Buffer);
Buffer=(char *)malloc(len+1);
unsigned int i;for(i=0;i<=len;i++)Buffer[i]='\0';
strcpy(this->Buffer,rzw.Buffer);
}
else {this->Buffer=0;}
mem_data.mem_encryptkey=0;
mem_data.mem_copy=0;
mem_data.mem_ifile=0;
mem_data.mem_ofile=0;
#ifndef _zhuwei_ztools_NOT_USE_MFC_CLASS
mem_data.mem_ReadWatchfile=0;
mem_data.mem_WriteWatchfile=0;
mem_data.mem_runfilelock=0;
#endif
}
示例8: indexof
int zstring::indexof(zstring const& other, int offset) const {
SASSERT(offset >= 0);
if (static_cast<unsigned>(offset) == length()) return -1;
if (other.length() + offset > length()) return -1;
unsigned last = length() - other.length();
for (unsigned i = static_cast<unsigned>(offset); i <= last; ++i) {
bool prefix = true;
for (unsigned j = 0; prefix && j < other.length(); ++j) {
prefix = m_buffer[i + j] == other[j];
}
if (prefix) {
return static_cast<int>(i);
}
}
return -1;
}
示例9: compile
PlanIter_t XQueryCompiler::compile(
std::istream& aXQuery,
const zstring& aFileName,
ulong& nextDynamicVarId)
{
audit::Event* ae = theCompilerCB->theRootSctx->get_audit_event();
zorba::audit::ScopedRecord sar(ae);
const char* lFileName = aFileName.c_str();
audit::ScopedAuditor<const char*>
filenameAudit(sar, zorba::audit::XQUERY_COMPILATION_FILENAME, lFileName);
parsenode_t lAST;
{
time::Timer lTimer;
audit::DurationAuditor
durationAudit(sar, audit::XQUERY_COMPILATION_PARSE_DURATION, lTimer);
lAST = parse(aXQuery, aFileName);
if (theCompilerCB->theConfig.lib_module &&
dynamic_cast<LibraryModule*>(lAST.getp()) != NULL)
{
lAST = createMainModule(lAST, aXQuery, aFileName);
}
}
return compile(lAST, true, nextDynamicVarId, sar);
}
示例10: prefixof
bool zstring::prefixof(zstring const& other) const {
if (length() > other.length()) return false;
bool prefix = true;
for (unsigned i = 0; prefix && i < length(); ++i) {
prefix = m_buffer[i] == other[i];
}
return prefix;
}
示例11: beginVisitWinCondVariable
void PrinterVisitor::
beginVisitWinCondVariable( zstring const &varName,
vector<PlanIter_t> const &varRefs ) {
thePrinter.startBeginVisit( "WinCondVariable", theId );
thePrinter.addAttribute( "name", varName.str() );
if ( !Properties::instance().getNoTreeIDs() )
printVarRefs( "referenced-by", varRefs );
thePrinter.endBeginVisit( theId );
}
示例12: xqdoc
void XQueryCompiler::xqdoc(
std::istream& aXQuery,
const zstring& aFileName,
store::Item_t& aResult,
const store::Item_t& aDateTime,
uint32_t aOptions)
{
parsenode_t lAST = parse(aXQuery, aFileName);
print_parsetree_xqdoc(aResult, lAST.getp(),
aFileName.c_str(), aDateTime, aOptions);
}
示例13: beginVisitFlworLetVariable
void PrinterVisitor::
beginVisitFlworLetVariable( bool materialize, zstring const &varName,
vector<PlanIter_t> const &varRefs ) {
thePrinter.startBeginVisit( "LetVariable", ++theId );
thePrinter.addAttribute( "name", varName.str() );
thePrinter.addBoolAttribute( "materialize", materialize ? true : false);
if ( !Properties::instance().getNoTreeIDs() )
printVarRefs( "referenced-by", varRefs );
thePrinter.endBeginVisit( theId );
}
示例14: getInteger
/**
* Utility function: Given a string aStr and position aPos, populate
* aInt with the integer at that position in the string. aPos will be
* updated to next character.
* @return true if an integer found, false if not.
*/
static bool
getInteger(zstring const& aStr, size_t& aPos, int& aInt)
{
char lChar;
size_t lLen = aStr.length();
size_t const lOrigPos = aPos;
aInt = 0;
while (aPos < lLen && isdigit(lChar = aStr[aPos])) {
aInt = aInt * 10 + (lChar - '0');
aPos++;
}
return (aPos != lOrigPos);
}
示例15:
bool zstring::operator==(const zstring& other) const {
// two strings are equal iff they have the same length and characters
if (length() != other.length()) {
return false;
}
for (unsigned i = 0; i < length(); ++i) {
unsigned Xi = m_buffer[i];
unsigned Yi = other[i];
if (Xi != Yi) {
return false;
}
}
return true;
}