本文整理汇总了C++中TArray::addSpaces方法的典型用法代码示例。如果您正苦于以下问题:C++ TArray::addSpaces方法的具体用法?C++ TArray::addSpaces怎么用?C++ TArray::addSpaces使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TArray
的用法示例。
在下文中一共展示了TArray::addSpaces方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getDebInfo
DebugInfos* getDebInfo(const char* package)
{
SymbolID_t pkgid = gSymbolTable.symbolID(package);
DebugInfos** pdsi = m_debInfos.find(pkgid);
if (pdsi != NULL)
return *pdsi;
hyu32 len = HMD_STRLEN(package);
TArray<char>* fname = new TArray<char>(len + HMD_STRLEN(DEBUGINFO_EXT) + 1);
memcpy(fname->addSpaces(len), package, len);
len = HMD_STRLEN(DEBUGINFO_EXT);
memcpy(fname->addSpaces(len), DEBUGINFO_EXT, len);
fname->add('\0');
return new DebugInfos(fname->top());
}
示例2: test_insert_remove
void test_insert_remove(void)
{
TArray<int> arr;
arr.initialize(2);
CPPUNIT_ASSERT_EQUAL((hyu32)0, arr.size());
HMD_ASSERT_HALT(arr.insert(1));
arr.insert(0) = 10;
CPPUNIT_ASSERT_EQUAL((hyu32)1, arr.size());
CPPUNIT_ASSERT_EQUAL(10, arr[0]);
arr.insert(0) = 20;
CPPUNIT_ASSERT_EQUAL((hyu32)2, arr.size());
CPPUNIT_ASSERT_EQUAL(20, arr[0]);
CPPUNIT_ASSERT_EQUAL(10, arr[1]);
arr.insert(1) = 30;
CPPUNIT_ASSERT_EQUAL((hyu32)3, arr.size());
CPPUNIT_ASSERT_EQUAL(20, arr[0]);
CPPUNIT_ASSERT_EQUAL(30, arr[1]);
CPPUNIT_ASSERT_EQUAL(10, arr[2]);
arr.insert(3) = 40;
CPPUNIT_ASSERT_EQUAL((hyu32)4, arr.size());
CPPUNIT_ASSERT_EQUAL(20, arr[0]);
CPPUNIT_ASSERT_EQUAL(30, arr[1]);
CPPUNIT_ASSERT_EQUAL(10, arr[2]);
CPPUNIT_ASSERT_EQUAL(40, arr[3]);
arr.insert(-1) = 50;
CPPUNIT_ASSERT_EQUAL((hyu32)5, arr.size());
CPPUNIT_ASSERT_EQUAL(20, arr[0]);
CPPUNIT_ASSERT_EQUAL(30, arr[1]);
CPPUNIT_ASSERT_EQUAL(10, arr[2]);
CPPUNIT_ASSERT_EQUAL(50, arr[3]);
CPPUNIT_ASSERT_EQUAL(40, arr[4]);
arr.remove(2);
CPPUNIT_ASSERT_EQUAL((hyu32)4, arr.size());
CPPUNIT_ASSERT_EQUAL(20, arr[0]);
CPPUNIT_ASSERT_EQUAL(30, arr[1]);
CPPUNIT_ASSERT_EQUAL(50, arr[2]);
CPPUNIT_ASSERT_EQUAL(40, arr[3]);
arr.remove(-3);
CPPUNIT_ASSERT_EQUAL((hyu32)3, arr.size());
CPPUNIT_ASSERT_EQUAL(20, arr[0]);
CPPUNIT_ASSERT_EQUAL(50, arr[1]);
CPPUNIT_ASSERT_EQUAL(40, arr[2]);
HMD_ASSERT_HALT(arr.remove(3));
HMD_ASSERT_HALT(arr.remove(-4));
int* p = arr.nthAddr(3);
int* q = arr.addSpaces(2);
CPPUNIT_ASSERT_EQUAL((hyu32)5, arr.size());
CPPUNIT_ASSERT_EQUAL(p, q);
}
示例3: replaceSymbol
TArray<char>* replaceSymbol(const char* line)
{
TArray<char>* buf = new TArray<char>(HMD_STRLEN(line)+1);
const char* p = line;
char c;
while ('\0' != (c = *p)) {
if (c == '{') {
int n = getSymIDNum(&p);
if (n >= 0) {
const char* s = (const char*)gSymbolTable.id2str((SymbolID_t)n);
if (s != NULL) {
hyu32 len = HMD_STRLEN(s);
memcpy(buf->addSpaces(len), s, len);
continue;
}
}
}
buf->add(c);
++p;
}
buf->add('\0');
return buf;
}