本文整理汇总了C++中DString::Length方法的典型用法代码示例。如果您正苦于以下问题:C++ DString::Length方法的具体用法?C++ DString::Length怎么用?C++ DString::Length使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DString
的用法示例。
在下文中一共展示了DString::Length方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ASSERT
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// PBook::ReadFile(): read in a file.
errorT
PBook::ReadFile ()
{
ASSERT (FileName != NULL);
ReadOnly = false;
MFile fp;
if (fp.Open (FileName, FMODE_Both) != OK) {
ReadOnly = true;
if (fp.Open (FileName, FMODE_ReadOnly) != OK) {
return ERROR_FileOpen;
}
}
LineCount = 1;
Position * pos = new Position;
DString * line = new DString;
ReadLine(line, &fp);
DString dstr;
while (line->Length() || ! fp.EndOfFile()) {
if (pos->ReadFromFEN (line->Data()) != OK) {
fprintf (stderr, "Error reading line: %u\n", LineCount);
LineCount++;
line->Clear();
ReadLine(line, &fp);
continue;
//exit (1);
}
char * s = (char *) line->Data();
// Skip over first four fields, which were the position:
while (*s == ' ') { s++; }
for (uint i=0; i < 4; i++) {
while (*s != ' ' && *s != 0) { s++; }
while (*s == ' ') { s++; }
}
// Now process each field in turn:
while (*s == ';' || *s == ' ') { s++; }
dstr.Clear();
while (*s != 0) {
while (*s == ';' || *s == ' ') { s++; }
bool seenCode = false;
while (*s != ';' && *s != 0) {
seenCode = true;
char ch = *s;
// Check for backslash (escape) character:
if (ch == '\\') {
s++;
ch = *s;
// "\s" -> semicolon within a field:
if (ch == 's') { ch = ';'; }
}
dstr.AddChar (ch);
s++;
}
if (seenCode) { dstr.AddChar ('\n'); }
}
if (Insert (pos, dstr.Data()) != OK) {
//fprintf (stderr, "Warning: position already exists! Line %u\n",
// LineCount);
}
LineCount++;
line->Clear();
ReadLine(line, &fp);
}
delete pos;
delete line;
Altered = false;
NextIndex = NodeListCount - 1;
return OK;
}