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


C++ ACE_TString::empty方法代码示例

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


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

示例1: test

int DDS_TEST::test(ACE_TString host, u_short port)
{
  if (host.empty() || port == 0) {
    std::cerr << "ERROR: -h <host> and -p <port> options are required\n";
    return 1;
  }

  // 0. initialization

  ACE_INET_Addr remote_addr(port, host.c_str());

  TransportInst_rch inst = TheTransportRegistry->create_inst("my_rtps",
                                                             "rtps_udp");

  RtpsUdpInst* rtps_inst = dynamic_cast<RtpsUdpInst*>(inst.in());
  if (!rtps_inst) {
    std::cerr << "ERROR: Failed to cast to RtpsUdpInst\n";
    return 1;
  }
  rtps_inst->datalink_release_delay_ = 0;
  rtps_inst->heartbeat_period_ = ACE_Time_Value(0, 100*1000 /*microseconds*/);

  TransportConfig_rch cfg = TheTransportRegistry->create_config("cfg");
  cfg->instances_.push_back(inst);

  TheTransportRegistry->global_config(cfg);

  RepoIdBuilder local;
  local.federationId(0x01234567);  // guidPrefix1
  local.participantId(0x89abcdef); // guidPrefix2
  local.entityKey(0x012345);
  local.entityKind(ENTITYKIND_USER_WRITER_WITH_KEY);
  OpenDDS::RTPS::GUID_t local_guid(local);
  const OpenDDS::RTPS::GuidPrefix_t& local_prefix = local_guid.guidPrefix;

  RepoIdBuilder remote; // these values must match what's in subscriber.cpp
  remote.federationId(0x01234567);  // guidPrefix1
  remote.participantId(0xefcdab89); // guidPrefix2
  remote.entityKey(0x452310);
  remote.entityKind(ENTITYKIND_USER_READER_WITH_KEY);

  LocatorSeq locators;
  locators.length(1);
  locators[0].kind = (remote_addr.get_type() == AF_INET6)
                     ? LOCATOR_KIND_UDPv6 : LOCATOR_KIND_UDPv4;
  locators[0].port = port;
  address_to_bytes(locators[0].address, remote_addr);

  size_t size_locator = 0, padding_locator = 0;
  gen_find_size(locators, size_locator, padding_locator);
  ACE_Message_Block mb_locator(size_locator + padding_locator + 1);
  Serializer ser_loc(&mb_locator, ACE_CDR_BYTE_ORDER, Serializer::ALIGN_CDR);
  ser_loc << locators;
  ser_loc << ACE_OutputCDR::from_boolean(false); // requires inline QoS

  SimpleDataWriter sdw(local_guid);
  sdw.enable_transport(true /*reliable*/, false /*durable*/);
  AssociationData subscription;
  subscription.remote_id_ = remote;
  subscription.remote_reliable_ = false;
  subscription.remote_data_.length(1);
  subscription.remote_data_[0].transport_type = "rtps_udp";
  subscription.remote_data_[0].data.replace(
    static_cast<CORBA::ULong>(mb_locator.length()), &mb_locator);

  if (!sdw.init(subscription)) {
    std::cerr << "publisher TransportClient::associate() failed\n";
    return 1;
  }

  // 1. send by directly writing an RTPS Message to the socket

  const Header hdr = { {'R', 'T', 'P', 'S'}, PROTOCOLVERSION, VENDORID_OPENDDS,
    {local_prefix[0], local_prefix[1], local_prefix[2], local_prefix[3],
     local_prefix[4], local_prefix[5], local_prefix[6], local_prefix[7],
     local_prefix[8], local_prefix[9], local_prefix[10], local_prefix[11]} };

  const ACE_Time_Value now = ACE_OS::gettimeofday();
  log_time(now);
  const double conv = 4294.967296; // NTP fractional (2^-32) sec per microsec
  const InfoTimestampSubmessage it = { {INFO_TS, 1, 8},
    {static_cast<ACE_CDR::Long>(now.sec()),
     static_cast<ACE_CDR::ULong>(now.usec() * conv)} };

  DataSubmessage ds = { {DATA, 7, 20 + 24 + 12 + sizeof(text)}, 0, 16,
    ENTITYID_UNKNOWN, local_guid.entityId, {0, 1}, ParameterList() };

  TestMsg data;
  data.key = 0x09230923;
  data.value = text;

  ds.inlineQos.length(1);
  OpenDDS::RTPS::KeyHash_t hash;
  marshal_key_hash(data, hash);
  ds.inlineQos[0].key_hash(hash);

  const ACE_CDR::ULong encap = 0x00000100; // {CDR_LE, options} in BE format
  size_t size = 0, padding = 0;
  gen_find_size(hdr, size, padding);
  gen_find_size(it, size, padding);
//.........这里部分代码省略.........
开发者ID:CapXilinx,项目名称:OpenDDS,代码行数:101,代码来源:publisher.cpp

示例2: opts

int
ACE_TMAIN(int argc, ACE_TCHAR* argv[])
{
  try {
    TheParticipantFactoryWithArgs(argc, argv);

    std::cerr << "STARTING MAIN IN SUBSCRIBER\n";
    ACE_TString host;
    u_short port = 0;

    ACE_Get_Opt opts(argc, argv, ACE_TEXT("h:p:"));
    int option = 0;

    while ((option = opts()) != EOF) {
      switch (option) {
      case 'h':
        host = opts.opt_arg();
        break;
      case 'p':
        port = static_cast<u_short>(ACE_OS::atoi(opts.opt_arg()));
        break;
      }
    }

    if (host.empty() || port == 0) {
      std::cerr << "ERROR: -h <host> and -p <port> options are required\n";
      return 1;
    }

    TransportInst_rch inst = TheTransportRegistry->create_inst("my_rtps",
                                                               "rtps_udp");

    RtpsUdpInst* rtps_inst = dynamic_cast<RtpsUdpInst*>(inst.in());
#ifdef OPENDDS_SAFETY_PROFILE
    if (host == "localhost") {
      host = "127.0.0.1";
    }
#endif
    rtps_inst->local_address(port, ACE_TEXT_ALWAYS_CHAR(host.c_str()));
    rtps_inst->datalink_release_delay_ = 0;

    TransportConfig_rch cfg = TheTransportRegistry->create_config("cfg");
    cfg->instances_.push_back(inst);

    TheTransportRegistry->global_config(cfg);

    RepoIdBuilder local;
    local.federationId(0x01234567);  // guidPrefix1
    local.participantId(0xefcdab89); // guidPrefix2
    local.entityKey(0x452310);
    local.entityKind(ENTITYKIND_USER_READER_WITH_KEY);

    RepoIdBuilder remote; // these values must match what's in publisher.cpp
    remote.federationId(0x01234567);  // guidPrefix1
    remote.participantId(0x89abcdef); // guidPrefix2
    remote.entityKey(0x012345);
    remote.entityKind(ENTITYKIND_USER_WRITER_WITH_KEY);

    SimpleDataReader sdr(local);
    sdr.enable_transport(false /*reliable*/, false /*durable*/);
    // Write a file so that test script knows we're ready
    FILE* file = std::fopen("subready.txt", "w");
    std::fprintf(file, "Ready\n");
    std::fclose(file);

    std::cerr << "***Ready written to subready.txt\n";

    AssociationData publication;
    publication.remote_id_ = remote;
    publication.remote_reliable_ = true;
    publication.remote_data_.length(1);
    publication.remote_data_[0].transport_type = "rtps_udp";
    publication.remote_data_[0].data.length(5);
    for (CORBA::ULong i = 0; i < 5; ++i) {
      publication.remote_data_[0].data[i] = 0;
    }

    std::cerr << "***Association Data created for Publication for SimpleDataReader to init\n";
    std::cout << "Associating with pub..." << std::endl;
    if (!sdr.init(publication)) {
      std::cerr << "subscriber TransportClient::associate() failed\n";
      return 1;
    }

    std::cerr << "***Simple Data Reader init:: publication completed\n";

    while (!sdr.done_) {
      ACE_OS::sleep(1);
    }

    if (sdr.control_msg_count_ != 4) {
      ACE_DEBUG((LM_ERROR, "ERROR: Expected 4 control messages, received %d\n",
                 sdr.control_msg_count_));
    }

    sdr.disassociate(publication.remote_id_);

    TheServiceParticipant->shutdown();
    ACE_Thread_Manager::instance()->wait();

//.........这里部分代码省略.........
开发者ID:stonejiang208,项目名称:OpenDDS,代码行数:101,代码来源:subscriber.cpp


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