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


C++ CID类代码示例

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


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

示例1: testSimpleRootPDUToOutputStream

/**
 * Check that writing an Root PDU to an output stream works
 */
void RootPDUTest::testSimpleRootPDUToOutputStream() {
  CID cid = CID::Generate();
  RootPDU pdu1(TEST_VECTOR, cid, NULL);
  OLA_ASSERT(cid == pdu1.Cid());

  OLA_ASSERT_EQ(16u, pdu1.HeaderSize());
  OLA_ASSERT_EQ(4u, pdu1.VectorSize());
  OLA_ASSERT_EQ(0u, pdu1.DataSize());
  OLA_ASSERT_EQ(22u, pdu1.Size());

  IOQueue output;
  OutputStream stream(&output);
  pdu1.Write(&stream);

  OLA_ASSERT_EQ(22u, output.Size());

  uint8_t *raw_pdu = new uint8_t[output.Size()];
  unsigned int raw_pdu_size = output.Peek(raw_pdu, output.Size());
  OLA_ASSERT_EQ(output.Size(), raw_pdu_size);

  uint8_t EXPECTED[] = {
    0x70, 22,
    0, 0, 0, 4,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
  };
  cid.Pack(EXPECTED + 6);
  ASSERT_DATA_EQUALS(__LINE__,
                     EXPECTED, sizeof(EXPECTED),
                     raw_pdu, raw_pdu_size);

  output.Pop(output.Size());
  delete[] raw_pdu;
}
开发者ID:mlba-team,项目名称:open-lighting,代码行数:36,代码来源:RootPDUTest.cpp

示例2: testToString

/*
 * Check that ToString works.
 */
void CIDTest::testToString() {
  CID cid = CID::FromData(TEST_DATA);
  string cid_str = cid.ToString();
  transform(cid_str.begin(), cid_str.end(), cid_str.begin(), toupper);
  OLA_ASSERT_EQ(string("00010203-0405-0607-0809-0A0B0C0D0E0F"),
                       cid_str);
}
开发者ID:basileus,项目名称:ola,代码行数:10,代码来源:CIDTest.cpp

示例3: CID

	/*
	 * Generates UDP key for specified IP address
	 */
	CID Utils::getUdpKey(const string& targetIp)
	{
		CID myUdpKey = CID(SETTING(DHT_KEY));

		TigerTree th;
		th.update(myUdpKey.data(), sizeof(CID));
		th.update(targetIp.c_str(), targetIp.size());
		return CID(th.finalize());
	}
开发者ID:pk2010,项目名称:eiskaltdcpp,代码行数:12,代码来源:Utils.cpp

示例4: transform

/*
 * Check that from string works.
 */
void CIDTest::testFromString() {
  const string uuid = "00010203-0405-0607-0809-0A0B0C0D0E0F";
  CID cid = CID::FromString(uuid);
  string cid_str = cid.ToString();
  transform(cid_str.begin(), cid_str.end(), cid_str.begin(), toupper);
  OLA_ASSERT_EQ(uuid, cid_str);

  const string bad_uuid = "foo";
  cid = CID::FromString(bad_uuid);
  OLA_ASSERT(cid.IsNil());
}
开发者ID:basileus,项目名称:ola,代码行数:14,代码来源:CIDTest.cpp

示例5: testToOutputBuffer

/**
 * Check writing to an OutputBuffer works.
 */
void CIDTest::testToOutputBuffer() {
  ola::io::IOQueue output;
  const string uuid = "00010203-0405-0607-0809-0A0B0C0D0E0F";
  CID cid = CID::FromString(uuid);

  cid.Write(&output);
  OLA_ASSERT_EQ(16u, output.Size());
  unsigned int size = output.Size();
  uint8_t cid_data[size];
  OLA_ASSERT_EQ(size, output.Read(cid_data, size));

  ASSERT_DATA_EQUALS(__LINE__, TEST_DATA, sizeof(TEST_DATA),
                     cid_data, size);
}
开发者ID:basileus,项目名称:ola,代码行数:17,代码来源:CIDTest.cpp

示例6: OLA_ASSERT

/*
 * Check that basic assignment & equality works
 */
void CIDTest::testCID() {
  CID cid;
  OLA_ASSERT(cid.IsNil());

  CID cid1 = CID::Generate();
  OLA_ASSERT_FALSE(cid1.IsNil());

  CID cid2 = cid1;
  OLA_ASSERT(cid2 == cid1);
  OLA_ASSERT_FALSE(cid2.IsNil());

  CID cid3;
  cid3 = cid1;
  OLA_ASSERT(cid3 == cid1);
  OLA_ASSERT_FALSE(cid3.IsNil());
}
开发者ID:basileus,项目名称:ola,代码行数:19,代码来源:CIDTest.cpp

示例7: cid

UserPtr DirectoryListing::getUserFromFilename(const string& fileName)
{
	// General file list name format: [username].[CID].[xml|xml.bz2]
	
	string name = Util::getFileName(fileName);
	string ext = Text::toLower(Util::getFileExt(name));
	
	if (ext == ".dcls" || ext == ".dclst")  // [+] IRainman dclst support
	{
		auto l_user = std::make_shared<User>(CID(), name, 0);
		return l_user;
	}
	
	// Strip off any extensions
	if (ext == ".bz2")
	{
		name.erase(name.length() - 4);
		ext = Text::toLower(Util::getFileExt(name));
	}
	
	if (ext == ".xml")
	{
		name.erase(name.length() - 4);
	}
	// Find CID
	string::size_type i = name.rfind('.');
	if (i == string::npos)
	{
		return ClientManager::getUser(name, "Unknown Hub", 0);
	}
	
	size_t n = name.length() - (i + 1);
	// CID's always 39 chars long...
	if (n != 39)
	{
		return ClientManager::getUser(name, "Unknown Hub", 0);
	}
	
	const CID cid(name.substr(i + 1));
	if (cid.isZero())
	{
		return ClientManager::getUser(name, "Unknown Hub", 0);
	}
	
	UserPtr u = ClientManager::createUser(cid, name.substr(0, i), 0);
	return u;
}
开发者ID:,项目名称:,代码行数:47,代码来源:

示例8: getHeaderString

string AdcCommand::getHeaderString(const CID& cid) const {
	dcassert(type == TYPE_UDP);
	string tmp;

	tmp += getType();
	tmp += cmdChar;
	tmp += ' ';
	tmp += cid.toBase32();
	return tmp;
}
开发者ID:HiT-Hi-FiT-Hai,项目名称:dcplusplus,代码行数:10,代码来源:AdcCommand.cpp

示例9: AddService

ErrorCode ComponentManager::AddService( CID cid, ISupports *service )
{
	TRACE_BEGIN( LOG_LVL_INFO );
	ClassInfo *info = jh_new ClassInfo( cid, service );
	
	LOG( "Adding cid %s, ISupports %p", cid.toString(), service );
	
	service->AddRef();
	
	mClasses.push_back( info );
	
	return kNoError;
}
开发者ID:benpayne,项目名称:jhcommon,代码行数:13,代码来源:ComponentManager.cpp

示例10: pdu1

/*
 * Test that packing a RootPDU with nested data works
 */
void RootPDUTest::testNestedRootPDUToOutputStream() {
  FakePDU pdu1(1);
  FakePDU pdu2(42);
  PDUBlock<PDU> block;
  block.AddPDU(&pdu1);
  block.AddPDU(&pdu2);

  CID cid = CID::Generate();
  RootPDU pdu(TEST_VECTOR, cid, &block);

  OLA_ASSERT(cid == pdu.Cid());
  OLA_ASSERT_EQ(30u, pdu.Size());

  IOQueue output;
  OutputStream stream(&output);
  pdu.Write(&stream);
  OLA_ASSERT_EQ(30u, output.Size());

  uint8_t *raw_pdu = new uint8_t[output.Size()];
  unsigned int raw_pdu_size = output.Peek(raw_pdu, output.Size());
  OLA_ASSERT_EQ(output.Size(), raw_pdu_size);

  uint8_t EXPECTED[] = {
    0x70, 30,
    0, 0, 0, 4,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 1,
    0, 0, 0, 42
  };
  cid.Pack(EXPECTED + 6);
  ASSERT_DATA_EQUALS(__LINE__,
                     EXPECTED, sizeof(EXPECTED),
                     raw_pdu, raw_pdu_size);

  output.Pop(output.Size());
  delete[] raw_pdu;
}
开发者ID:mlba-team,项目名称:open-lighting,代码行数:40,代码来源:RootPDUTest.cpp

示例11: getNicks

StringList ClientManager::getNicks(const CID& cid) const {
	Lock l(cs);
	StringSet nicks;
	OnlinePairC op = onlineUsers.equal_range(cid);
	for(OnlineIterC i = op.first; i != op.second; ++i) {
		nicks.insert(i->second->getIdentity().getNick());
	}
	if(nicks.empty()) {
		// Offline perhaps?
		UserMap::const_iterator i = users.find(cid);
		if(i != users.end() && !i->second->getFirstNick().empty()) {
			nicks.insert(i->second->getFirstNick());
		} else {
			nicks.insert('{' + cid.toBase32() + '}');
		}
	}
	return StringList(nicks.begin(), nicks.end());
}
开发者ID:andor44,项目名称:nanodc2,代码行数:18,代码来源:ClientManager.cpp

示例12: TypeBase

CID::CID(CID const& other)
: TypeBase(other.GetNode())
{
}
开发者ID:michealwong,项目名称:qhelper-all,代码行数:4,代码来源:sap.cpp

示例13: UIntValidator

/*
 * Load the plugin prefs and default to sensible values
 *
 */
bool E131Plugin::SetDefaultPreferences() {
  if (!m_preferences)
    return false;

  bool save = false;

  CID cid = CID::FromString(m_preferences->GetValue(CID_KEY));
  if (cid.IsNil()) {
    cid = CID::Generate();
    m_preferences->SetValue(CID_KEY, cid.ToString());
    save = true;
  }

  save |= m_preferences->SetDefaultValue(
      DSCP_KEY,
      UIntValidator(0, 63),
      DEFAULT_DSCP_VALUE);

  save |= m_preferences->SetDefaultValue(
      DRAFT_DISCOVERY_KEY,
      BoolValidator(),
      BoolValidator::DISABLED);

  save |= m_preferences->SetDefaultValue(
      IGNORE_PREVIEW_DATA_KEY,
      BoolValidator(),
      BoolValidator::ENABLED);

  save |= m_preferences->SetDefaultValue(
      INPUT_PORT_COUNT_KEY,
      UIntValidator(0, 128),
      DEFAULT_PORT_COUNT);

  save |= m_preferences->SetDefaultValue(
      OUTPUT_PORT_COUNT_KEY,
      UIntValidator(0, 128),
      DEFAULT_PORT_COUNT);

  save |= m_preferences->SetDefaultValue(IP_KEY, StringValidator(true), "");

  save |= m_preferences->SetDefaultValue(
      PREPEND_HOSTNAME_KEY,
      BoolValidator(),
      BoolValidator::ENABLED);

  std::set<string> revision_values;
  revision_values.insert(REVISION_0_2);
  revision_values.insert(REVISION_0_46);

  save |= m_preferences->SetDefaultValue(
      REVISION_KEY,
      SetValidator<string>(revision_values),
      REVISION_0_46);

  if (save)
    m_preferences->Save();

  // check if this saved correctly
  // we don't want to use it if null
  string revision = m_preferences->GetValue(REVISION_KEY);
  if (m_preferences->GetValue(CID_KEY).empty() ||
      (revision != REVISION_0_2 && revision != REVISION_0_46))
    return false;

  return true;
}
开发者ID:NextGenIntelligence,项目名称:ola,代码行数:70,代码来源:E131Plugin.cpp

示例14: OLA_ASSERT_FALSE

void CIDTest::testSetPack() {
  uint8_t buffer[CID::CID_LENGTH];
  CID cid = CID::FromData(TEST_DATA);
  cid.Pack(buffer);
  OLA_ASSERT_FALSE(memcmp(TEST_DATA, buffer, CID::CID_LENGTH));
}
开发者ID:basileus,项目名称:ola,代码行数:6,代码来源:CIDTest.cpp

示例15: getOfflineNick

string ClientManager::getOfflineNick(const CID& cid) const {
	auto i = nicks.find(cid);
	return i != nicks.end() ? i->second.first : '{' + cid.toBase32() + '}';
}
开发者ID:hjpotter92,项目名称:dcplusplus,代码行数:4,代码来源:ClientManager.cpp


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