本文整理汇总了C++中TextLine::SetSourceInfo方法的典型用法代码示例。如果您正苦于以下问题:C++ TextLine::SetSourceInfo方法的具体用法?C++ TextLine::SetSourceInfo怎么用?C++ TextLine::SetSourceInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextLine
的用法示例。
在下文中一共展示了TextLine::SetSourceInfo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Test
//.........这里部分代码省略.........
assert (0 == strcmp (tl._pData, "howdy"));
//
// copy ctor
//
TextLine tl2 = tl;
assert (tl2._pStorage);
assert (tl2._pData);
assert (tl2._pData >= tl._pStorage);
assert (tl2._numAllocated);
assert (tl2._numAllocated > strlen ("howdy"));
assert (0 == strcmp (tl2._pData, "howdy"));
//
// op=
//
TextLine tl3;
tl3 = tl;
assert (tl3._pStorage);
assert (tl3._pData);
assert (tl3._pData >= tl._pStorage);
assert (tl3._numAllocated);
assert (tl3._numAllocated > strlen ("howdy"));
assert (0 == strcmp (tl3._pData, "howdy"));
//
// GetLength()
//
assert (5 == tl.GetLength());
//
// Append()
//
bool stat;
stat = tl.Append ('!');
assert (stat);
assert (0 == strcmp (tl._pData, "howdy!"));
stat = tl.Append ('\\');
assert (stat);
assert (0 == strcmp (tl._pData, "howdy!\\"));
stat = tl.Append ('\n');
assert (stat);
assert (0 == strcmp (tl._pData, "howdy!\\\n"));
// we should be able to add chars after escaped newline
stat = tl.Append (' ');
assert (stat);
assert (0 == strcmp (tl._pData, "howdy!\\\n "));
stat = tl.Append ('\n');
assert (stat);
assert (0 == strcmp (tl._pData, "howdy!\\\n \n"));
// we should not be able to add chars after non-escaped newline
stat = tl.Append ('x');
assert (! stat);
assert (0 == strcmp (tl._pData, "howdy!\\\n \n"));
stat = tl.Append ('y');
assert (! stat);
assert (0 == strcmp (tl._pData, "howdy!\\\n \n"));
//
// Consume()
//
char c;
stat = tl2.Consume (c);
assert (stat);
assert ('h' == c);
stat = tl2.Consume (c);
assert (stat);
assert ('o' == c);
stat = tl2.Consume (c);
assert (stat);
assert ('w' == c);
stat = tl2.Consume (c);
assert (stat);
assert ('d' == c);
stat = tl2.Consume (c);
assert (stat);
assert ('y' == c);
stat = tl2.Consume (c);
assert (!stat);
stat = tl2.Consume (c);
assert (!stat);
assert (! tl2.GetLength());
//
// Set/GetSourceInfo()
//
SourceInfo si1 ("this-file", 42);
SourceInfo si2;
si2 = tl.GetSourceInfo ();
assert (0 == si2.GetLineNumber());
assert (0 == si2.GetFileName());
tl.SetSourceInfo (si1);
si2 = tl.GetSourceInfo ();
assert (42 == si2.GetLineNumber());
assert (0 == strcmp ("this-file", si2.GetFileName()));
}