当前位置: 首页>>代码示例>>C++>>正文


C++ TextLine::SetSourceInfo方法代码示例

本文整理汇总了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()));
}
开发者ID:mcanthony,项目名称:aaf,代码行数:101,代码来源:TextLineTest.cpp


注:本文中的TextLine::SetSourceInfo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。