本文整理汇总了C++中String::Begin方法的典型用法代码示例。如果您正苦于以下问题:C++ String::Begin方法的具体用法?C++ String::Begin怎么用?C++ String::Begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类String
的用法示例。
在下文中一共展示了String::Begin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LEqual
dword String::LEqual(const String& s) const
{
#ifdef CPU_64
int l = GetCount();
if(s.GetCount() != l) return 1;
const qword *qa = (const qword *)Begin();
const qword *qb = (const qword *)s.Begin();
while(l >= 8) {
if(*qa++ != *qb++) return 1;
l -= 8;
}
const dword *da = (const dword *)qa;
const dword *db = (const dword *)qb;
if((l & 4) && *da++ != *db++) return 1;
#else
int l = GetCount();
if(s.GetCount() != l) return 1;
const dword *da = (const dword *)Begin();
const dword *db = (const dword *)s.Begin();
while(l >= 4) {
if(*da++ != *db++) return 1;
l -= 4;
}
#endif
const word *wa = (const word *)da;
const word *wb = (const word *)db;
if((l & 2) && *wa++ != *wb++) return 1;
return (l & 1) ? *(const char *)wa != *(const char *)wb : 0;
}
示例2:
Url::Url(const String& base_url)
{
String url = base_url;
if (url.GetLength() == 0)
BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid URL Empty URL."));
size_t pHelper = url.Find(":");
if (pHelper != String::NPos) {
if (!ParseScheme(url.SubStr(0, pHelper)))
BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid URL Scheme."));
url = url.SubStr(pHelper + 1);
}
if (*url.Begin() != '/')
BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid URL: '/' expected after scheme."));
if (url.GetLength() == 1) {
return;
}
if (*(url.Begin() + 1) == '/') {
pHelper = url.Find("/", 2);
if (pHelper == String::NPos)
BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid URL: Missing '/' after authority."));
if (!ParseAuthority(url.SubStr(0, pHelper)))
BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid URL Authority"));
url = url.SubStr(pHelper);
}
if (*url.Begin() == '/') {
pHelper = url.FindFirstOf("#?");
if (!ParsePath(url.SubStr(1, pHelper - 1)))
BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid URL Path"));
if (pHelper != String::NPos)
url = url.SubStr(pHelper);
} else
BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid URL: Missing path."));
if (*url.Begin() == '?') {
pHelper = url.Find("#");
if (!ParseQuery(url.SubStr(1, pHelper - 1)))
BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid URL Query"));
if (pHelper != String::NPos)
url = url.SubStr(pHelper);
}
if (*url.Begin() == '#') {
if (!ParseFragment(url.SubStr(1)))
BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid URL Fragment"));
}
}
示例3: ReadMessageTest
// Read and save messages and their attachments
void ReadMessageTest(MAPIEx& mapi, const String &folderName = "") {
puts("\nRead and save message test");
MAPIFolder folder;
if (folderName.IsEmpty()) {
if(!mapi.OpenInbox(folder))
return;
} else {
if(!mapi.OpenFolder(folderName, folder)) // Instead of Inbox open selected folder
return;
}
// use SortContents to sort the messages, default is ascending by PR_MESSAGE_DELIVERY_TIME
folder.SortContents(TABLE_SORT_DESCEND);
//mapi.SetUnreadOnly();
MAPIMessage message;
while(folder.GetNextMessage(message)) {
Time receivedTime = message.GetReceivedTime();
Time submitTime = message.GetSubmitTime();
Time modifTime = message.GetLastModificationTime();
String recipients;
if (message.GetRecipients()) {
String name, email;
int type;
while (message.GetNextRecipient(name, email, type)) {
if (!recipients.IsEmpty())
recipients += "; ";
String stype;
if (type == MAPI_TO)
stype = "TO";
else if (type == MAPI_CC)
stype = "CC";
else if (type == MAPI_BCC)
stype = "BCC";
else
stype = "Unknown!";
recipients += Format("'%s' (%s)(%s)", name, email, stype.Begin());
}
}
puts(Format("Message from '%s' (%s) to %s subject '%s', received time: %s, "
"sent time: %s, modif time: %s", message.GetSenderName(),
message.GetSenderEmail(), recipients, message.GetSubject(),
Format(receivedTime), Format(submitTime), Format(modifTime)));
puts(Format("Body: %s", message.GetBody(false)));
//puts(Format("HTML: %s", message.GetHTML()));
if(message.GetAttachmentCount()) {
printf(Format("Saving attachments to %s...", MSG_ATTACHMENT_FOLDER));
message.SaveAttachment(MSG_ATTACHMENT_FOLDER);
puts("done");
}
static int num;
String fileName = "c:\\temp\\" + FormatInt(num) + ".msg";
printf(Format("Saving message to %s ...", fileName.Begin()));
message.SaveToFile(fileName);
num++;
puts("done");
}
}
示例4: VFKParseDOPLKOD
static String VFKParseDOPLKOD(String s)
{
const char *p = s;
while(*p && !(p[0] == '/' && p[1] == ' ' && p[2] == 'D' && p[3] == 'O'
&& p[4] == 'P' && p[5] == 'L' && p[6] == 'K' && p[7] == 'O' && p[8] == 'D'))
p++;
if(!*p)
return s;
while(p > s.Begin() && (byte)p[-1] <= ' ')
p--;
return s.Left(p - s.Begin());
}
示例5: End
bool String::operator==(const String& str) const
{
if (Length() != str.Length())
{
return false;
}
if (Begin() == str.Begin())
{
return true;
}
return Algo::Range::Equal(Begin(), End(), str.Begin());
}
示例6: if
bool ODBCPerformScript(const String& text, StatementExecutor& executor, Gate2<int, int> progress_canceled)
{
const char *p = text;
while(*p) {
String cmd;
while(*p && *p != ';')
if(*p == '\'') {
const char *s = p;
while(*++p && (*p != '\'' || *++p == '\''))
;
cmd.Cat(s, int(p - s));
}
else {
if(*p > ' ')
cmd.Cat(*p);
else if(!cmd.IsEmpty() && *cmd.Last() != ' ')
cmd.Cat(' ');
p++;
}
if(progress_canceled(int(p - text.Begin()), text.GetLength()))
return false;
if(!IsNull(cmd) && !executor.Execute(cmd))
return false;
if(*p == ';')
p++;
}
return true;
}
示例7: LoadConfigFile
//-----------------------------------------------------------------------------------------------------------------------------------------------------
VOID Configuration::LoadConfigFile(LPCTSTR Filename)
{
TextStream T(File::Open(Filename, FileMode::OPEN));
while(!T.EndOfStream())
{
String L = T.ReadLine();
if (L.BeginsWith("#"))
continue;
String::Iterator i = L.Find('=');
if (i != L.End())
{
String Name = L.Substr(L.Begin(), i);
String Value = L.Substr(i+1, L.End());
if (m_Schema.Contains(Name))
{
Item I = m_Schema.Get(Name);
if ((I.m_Source & ConfigurationSource::FILE) == 0)
continue;
I.m_Present = TRUE;
}
m_ConfigValues.Add(Name,Value);
}
}
}
示例8: Sqlite3PerformScript
bool Sqlite3PerformScript(const String& txt, StatementExecutor& se, Gate2<int, int> progress_canceled) {
const char *text = txt;
for(;;) {
String stmt;
while(*text <= 32 && *text > 0) text++;
if(*text == '\0') break;
for(;;) {
if(*text == '\0')
break;
if(*text == ';')
break;
else
if(*text == '\'')
text = Sqlite3ReadString(text, stmt);
else
if(*text == '\"')
text = Sqlite3ReadString(text, stmt);
else
stmt.Cat(*text++);
}
if(progress_canceled(text - txt.Begin(), txt.GetLength()))
return false;
if(!se.Execute(stmt))
return false;
if(*text) text++;
}
return true;
}
示例9: Save
bool JSONFile::Save(Stream& dest)
{
PROFILE(SaveJSONFile);
String buffer;
root.ToString(buffer);
return dest.Write(buffer.Begin().ptr, buffer.Length()) == buffer.Length();
}
示例10: Load
bool SslKey::Load(const String& data)
{
Clear();
SslStream strm;
if(!strm.OpenBuffer(data.Begin(), data.GetLength()))
return false;
return Set(PEM_read_bio_PrivateKey(strm, NULL, NULL, NULL));
}
示例11: WriteJSONString
void JSONValue::WriteJSONString(String& dest, const String& str)
{
dest += '\"';
for (String::ConstIterator it = str.Begin(); it != str.End(); ++it)
{
char c = *it;
if (c >= 0x20 && c != '\"' && c != '\\')
dest += c;
else
{
dest += '\\';
switch (c)
{
case '\"':
case '\\':
dest += c;
break;
case '\b':
dest += 'b';
break;
case '\f':
dest += 'f';
break;
case '\n':
dest += 'n';
break;
case '\r':
dest += 'r';
break;
case '\t':
dest += 't';
break;
default:
{
char buffer[6];
sprintf(buffer, "u%04x", c);
dest += (const char*)&buffer[0];
}
break;
}
}
}
dest += '\"';
}
示例12: NormalizePath
String NormalizePath(const char *path, const char *currdir)
{
String join_path;
if(!IsFullPath(path))
path = join_path = AppendFileName(currdir, path);
String out;
if(*path && path[1] == ':') {
out << path[0] << ":\\";
path += 3;
}
else
if(path[0] == '\\' && path[1] == '\\') {
out = "\\\\";
path += 2;
}
else
if(sDirSep(*path)) {
if(*currdir)
out << *currdir << ':';
out.Cat(DIR_SEP);
path++;
}
int outstart = out.GetLength();
while(*path) {
if(sDirSep(*path)) {
while(sDirSep(*path))
path++;
if(*path == '\0')
break;
if(out.IsEmpty() || *out.Last() != DIR_SEP)
out.Cat(DIR_SEP);
}
const char *b = path;
while(*path && !sDirSep(*path))
path++;
if(path - b == 1 && *b == '.')
; //no-op
else if(path - b == 2 && *b == '.' && b[1] == '.') {
const char *ob = ~out + outstart, *oe = out.End();
if(oe - 1 > ob && oe[-1] == DIR_SEP)
oe--;
while(oe > ob && oe[-1] != DIR_SEP)
oe--;
out.Trim((int)(oe - out.Begin()));
}
else
out.Cat(b, (int)(path - b));
}
return out;
}
示例13: Concat
String String::Concat(const String& str) const
{
String result;
if (HasChars() || str.HasChars())
{
result.Allocate(Length() + str.Length());
Iterator dest = Algo::Range::Copy(Begin(), End(), result.MutableBegin());
Algo::Range::Copy(str.Begin(), str.End(), dest);
}
return result;
}
示例14: MinimumValueText
String SpinBox::MinimumValueText() const
{
size_type len = 0;
(*API->SpinBox->GetSpinBoxMinimumValueText)( handle, 0, &len );
String text;
if ( len > 0 )
{
text.SetLength( len );
if ( (*API->SpinBox->GetSpinBoxMinimumValueText)( handle, text.Begin(), &len ) == api_false )
throw APIFunctionError( "GetSpinBoxMinimumValueText" );
text.ResizeToNullTerminated();
}
return text;
}
示例15: Text
String Label::Text() const
{
size_type len = 0;
(*API->Label->GetLabelText)( handle, 0, &len );
String text;
if ( len > 0 )
{
text.SetLength( len );
if ( (*API->Label->GetLabelText)( handle, text.Begin(), &len ) == api_false )
throw APIFunctionError( "GetLabelText" );
text.ResizeToNullTerminated();
}
return text;
}