本文整理汇总了C++中ustring::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ ustring::clear方法的具体用法?C++ ustring::clear怎么用?C++ ustring::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ustring
的用法示例。
在下文中一共展示了ustring::clear方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: notes_read_one_from_file
void notes_read_one_from_file (int id, ustring& note, ustring& project, ustring& references, ustring& category, int& date_created, ustring& user_created, int& date_modified, ustring& logbook)
{
note.clear();
logbook.clear();
ustring filename = notes_file_name (id);
ReadText rt (filename, true, false);
bool logbook_indicator_encountered = false;
for (unsigned int i = 0; i < rt.lines.size(); i++) {
ustring line = rt.lines[i];
if (i == 0) {
// Retrieve date created.
date_created = convert_to_int (line);
}
else if (i == 1) {
// Retrieve user who created it.
user_created = line;
}
else if (i == 2) {
// Retrieve references.
references = line;
}
else if (i == 3) {
// Retrieve category.
category = line;
}
else if (i == 4) {
// Retrieve project.
project = line;
}
else if (i == 5) {
// Retrieve date modified.
date_modified = convert_to_int (line);
}
else if (line == notes_logbook_line ()) {
logbook_indicator_encountered = true;
}
else {
if (logbook_indicator_encountered) {
if (!logbook.empty()) logbook.append ("\n");
logbook.append (line);
} else {
if (!note.empty()) note.append ("\n");
note.append (line);
}
}
}
note = trim (note);
logbook = trim (logbook);
}
示例2: processAllMessages
/*
* Extracts and processes all messages inside the specified buffer.
* @throw CDCReading Exception
*/
void CDCImplPrivate::processAllMessages(ustring& msgBuffer) {
if (msgBuffer.empty()) {
return;
}
ParsedMessage parsedMessage = parseNextMessage(msgBuffer);
while ( parsedMessage.parseResult.resultType != PARSE_NOT_COMPLETE ) {
if ( parsedMessage.parseResult.resultType == PARSE_BAD_FORMAT ) {
// throw all bytes from the buffer up to next 0x0D
size_t endMsgPos = msgBuffer.find(0x0D, parsedMessage.parseResult.lastPosition);
if (endMsgPos == string::npos) {
msgBuffer.clear();
} else {
msgBuffer.erase(0, endMsgPos+1);
}
setLastReceptionError("Bad message format");
} else {
msgBuffer.erase(0, parsedMessage.parseResult.lastPosition+1);
processMessage(parsedMessage);
}
if (msgBuffer.empty()) {
return;
}
parsedMessage = parseNextMessage(msgBuffer);
}
}
示例3: codeend
void
OSOReaderToMaster::codemarker (const char *name)
{
m_sourcefile.clear();
int nextop = (int) m_master->m_ops.size();
codeend (); // Mark the end spot, if we were parsing ops before
m_codesection = ustring (name);
m_codesym = m_master->findsymbol (m_codesection);
if (m_codesym >= 0)
m_master->symbol(m_codesym)->initbegin (nextop);
#if 0
std::cerr << "Read code marker " << m_codesection
<< " at instruction " << nextop
<< ", sym " << m_codesym
<< " (" << (m_codesym >= 0 ? m_master->symbol(m_codesym)->name() : ustring()) << ")"
<< "\n";
#endif
if (m_codesection == "___main___") {
m_master->m_maincodebegin = nextop;
} else if (m_codesym < 0) {
m_shadingsys.error ("Parsing shader %s: don't know what to do with code section \"%s\"",
m_master->shadername().c_str(), name);
m_errors = true;
}
}
示例4: parse_memory
bool
OSOReaderToMaster::parse_memory (const std::string &oso)
{
m_master->m_osofilename = "<none>";
m_master->m_maincodebegin = 0;
m_master->m_maincodeend = 0;
m_codesection.clear ();
m_codesym = -1;
return OSOReader::parse_memory (oso) && ! m_errors;
}
示例5: parse_file
bool
OSOReaderToMaster::parse_file (const std::string &filename)
{
m_master->m_osofilename = filename;
m_master->m_maincodebegin = 0;
m_master->m_maincodeend = 0;
m_codesection.clear ();
m_codesym = -1;
return OSOReader::parse_file (filename) && ! m_errors;
}
示例6: usfm_extract_marker_with_forwardslash
ustring CheckValidateUsfm::usfm_extract_marker_with_forwardslash(ustring & line)
// Returns the usfm marker from the line, but only if it starts with a forward slash
{
ustring returnvalue;
line = trim(line);
size_t offposition;
offposition = line.find("/");
if (offposition != string::npos) {
line.erase(0, offposition);
size_t endposition;
endposition = line.find_first_of(" *", 1);
if (endposition != string::npos) {
returnvalue = line.substr(0, ++endposition);
line.erase(0, endposition);
} else {
returnvalue = line;
line.clear();
}
}
if (returnvalue.length() > 0)
returnvalue.erase(0, 1); // Remove slash.
return trim(returnvalue);
}
示例7: CategorizeOneLine
void CategorizeLine::CategorizeOneLine(ustring &line)
{
// Extract the marker for this line.
ustring marker = usfm_extract_marker(line);
// Marker to work with for this line.
ustring actual_marker;
if (marker.empty())
actual_marker = previous_marker;
else
actual_marker = marker;
// Re-insert bible note markers.
if (marker == footnote_opener(false)) {
line.insert(0, footnote_opener(true));
}
if (marker == endnote_opener(false)) {
line.insert(0, endnote_opener(true));
}
if (marker == xref_opener(false)) {
line.insert(0, xref_opener(true));
}
// Subdivide the line into categories.
// Each category removes something from this content, until it is empty.
// Footnotes, endnotes.
if (!line.empty()) {
size_t beginposition, endposition;
ustring opening_marker = footnote_opener(true);
ustring closing_marker = footnote_closer();
beginposition = line.find(opening_marker);
endposition = line.find(closing_marker);
if (endposition == string::npos) {
// BUG: In main editor, the chapter lines are all combined into a single long ustring.
// This means that footnotes that are split across lines are "fixed." But that is not
// the case when just looking at a single verse \\v line that has a footnote started
// but not finished. Fixed 2/15/2018
endposition = line.length() - 1;
}
while (beginposition != string::npos) {
assert(beginposition <= endposition); // this cannot be above the while stmt...beginposition == string::npos if no marker is found
ustring notetext;
notetext = line.substr(beginposition + opening_marker.length(), endposition - beginposition - closing_marker.length());
line.erase(beginposition, endposition - beginposition + closing_marker.length());
clear_out_any_marker(notetext);
append_text(note, notetext);
beginposition = line.find(opening_marker);
endposition = line.find(closing_marker);
}
opening_marker = endnote_opener(true);
closing_marker = endnote_closer();
beginposition = line.find(opening_marker);
endposition = line.find(closing_marker);
while ((beginposition != string::npos) && (endposition != string::npos)) {
ustring notetext;
notetext = line.substr(beginposition + opening_marker.length(), endposition - beginposition - closing_marker.length());
line.erase(beginposition, endposition - beginposition + closing_marker.length());
clear_out_any_marker(notetext);
append_text(note, notetext);
beginposition = line.find(opening_marker);
endposition = line.find(closing_marker);
}
}
// Crossreferences.
if (!line.empty()) {
size_t beginposition, endposition;
ustring opening_marker = xref_opener(true);
ustring closing_marker = xref_closer();
beginposition = line.find(opening_marker);
endposition = line.find(closing_marker);
while ((beginposition != string::npos) && (endposition != string::npos)) {
ustring referencetext;
referencetext = line.substr(beginposition + opening_marker.length(), endposition - beginposition - closing_marker.length());
line.erase(beginposition, endposition - beginposition + closing_marker.length());
clear_out_any_marker(referencetext);
append_text(ref, referencetext);
beginposition = line.find(opening_marker);
endposition = line.find(closing_marker);
}
}
// Identifiers.
if (!line.empty()) {
if (is_id_marker(actual_marker)) {
clear_out_any_marker(line);
append_text(id, line);
line.clear();
}
}
// Introduction elements.
if (!line.empty()) {
if (is_intro_marker(actual_marker)) {
clear_out_any_marker(line);
append_text(intro, line);
line.clear();
}
}
// Headings, titles, labels.
if (!line.empty()) {
if (is_head_marker(actual_marker)) {
clear_out_any_marker(line);
//.........这里部分代码省略.........
示例8: buildAddressFromKeys
ustring PubAddr::buildAddressFromKeys(ustring Skey, ustring Ekey, int stream, int version)
{
CryptoPP::SHA512 hash;
byte digest[CryptoPP::SHA512::DIGESTSIZE];
byte digest1[CryptoPP::SHA512::DIGESTSIZE];
ustring buffer;
if (Skey.size() == 64)
{
ustring tmp = Skey;
Skey.clear();
Skey += 0x04;
Skey += tmp;
}
if (Ekey.size() == 64)
{
ustring tmp = Ekey;
Ekey.clear();
Ekey += 0x04;
Ekey += tmp;
}
buffer += Skey;
buffer += Ekey;
hash.CalculateDigest(digest, (byte*)buffer.c_str(), buffer.length());
CryptoPP::RIPEMD160 hash2;
byte digest2[CryptoPP::RIPEMD160::DIGESTSIZE];
hash2.CalculateDigest(digest2, digest, sizeof digest);
ustring ripe;
int i = 0;
while (digest2[i] == 0x00)
i++;
while (i < sizeof digest2)
{
ripe += digest2[i];
i++;
}
ustring tmp;
tmp.appendVarInt_B(version);
tmp.appendVarInt_B(stream);
tmp += ripe;
//generate checksum
hash.CalculateDigest(digest, (byte*)tmp.c_str(), tmp.length());
hash.CalculateDigest(digest1, digest, sizeof digest);
tmp += digest1[0];
tmp += digest1[1];
tmp += digest1[2];
tmp += digest1[3];
//convert to base58
char * ret = new char[256];
size_t size = 256;
if (!b58enc(ret, &size, tmp.c_str(), tmp.size()))
{
delete[] ret;
throw runtime_error("cannot encode base58");
}
ustring addr;
addr.fromString(string("BM-"));
addr.append((unsigned char*)ret, size-1);
delete[] ret;
return addr;
}