本文整理汇总了C++中Iter::get方法的典型用法代码示例。如果您正苦于以下问题:C++ Iter::get方法的具体用法?C++ Iter::get怎么用?C++ Iter::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Iter
的用法示例。
在下文中一共展示了Iter::get方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
int
Match::eval(const Iter& iter)
{
Uint32 val32;
Uint64 val64;
const char* valc;
if (iter.get(m_key, &val32) == 0)
{
if(atoi(m_value.c_str()) != (int)val32)
return 0;
}
else if(iter.get(m_key, &val64) == 0)
{
if(strtoll(m_value.c_str(), (char **)NULL, 10) != (long long)val64)
return 0;
}
else if(iter.get(m_key, &valc) == 0)
{
if(strcmp(m_value.c_str(), valc) != 0)
return 0;
}
else
{
return 0;
}
return 1;
}
示例2: printf
int
NodeTypeApply::apply(const Iter& iter)
{
Uint32 val32;
if (iter.get(CFG_TYPE_OF_SECTION, &val32) == 0)
{
printf("%s", ndb_mgm_get_node_type_alias_string((ndb_mgm_node_type)val32, 0));
}
return 0;
}
示例3: gethostbyname
int
HostMatch::eval(const Iter& iter)
{
const char* valc;
if(iter.get(m_key, &valc) == 0)
{
struct hostent *h1, *h2, copy1;
char *addr1;
h1 = gethostbyname(m_value.c_str());
if (h1 == NULL) {
return 0;
}
// gethostbyname returns a pointer to a static structure
// so we need to copy the results before doing the next call
memcpy(©1, h1, sizeof(struct hostent));
addr1 = (char *)malloc(copy1.h_length);
NdbAutoPtr<char> tmp_aptr(addr1);
memcpy(addr1, h1->h_addr, copy1.h_length);
h2 = gethostbyname(valc);
if (h2 == NULL) {
return 0;
}
if (copy1.h_addrtype != h2->h_addrtype) {
return 0;
}
if (copy1.h_length != h2->h_length)
{
return 0;
}
return 0 == memcmp(addr1, h2->h_addr, copy1.h_length);
}
return 0;
}
示例4: switch
int
ConnectionTypeApply::apply(const Iter& iter)
{
Uint32 val32;
if (iter.get(CFG_TYPE_OF_SECTION, &val32) == 0)
{
switch (val32)
{
case CONNECTION_TYPE_TCP:
printf("tcp");
break;
case CONNECTION_TYPE_SCI:
printf("sci");
break;
case CONNECTION_TYPE_SHM:
printf("shm");
break;
default:
printf("<unknown>");
break;
}
}
return 0;
}
示例5: TestTLList
static void TestTLList(skiatest::Reporter* reporter) {
typedef SkTLList<ListElement> ElList;
typedef ElList::Iter Iter;
SkRandom random;
for (int i = 1; i <= 16; i *= 2) {
ElList list1(i);
ElList list2(i);
Iter iter1;
Iter iter2;
Iter iter3;
Iter iter4;
#if SK_ENABLE_INST_COUNT
SkASSERT(0 == ListElement::InstanceCount());
#endif
REPORTER_ASSERT(reporter, list1.isEmpty());
REPORTER_ASSERT(reporter, NULL == iter1.init(list1, Iter::kHead_IterStart));
REPORTER_ASSERT(reporter, NULL == iter1.init(list1, Iter::kTail_IterStart));
// Try popping an empty list
list1.popHead();
list1.popTail();
REPORTER_ASSERT(reporter, list1.isEmpty());
REPORTER_ASSERT(reporter, list1 == list2);
// Create two identical lists, one by appending to head and the other to the tail.
list1.addToHead(ListElement(1));
list2.addToTail(ListElement(1));
#if SK_ENABLE_INST_COUNT
SkASSERT(2 == ListElement::InstanceCount());
#endif
iter1.init(list1, Iter::kHead_IterStart);
iter2.init(list1, Iter::kTail_IterStart);
REPORTER_ASSERT(reporter, iter1.get()->fID == iter2.get()->fID);
iter3.init(list2, Iter::kHead_IterStart);
iter4.init(list2, Iter::kTail_IterStart);
REPORTER_ASSERT(reporter, iter3.get()->fID == iter1.get()->fID);
REPORTER_ASSERT(reporter, iter4.get()->fID == iter1.get()->fID);
REPORTER_ASSERT(reporter, list1 == list2);
list2.reset();
// use both before/after in-place construction on an empty list
SkNEW_INSERT_IN_LLIST_BEFORE(&list2, list2.headIter(), ListElement, (1));
REPORTER_ASSERT(reporter, list2 == list1);
list2.reset();
SkNEW_INSERT_IN_LLIST_AFTER(&list2, list2.tailIter(), ListElement, (1));
REPORTER_ASSERT(reporter, list2 == list1);
// add an element to the second list, check that iters are still valid
iter3.init(list2, Iter::kHead_IterStart);
iter4.init(list2, Iter::kTail_IterStart);
list2.addToHead(ListElement(2));
#if SK_ENABLE_INST_COUNT
SkASSERT(3 == ListElement::InstanceCount());
#endif
REPORTER_ASSERT(reporter, iter3.get()->fID == iter1.get()->fID);
REPORTER_ASSERT(reporter, iter4.get()->fID == iter1.get()->fID);
REPORTER_ASSERT(reporter, 1 == Iter(list2, Iter::kTail_IterStart).get()->fID);
REPORTER_ASSERT(reporter, 2 == Iter(list2, Iter::kHead_IterStart).get()->fID);
REPORTER_ASSERT(reporter, list1 != list2);
list1.addToHead(ListElement(2));
REPORTER_ASSERT(reporter, list1 == list2);
#if SK_ENABLE_INST_COUNT
SkASSERT(4 == ListElement::InstanceCount());
#endif
REPORTER_ASSERT(reporter, !list1.isEmpty());
list1.reset();
list2.reset();
#if SK_ENABLE_INST_COUNT
SkASSERT(0 == ListElement::InstanceCount());
#endif
REPORTER_ASSERT(reporter, list1.isEmpty() && list2.isEmpty());
// randomly perform insertions and deletions on a list and perform tests
int count = 0;
for (int j = 0; j < 100; ++j) {
if (list1.isEmpty() || random.nextBiasedBool(3 * SK_Scalar1 / 4)) {
int id = j;
// Choose one of three ways to insert a new element: at the head, at the tail,
// before a random element, after a random element
int numValidMethods = 0 == count ? 2 : 4;
int insertionMethod = random.nextULessThan(numValidMethods);
switch (insertionMethod) {
case 0:
list1.addToHead(ListElement(id));
break;
case 1:
list1.addToTail(ListElement(id));
break;
case 2: // fallthru to share code that picks random element.
case 3: {
int n = random.nextULessThan(list1.count());
Iter iter = list1.headIter();
//.........这里部分代码省略.........