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


C++ UUID::toString方法代码示例

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


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

示例1: async

	std::future<bool> UserData::SendFriendResponse(const UUID &id, const UUID &requester, const std::string &response,
		BooleanCallback success, APIFailureCallback failure)
	{
		return std::async(std::launch::async, [=]() -> bool {
			std::stringstream url;
			url << "/friends/" << id.toString() << "/response";

			std::map<std::string, std::string> params{
				std::make_pair("requester_id", requester.toString()),
				std::make_pair("action", response)
			};

			std::string error;

			APIRequestManager *manager = APIRequestManager::GetDefaultManager();
			boost::optional<std::string> response = manager->Send(url.str(), "POST", params, error);
			if (response.is_initialized()) {
				Poco::JSON::Parser parser;
				auto jsonObject = parser.parse(response.get()).extract<JSONObject::Ptr>();
				return jsonObject->getValue<bool>("success");
			}
			else {
				if (failure) {
					failure(error);
				}

				return false;
			}
		});
	}
开发者ID:metsfan,项目名称:dungeon-raider,代码行数:30,代码来源:UserData.cpp

示例2: main

int main(int argc, char** argv)
{
	UUID uuid;
	
	std::string arg;
	if (argc > 1)
		arg = argv[1];
	
	try
	{
		if (arg == "-random")
			uuid = UUIDGenerator::defaultGenerator().createRandom();
		else if (arg.empty())
			uuid = UUIDGenerator::defaultGenerator().create();
		else
			uuid = UUIDGenerator::defaultGenerator().createFromName(UUID::uri(), arg);
		
		std::cout << uuid.toString() << std::endl;
	}
	catch (Exception& exc)
	{
		std::cerr << exc.displayText() << std::endl;
		return 1;
	}
	
	return 0;
}
开发者ID:Alcibiades586,项目名称:roadrunner,代码行数:27,代码来源:uuidgen.cpp

示例3: test007

void test007() {
  const UUID u0 = {0xe87db3a0, 0x109a, 0x4ecb, {0x86, 0x64, 0x66, 0x85,
						0x45, 0x20, 0xa6, 0xcc}};
  UUID u1;
  const char u2[] = "e87db3a0-109a-4ecb-8664-66854520a6cc";
  char u3[39];
  char u4[39];
  char u5[39];
  char u6[38];
  int rv;

  ASSERT(sizeof(u0) == 16, "UUID structure is of unexpected size");

  ASSERT(sizeof(u2) == 37, "u2 is of unexpected size");

  u1 = UUID_null;
  u1.fromString(u2);
  VERIFY(u1.equals(u0), "u2 was not parsed properly into u1");

  rv = snprintf(u3, 39, "{%s}", u2);
  ASSERT(rv == 38, "copying u2 into u3 with curly braces failed");

  u1 = UUID_null;
  VERIFY(u1.equals(UUID_null), "u1 is not equal to UUID_null after resetting");

  u1.fromString(u3);
  VERIFY(u1.equals(u0), "u3 was not parsed properly into u1");

  rv = snprintf(u4, 39, "{%x-%x-%x-%x%x-%x%x%x%x%x%x}",
		u0.data0, u0.data1, u0.data2,
		u0.data3[0],
		u0.data3[1],
		u0.data3[2],
		u0.data3[3],
		u0.data3[4],
		u0.data3[5],
		u0.data3[6],
		u0.data3[7]);
  ASSERT(rv == 38, "formatting u0 into u4 (with snprintf) failed");

  VERIFY(strncmp(u3, u4, 39) == 0, "result of formatting u0 into u4 was different from u3");

  u0.toString(u5);
  VERIFY(strncmp(u3, u5, 39) == 0, "result of using toString on u0 was different from u3");

  rv = snprintf(u6, 38, "{%s", u2);
  ASSERT(rv == 37, "copying u2 into u6 with starting curly brace failed");

  u1 = u0;
  u1.fromString(u6);
  VERIFY(u1.equals(UUID_null), "fromString wrongfully accepted u6 into u1");

  rv = snprintf(u6, 38, "%s}", u2);
  ASSERT(rv == 37, "copying u2 into u6 with ending curly brace failed");

  u1 = u0;
  u1.fromString(u6);
  VERIFY(u1.equals(UUID_null), "fromString wrongfully accepted u6 into u1");
}
开发者ID:BackupTheBerlios,项目名称:xplc-svn,代码行数:59,代码来源:test007.cpp

示例4: testTryParse

void UUIDTest::testTryParse()
{
	UUID uuid;
	assert (uuid.tryParse("6BA7B810-9DAD-11D1-80B4-00C04FD430C8"));
	assert (uuid.toString() == "6ba7b810-9dad-11d1-80b4-00c04fd430c8");

	UUID notUuid;
	assert (!notUuid.tryParse("not a uuid"));
	assert (notUuid.isNull());
}
开发者ID:cshnick,项目名称:CommunicationModel,代码行数:10,代码来源:UUIDTest.cpp

示例5: initiateHandshake

void Broadcast::initiateHandshake(Broadcast::BroadcastStream*stream,const Network::Address&addy,const UUID &name) {
    Protocol::Broadcast message;
    message.set_broadcast_name(name);
    String str;
    if (message.SerializeToString(&str)) {
        (*stream)->send(MemoryReference(str),Network::ReliableOrdered);
        //FIXME
    }else {
        SILOG(broadcast,error,"Cannot send memory reference to UUID "<<name.toString());
    }
}
开发者ID:MikeSofaer,项目名称:sirikata,代码行数:11,代码来源:Broadcast.cpp

示例6: BSON

StatusWith<BSONObj> RollbackSourceImpl::getCollectionInfoByUUID(const std::string& db,
                                                                const UUID& uuid) const {
    std::list<BSONObj> info = _getConnection()->getCollectionInfos(db, BSON("info.uuid" << uuid));
    if (info.empty()) {
        return StatusWith<BSONObj>(ErrorCodes::NoSuchKey,
                                   str::stream()
                                       << "No collection info found for collection with uuid: "
                                       << uuid.toString()
                                       << " in db: "
                                       << db);
    }
    invariant(info.size() == 1U);
    return info.front();
}
开发者ID:mpobrien,项目名称:mongo,代码行数:14,代码来源:rollback_source_impl.cpp

示例7: updateUUID

        void LightManager::updateUUID(UUID const& uuid)
        {
            const std::string uuidStr = uuid.toString();
            auto find = m_Lights.find(uuidStr);

            if(find != m_Lights.end())
            {
                auto object = find->second;

                m_Lights.erase(find);

                m_Lights.insert(std::make_pair(object->getUUID().toString(), object));
            }
        }
开发者ID:ssell,项目名称:OcularEngine,代码行数:14,代码来源:LightManager.cpp

示例8: format

inline std::string getExecutorSentinelPath(
    const std::string& rootDir,
    const SlaveID& slaveId,
    const FrameworkID& frameworkId,
    const ExecutorID& executorId,
    const UUID& executorUUID)
{
  return strings::format(
      EXECUTOR_SENTINEL_PATH,
      rootDir,
      slaveId,
      frameworkId,
      executorId,
      executorUUID.toString()).get();
}
开发者ID:CipherLiu,项目名称:mesos,代码行数:15,代码来源:paths.hpp

示例9: replaceWithLink

int Plugin::replaceWithLink(std::string filepath)
{
    std::cout << "Replacing with link " << filepath.c_str() << std::endl;

    std::ifstream fstr(filepath.c_str());
    MD5Engine md5;
    DigestOutputStream ostr(md5);
    Poco::StreamCopier::copyStream(fstr, ostr);
    ostr.flush();
    const DigestEngine::Digest& digest = md5.digest();
    std::string sourceMd5 = DigestEngine::digestToHex(digest);
    std::cout << "File contents MD5 sum: " << sourceMd5.c_str() << std::endl;

    // Generate new file name
    UUIDGenerator gen;
    UUID tmpUuid = gen.createRandom();
    std::string uuid = tmpUuid.toString(); 
    std::string newFile(Plugin::GIT_CACHE_DIR);
    newFile.append("/");
    newFile.append(uuid);

    Process::Args args;
    args.push_back(filepath);
    args.push_back(newFile);
    Poco::ProcessHandle ph = Process::launch("mv", args, 0, 0, 0);

    // Failback with sudo
    if (ph.wait() != 0)
    {
        args.clear();
        args.push_back("mv");
        args.push_back(filepath);
        args.push_back(newFile);
        ph = Process::launch("sudo", args, 0, 0, 0);
    }

    // Check if file was moved
    File originalFile(filepath);
    if (originalFile.exists())
    {
        std::cout << "Failed to move original file" << std::endl;
        return -1;
    }

    return 1;
}
开发者ID:subutai-io,项目名称:gitbin,代码行数:46,代码来源:Plugin.cpp

示例10: sendProtocolHeader

void ASIOSocketWrapper::sendProtocolHeader(const MultiplexedSocketPtr&parentMultiSocket, const Address& address,  const UUID&value, unsigned int numConnections) {
//    if (paerntMultiSocket->isZeroDelim()) {
    std::stringstream header;
    header << "GET /" << value.toString() << " HTTP/1.1\r\n";
    header << "Upgrade: WebSocket\r\n";
    header << "Connection: Upgrade\r\n";

    std::string hostname=address.getHostName();
    for (std::string::iterator hi=hostname.begin(),he=hostname.end(); hi!=he; ++hi) {
        *hi=std::tolower(*hi);
    }
    header << "Host: " << hostname;
    if (address.getService()!="80")
        header << ":" << address.getService();
    header << "\r\n";

    header << "Origin: " << address.getHostName() << "\r\n";

    if (parentMultiSocket->getStreamType()!= TCPStream::RFC_6455) {
        header << "Sec-WebSocket-Key1: x!|6 j9  U 1 guf  36Y04  |   4\r\n";
        header << "Sec-WebSocket-Key2: 3   59   2 E4   _11  x80      \r\n";
    } else {
        header << "Sec-WebSocket-Version: 13\r\n";
        header << "Sec-WebSocket-Key: MTIzNDU2Nzg5MGFiY2RlZg==\r\n";
    }
    header << "Sec-WebSocket-Protocol: "
           << (parentMultiSocket->getStreamType()==TCPStream::BASE64_ZERODELIM?"wssst":"sst")
           << numConnections << "\r\n";
    header << "\r\n";
    if (parentMultiSocket->getStreamType()!= TCPStream::RFC_6455) {
        header << "abcdefgh";
    }

    std::string finalHeader(header.str());
    Chunk * headerData= new Chunk(finalHeader.begin(),finalHeader.end());
    rawSend(parentMultiSocket,headerData,true);
    /*
        }else {
            UUID return_value=(parentMultiSocket->isZeroDelim()?massageUUID(UUID::random()):UUID::random());

            Chunk *headerData=new Chunk(TCPStream::TcpSstHeaderSize);
            copyHeader(&*headerData->begin(),parentMultiSocket->isZeroDelim()?TCPStream::WEBSOCKET_STRING_PREFIX():TCPStream::STRING_PREFIX(),value,numConnections);
            rawSend(parentMultiSocket,headerData,true);
        }
    */
}
开发者ID:namwkim,项目名称:sirikata,代码行数:46,代码来源:ASIOSocketWrapper.cpp

示例11: GetSpellById

	void SpellData::GetSpellById(const UUID &id, std::function<void(SpellDataPtr)> success, APIFailureCallback failure)
	{
		APIRequestManager *manager = APIRequestManager::GetDefaultManager();
		std::stringstream url;
		url << "/spell/" << id.toString();

		manager->Send(url.str(), "GET", "", [success](std::istream &stream) {
			Poco::JSON::Parser parser;

			auto object = parser.parse(stream).extract<JSONObject::Ptr>();
			auto data = std::make_shared<SpellData>();
			data->FromJSON(object);

			success(data);

		}, [failure](const std::string &error)  {
			failure(error);
		});
	}
开发者ID:metsfan,项目名称:dungeon-raider,代码行数:19,代码来源:SpellData.cpp

示例12: addMigratedObject

/*
  This is the function that we use to add an object.  generateAck is true if you want to generate an ack message to server idServerAckTo

  If you're initially adding an object to the world, you should use the newObjectAdd function instead.
*/
void CraqObjectSegmentation::addMigratedObject(const UUID& obj_id, float radius, ServerID idServerAckTo, bool generateAck)
{
    if (mStopping)
        return;


    if (generateAck)
    {
        CraqDataKey cdk;
        convert_obj_id_to_dht_key(obj_id,cdk);

        CraqDataSetGet cdSetGet(cdk, CraqEntry(mContext->id(),radius) ,true,CraqDataSetGet::SET);

        receivingObjects_m.lock();
        mReceivingObjects.insert(ObjectSet::value_type(obj_id,CraqEntry(mContext->id(),radius)));
        receivingObjects_m.unlock();

        TrackedSetResultsData tsrd;
        tsrd.migAckMsg = generateAcknowledgeMessage(obj_id, radius, idServerAckTo);
        tsrd.dur =  Time::local() - Time::epoch();

        int trackID = getUniqueTrackID();
        craqDhtSet.set(cdSetGet,trackID);
        trackingMessages[trackID] = tsrd;
    }
    else
    {
        //potentially clean up: we should really only be adding objects without generating acks using the newObjectAdd interface
        CraqDataKey cdk;
        convert_obj_id_to_dht_key(obj_id,cdk);

        CraqDataSetGet cdSetGet(cdk, CraqEntry(mContext->id(),radius) ,false,CraqDataSetGet::SET);
        int trackID = getUniqueTrackID();
        craqDhtSet.set(cdSetGet, trackID);


        std::pair<ObjectSet::iterator, bool> inserted = mObjects.insert(ObjectSet::value_type(obj_id,CraqEntry(mContext->id(),radius)));
        if (inserted.second)
        {
            std::cout<<"\n\nAdding object:  "<<obj_id.toString()<<"\n";
        }
    }
}
开发者ID:pathorn,项目名称:sirikata,代码行数:48,代码来源:CraqObjectSegmentation.cpp

示例13: compareTo

int UUID::compareTo( const UUID& value ) const {
    return apr_strnatcmp( this->toString().c_str(), value.toString().c_str() );
}
开发者ID:WilliamDrewAeroNomos,项目名称:muthur,代码行数:3,代码来源:UUID.cpp

示例14: buildStream


//.........这里部分代码省略.........
            delete socket;
            return;
        }
        std::string head = line.substr(0, colon);
        std::string val = line.substr(colon+2);

        headers[head] = val;

        // Advance to get past the \r\n
        offset += 2;
    }

    if (headers.find("Host") == headers.end() ||
        headers.find("Origin") == headers.end() ||
        headers.find("Sec-WebSocket-Key1") == headers.end() ||
        headers.find("Sec-WebSocket-Key2") == headers.end())
    {
        SILOG(tcpsst,warning,"Connection request didn't specify all required fields.");
        delete socket;
        return;
    }

    std::string host = headers["Host"];
    std::string origin = headers["Origin"];
    std::string protocol = "wssst1";
    if (headers.find("Sec-WebSocket-Protocol") != headers.end())
        protocol = headers["Sec-WebSocket-Protocol"];
    std::string key1 = headers["Sec-WebSocket-Key1"];
    std::string key2 = headers["Sec-WebSocket-Key2"];
    std::string key3 = buffer_str.substr(bytes_transferred - 8);
    assert(key3.size() == 8);

    std::string reply_str = getWebSocketSecReply(key1, key2, key3);

    bool binaryStream=protocol.find("sst")==0;
    bool base64Stream=!binaryStream;
    boost::asio::ip::tcp::no_delay option(data->mNoDelay);
    socket->set_option(option);
    IncompleteStreamMap::iterator where=sIncompleteStreams.find(context);

    unsigned int numConnections=1;

    for (std::string::iterator i=protocol.begin(),ie=protocol.end();i!=ie;++i) {
        if (*i>='0'&&*i<='9') {
            char* endptr=NULL;
            const char *start=protocol.c_str();
            size_t offset=(i-protocol.begin());
            start+=offset;
            numConnections=strtol(start,&endptr,10);
            size_t numberlen=endptr-start;
            if (numConnections>data->mMaxSimultaneousSockets) {
                numConnections=data->mMaxSimultaneousSockets;
                char numcon[256];
                sprintf(numcon,"%d",numConnections);
                protocol=protocol.substr(0,offset)+numcon+protocol.substr(offset+numberlen);
            }
            break;
        }
    }

    if (where==sIncompleteStreams.end()){
        sIncompleteStreams[context].mNumSockets=numConnections;
        where=sIncompleteStreams.find(context);
        assert(where!=sIncompleteStreams.end());
        // Setup a timer to clean up the sockets if we don't complete it in time
        data->strand->post(
            Duration::seconds(10),
            std::tr1::bind(&handleBuildStreamTimeout, context)
        );
    }
    if ((int)numConnections!=where->second.mNumSockets) {
        SILOG(tcpsst,warning,"Single client disagrees on number of connections to establish: "<<numConnections<<" != "<<where->second.mNumSockets);
        sIncompleteStreams.erase(where);
    }else {
        where->second.mSockets.push_back(socket);
        where->second.mWebSocketResponses[socket] = reply_str;
        if (numConnections==(unsigned int)where->second.mSockets.size()) {
            MultiplexedSocketPtr shared_socket(
                MultiplexedSocket::construct<MultiplexedSocket>(data->strand,context,data->cb,base64Stream));
            shared_socket->initFromSockets(where->second.mSockets,data->mSendBufferSize);
            std::string port=shared_socket->getASIOSocketWrapper(0).getLocalEndpoint().getService();
            std::string resource_name='/'+context.toString();
            MultiplexedSocket::sendAllProtocolHeaders(shared_socket,origin,host,port,resource_name,protocol, where->second.mWebSocketResponses);
            sIncompleteStreams.erase(where);


            Stream::StreamID newID=Stream::StreamID(1);
            TCPStream * strm=new TCPStream(shared_socket,newID);

            TCPSetCallbacks setCallbackFunctor(&*shared_socket,strm);
            data->cb(strm,setCallbackFunctor);
            if (setCallbackFunctor.mCallbacks==NULL) {
                SILOG(tcpsst,error,"Client code for stream "<<newID.read()<<" did not set listener on socket");
                shared_socket->closeStream(shared_socket,newID);
            }
        }else{
            sStaleUUIDs.push_back(context);
        }
    }
}
开发者ID:pathorn,项目名称:sirikata,代码行数:101,代码来源:ASIOStreamBuilder.cpp

示例15: Error

Try<RunState> RunState::recover(
    const string& rootDir,
    const SlaveID& slaveId,
    const FrameworkID& frameworkId,
    const ExecutorID& executorId,
    const UUID& uuid,
    bool strict)
{
  RunState state;
  state.id = uuid;
  string message;

  // Find the tasks.
  const Try<list<string> >& tasks = os::glob(strings::format(
      paths::TASK_PATH,
      rootDir,
      slaveId,
      frameworkId,
      executorId,
      uuid.toString(),
      "*").get());

  if (tasks.isError()) {
    return Error("Failed to find tasks for executor run " + uuid.toString() +
                 ": " + tasks.error());
  }

  // Recover tasks.
  foreach (const string& path, tasks.get()) {
    TaskID taskId;
    taskId.set_value(os::basename(path).get());

    const Try<TaskState>& task = TaskState::recover(
        rootDir, slaveId, frameworkId, executorId, uuid, taskId, strict);

    if (task.isError()) {
      return Error(
          "Failed to recover task " + taskId.value() + ": " + task.error());
    }

    state.tasks[taskId] = task.get();
  }

  // Read the forked pid.
  string path = paths::getForkedPidPath(
      rootDir, slaveId, frameworkId, executorId, uuid);

  Try<string> pid = os::read(path);

  if (pid.isError()) {
    message = "Failed to read executor's forked pid from '" + path +
              "': " + pid.error();

    if (strict) {
      return Error(message);
    } else {
      LOG(WARNING) << message;
      return state;
    }
  }

  Try<pid_t> forkedPid = numify<pid_t>(pid.get());
  if (forkedPid.isError()) {
    return Error("Failed to parse forked pid " + pid.get() +
                 ": " + forkedPid.error());
  }

  state.forkedPid = forkedPid.get();

  // Read the libprocess pid.
  path = paths::getLibprocessPidPath(
      rootDir, slaveId, frameworkId, executorId, uuid);

  pid = os::read(path);

  if (pid.isError()) {
    message = "Failed to read executor's libprocess pid from '" + path +
              "': " + pid.error();

    if (strict) {
      return Error(message);
    } else {
      LOG(WARNING) << message;
      return state;
    }
  }

  state.libprocessPid = process::UPID(pid.get());

  return state;
}
开发者ID:WuErPing,项目名称:mesos,代码行数:91,代码来源:state.cpp


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