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


C++ DataItem::getData方法代码示例

本文整理汇总了C++中DataItem::getData方法的典型用法代码示例。如果您正苦于以下问题:C++ DataItem::getData方法的具体用法?C++ DataItem::getData怎么用?C++ DataItem::getData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DataItem的用法示例。


在下文中一共展示了DataItem::getData方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main()
{
	HashTable hash_table;
	hash_table.insert(1, 20);
	hash_table.insert(2, 70);
	hash_table.insert(42, 80);
	hash_table.insert(4, 25);
	hash_table.insert(12, 44);
	hash_table.insert(14, 32);
	hash_table.insert(17, 11);
	hash_table.insert(13, 78);
	hash_table.insert(37, 97);
	
	hash_table.display();

	DataItem item = hash_table.search(37);

	if (item != HashTable::emptyItem && item != HashTable::dummyItem)
		cout << "Element found: " << item.getData() << endl;
	else
		cout << "Element not found" << endl;

	hash_table.remove(37);
	item = hash_table.search(37);

	if (item != HashTable::emptyItem && item != HashTable::dummyItem)
		cout << "Element found: " << item.getData() << endl;
	else
		cout << "Element not found" << endl;

	hash_table.display();
	return 0;
}
开发者ID:zpiao1,项目名称:CPP-Data-Structures,代码行数:33,代码来源:main.cpp

示例2: getData

PyObject* DataRecord::getData(int verbose)
{
	PyObject*p = PyDict_New();

	PyObject* k1 = Py_BuildValue("s", "category");
	PyObject* v1 = Py_BuildValue("H", m_pCategory->m_id);
	PyDict_SetItem(p, k1, v1);
	Py_DECREF(k1);
	Py_DECREF(v1);

	PyObject* k2 = Py_BuildValue("s", "len");
	PyObject* v2 = Py_BuildValue("l", m_nLength);
	PyDict_SetItem(p, k2, v2);
	Py_DECREF(k2);
	Py_DECREF(v2);

    char hexcrc[9];
    sprintf(hexcrc, "%08X", m_nCrc);
	PyObject* k3 = Py_BuildValue("s", "crc");
	PyObject* v3 = Py_BuildValue("s", hexcrc);
	PyDict_SetItem(p, k3, v3);
	Py_DECREF(k3);
	Py_DECREF(v3);

	PyObject* k4 = Py_BuildValue("s", "ts");
	PyObject* v4 = Py_BuildValue("l", m_nTimestamp);
	PyDict_SetItem(p, k4, v4);
	Py_DECREF(k4);
	Py_DECREF(v4);

    if (m_bFormatOK)
    {
        // go through all present data items in this record
        std::list<DataItem*>::iterator it;
        for ( it=m_lDataItems.begin() ; it != m_lDataItems.end(); it++ )
        {
            DataItem* di = (DataItem*)(*it);
            if (di)
            {
                PyObject* v1 = di->getData(verbose);
                char tmp[20];
                snprintf(tmp, 20, "I%s", di->m_pDescription->m_strID.c_str());
                PyObject* k1 = Py_BuildValue("s", tmp);
                PyDict_SetItem(p, k1, v1);
                Py_DECREF(k1);
                Py_DECREF(v1);
            }
        }
    }

  return p;
}
开发者ID:CroatiaControlLtd,项目名称:asterix,代码行数:52,代码来源:DataRecord.cpp

示例3: getData

PyObject* DataRecord::getData()
{
	UAP* pUAP = m_pCategory->getUAP(m_pFSPECData, m_nFSPECLength);
	PyObject*p = PyDict_New();

	PyObject* k1 = Py_BuildValue("s", "category");
	PyObject* v1 = Py_BuildValue("H", m_pCategory->m_id);
	PyDict_SetItem(p, k1, v1);
	Py_DECREF(k1);
	Py_DECREF(v1);

	PyObject* k2 = Py_BuildValue("s", "len");
	PyObject* v2 = Py_BuildValue("l", m_nLength);
	PyDict_SetItem(p, k2, v2);
	Py_DECREF(k2);
	Py_DECREF(v2);

    char hexcrc[9];
    sprintf(hexcrc, "%08X", m_nCrc);
	PyObject* k3 = Py_BuildValue("s", "crc");
	PyObject* v3 = Py_BuildValue("s", hexcrc);
	PyDict_SetItem(p, k3, v3);
	Py_DECREF(k3);
	Py_DECREF(v3);

	PyObject* k4 = Py_BuildValue("s", "ts");
	PyObject* v4 = Py_BuildValue("l", m_nTimestamp);
	PyDict_SetItem(p, k4, v4);
	Py_DECREF(k4);
	Py_DECREF(v4);

	if (!pUAP)
	{
		Tracer::Error("UAP for CAT%03d not found!", m_pCategory->m_id);
	}
	else
	{
		// go through all present data items in this record
		std::list<DataItem*>::iterator it;
		for ( it=m_lDataItems.begin() ; it != m_lDataItems.end(); it++ )
		{
			DataItem* di = (DataItem*)(*it);
			if (di)
			{
				PyObject* v1 = di->getData();
				char tmp[20];
				sprintf(tmp, "I%s", di->m_pDescription->m_strID.c_str());
                PyObject* k1 = Py_BuildValue("s", tmp);
				PyDict_SetItem(p, k1, v1);
                Py_DECREF(k1);
				Py_DECREF(v1);
			}
		}
	}

  if (!m_bFormatOK)
  {
    // TODO err
  }

  return p;
}
开发者ID:bbertrand,项目名称:asterix,代码行数:62,代码来源:DataRecord.cpp


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