本文整理汇总了C++中SimpleStringCollection::allocate方法的典型用法代码示例。如果您正苦于以下问题:C++ SimpleStringCollection::allocate方法的具体用法?C++ SimpleStringCollection::allocate怎么用?C++ SimpleStringCollection::allocate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SimpleStringCollection
的用法示例。
在下文中一共展示了SimpleStringCollection::allocate方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SimpleString
TEST(SimpleString, CollectionWritingToEmptyString)
{
SimpleStringCollection col;
col.allocate(3);
col[3] = SimpleString("HAH");
STRCMP_EQUAL("", col[3].asCharString());
}
示例2:
TEST(SimpleString, CollectionMultipleAllocateNoLeaksMemory)
{
SimpleStringCollection col;
col.allocate(5);
col.allocate(5);
// CHECK no memory leak
}
示例3: split
void SimpleString::split(const SimpleString& delimiter, SimpleStringCollection& col) const
{
size_t num = count(delimiter);
size_t extraEndToken = (endsWith(delimiter)) ? 0 : 1U;
col.allocate(num + extraEndToken);
char* str = buffer_;
char* prev;
for (size_t i = 0; i < num; ++i) {
prev = str;
str = StrStr(str, delimiter.buffer_) + 1;
col[i] = SimpleString(prev).subString(0, size_t (str - prev));
}
if (extraEndToken) {
col[num] = str;
}
}
示例4: split
void SimpleString::split(const SimpleString& delimiter, SimpleStringCollection& col) const
{
size_t num = count(delimiter);
size_t extraEndToken = (endsWith(delimiter)) ? 0 : 1U;
col.allocate(num + extraEndToken);
char* str = buffer_;
char* prev;
for (size_t i = 0; i < num; ++i) {
prev = str;
str = PlatformSpecificStrStr(str, delimiter.buffer_) + 1;
size_t len = (size_t) (str - prev) + 1;
col[i].buffer_ = copyToNewBuffer(prev, len);
}
if (extraEndToken) {
col[num] = str;
}
}
示例5: split
void SimpleString::split(const SimpleString& split, SimpleStringCollection& col) const
{
int num = count(split);
int extraEndToken = (endsWith(split)) ? 0 : 1;
col.allocate(num + extraEndToken);
char* str = buffer;
char* prev;
for (int i = 0; i < num; ++i) {
prev = str;
str = PlatformSpecificStrStr(str, split.buffer) + 1;
int len = str - prev;
char* sub = allocString(len+1);
PlatformSpecificStrNCpy(sub, prev, len);
sub[len] = '\0';
col[i] = sub;
deallocString(sub);
}
if (extraEndToken) {
col[num] = str;
}
}
示例6: split
void SimpleString::split(const SimpleString& delimiter, SimpleStringCollection& col) const
{
size_t num = count(delimiter);
size_t extraEndToken = (endsWith(delimiter)) ? 0 : 1;
col.allocate(num + extraEndToken);
char* str = buffer_;
char* prev;
for (size_t i = 0; i < num; ++i) {
prev = str;
str = PlatformSpecificStrStr(str, delimiter.buffer_) + 1;
size_t len = str - prev;
char* sub = allocStringBuffer(len + 1);
PlatformSpecificStrNCpy(sub, prev, len);
sub[len] = '\0';
col[i] = sub;
deallocStringBuffer(sub);
}
if (extraEndToken) {
col[num] = str;
}
}