本文整理汇总了C++中UUID类的典型用法代码示例。如果您正苦于以下问题:C++ UUID类的具体用法?C++ UUID怎么用?C++ UUID使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了UUID类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getTaskInfoPath
inline std::string getTaskInfoPath(
const std::string& rootDir,
const SlaveID& slaveId,
const FrameworkID& frameworkId,
const ExecutorID& executorId,
const UUID& executorUUID,
const TaskID& taskId)
{
return strings::format(
TASK_INFO_PATH,
rootDir,
slaveId,
frameworkId,
executorId,
executorUUID.toString(),
taskId).get();
}
示例2: finalHeader
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);
}
*/
}
示例3: 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";
}
}
}
示例4: 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);
});
}
示例5: make_pair
std::pair<BSONObj, RecordId> RollbackTest::makeCRUDOp(OpTypeEnum opType,
Timestamp ts,
UUID uuid,
StringData nss,
BSONObj o,
boost::optional<BSONObj> o2,
int recordId) {
invariant(opType != OpTypeEnum::kCommand);
BSONObjBuilder bob;
bob.append("ts", ts);
bob.append("op", OpType_serializer(opType));
uuid.appendToBuilder(&bob, "ui");
bob.append("ns", nss);
bob.append("o", o);
if (o2) {
bob.append("o2", *o2);
}
return std::make_pair(bob.obj(), RecordId(recordId));
}
示例6: locker
ModuleSP
ModuleList::FindModule (const UUID &uuid) const
{
ModuleSP module_sp;
if (uuid.IsValid())
{
Mutex::Locker locker(m_modules_mutex);
collection::const_iterator pos, end = m_modules.end();
for (pos = m_modules.begin(); pos != end; ++pos)
{
if ((*pos)->GetUUID() == uuid)
{
module_sp = (*pos);
break;
}
}
}
return module_sp;
}
示例7: performUpdate
void SQLitePersistedObjectSet::performUpdate(const UUID& internal_id, const String& script_type, const String& script_args, const String& script_contents, RequestCallback cb) {
bool success = true;
int rc;
char* remain;
String value_insert;
value_insert = "INSERT OR REPLACE INTO ";
value_insert += "\"" TABLE_NAME "\"";
value_insert += " (object, script_type, script_args, script_contents) VALUES(?, ?, ?, ?)";
sqlite3_stmt* value_insert_stmt;
rc = sqlite3_prepare_v2(mDB->db(), value_insert.c_str(), -1, &value_insert_stmt, (const char**)&remain);
success = success && !SQLite::check_sql_error(mDB->db(), rc, NULL, "Error preparing value insert statement");
String id_str = internal_id.rawHexData();
rc = sqlite3_bind_text(value_insert_stmt, 1, id_str.c_str(), (int)id_str.size(), SQLITE_TRANSIENT);
success = success && !SQLite::check_sql_error(mDB->db(), rc, NULL, "Error binding object internal ID to value insert statement");
rc = sqlite3_bind_text(value_insert_stmt, 2, script_type.c_str(), (int)script_type.size(), SQLITE_TRANSIENT);
success = success && !SQLite::check_sql_error(mDB->db(), rc, NULL, "Error binding script_type name to value insert statement");
rc = sqlite3_bind_blob(value_insert_stmt, 3, script_args.c_str(), (int)script_args.size(), SQLITE_TRANSIENT);
success = success && !SQLite::check_sql_error(mDB->db(), rc, NULL, "Error binding script_args to value insert statement");
rc = sqlite3_bind_blob(value_insert_stmt, 4, script_contents.c_str(), (int)script_contents.size(), SQLITE_TRANSIENT);
success = success && !SQLite::check_sql_error(mDB->db(), rc, NULL, "Error binding script_contents to value insert statement");
int step_rc = SQLITE_OK;
while(step_rc == SQLITE_OK) {
step_rc = sqlite3_step(value_insert_stmt);
}
if (step_rc != SQLITE_OK && step_rc != SQLITE_DONE) {
success = false;
sqlite3_reset(value_insert_stmt); // allow this to be cleaned
// up
}
rc = sqlite3_finalize(value_insert_stmt);
success = success && !SQLite::check_sql_error(mDB->db(), rc, NULL, "Error finalizing value insert statement");
if (cb != 0)
mContext->mainStrand->post(std::tr1::bind(cb, success), "SQLitePersistedObjectSet::performUpdate callback");
}
示例8: setupVariadicParameters
void SubgraphNode::setupParameters(Parameterizable& params)
{
setupVariadicParameters(params);
params.addParameter(param::factory::declareBool("iterate_containers", param::ParameterDescription("When true, input vectors will be iterated internally"), false));
std::map<std::string, std::pair<int, bool> > flags;
iterated_inputs_param_ = std::dynamic_pointer_cast<param::BitSetParameter>(param::factory::declareParameterBitSet("iterated_containers", flags).build());
params.addConditionalParameter(iterated_inputs_param_, [this]() { return readParameter<bool>("iterate_containers"); },
[this](param::Parameter* p) {
for (auto& pair : relay_to_external_input_) {
UUID id = pair.second;
InputPtr i = node_handle_->getInput(id);
apex_assert_hard(i);
bool iterate = iterated_inputs_param_->isSet(id.getFullName());
setIterationEnabled(id, iterate);
}
});
}
示例9: JoinPath
ModuleLock::ModuleLock(const FileSpec &root_dir_spec, const UUID &uuid,
Error &error) {
const auto lock_dir_spec = JoinPath(root_dir_spec, kLockDirName);
error = MakeDirectory(lock_dir_spec);
if (error.Fail())
return;
m_file_spec = JoinPath(lock_dir_spec, uuid.GetAsString().c_str());
m_file.Open(m_file_spec.GetCString(), File::eOpenOptionWrite |
File::eOpenOptionCanCreate |
File::eOpenOptionCloseOnExec);
if (!m_file) {
error.SetErrorToErrno();
return;
}
m_lock.reset(new lldb_private::LockFile(m_file.GetDescriptor()));
error = m_lock->WriteLock(0, 1);
if (error.Fail())
error.SetErrorStringWithFormat("Failed to lock file: %s",
error.AsCString());
}
示例10: equals
bool UUID::equals( const UUID& value ) const {
return this->getMostSignificantBits() == value.getMostSignificantBits() &&
this->getLeastSignificantBits() == value.getLeastSignificantBits();
}
示例11: compareTo
int UUID::compareTo( const UUID& value ) const {
return apr_strnatcmp( this->toString().c_str(), value.toString().c_str() );
}
示例12: m_name
//.........这里部分代码省略.........
// "definition.default_uint_value" is the default enumeration value if
// "definition.default_cstr_value" is NULL, otherwise interpret
// "definition.default_cstr_value" as a string value that represents the default
// value.
{
OptionValueEnumeration *enum_value = new OptionValueEnumeration(definition.enum_values, definition.default_uint_value);
m_value_sp.reset (enum_value);
if (definition.default_cstr_value)
{
if (enum_value->SetValueFromCString(definition.default_cstr_value).Success())
{
enum_value->SetDefaultValue(enum_value->GetCurrentValue());
// Call Clear() since we don't want the value to appear as
// having been set since we called SetValueFromCString() above.
// Clear will set the current value to the default and clear
// the boolean that says that the value has been set.
enum_value->Clear();
}
}
}
break;
case OptionValue::eTypeFileSpec:
// "definition.default_uint_value" represents if the "definition.default_cstr_value" should
// be resolved or not
m_value_sp.reset (new OptionValueFileSpec(FileSpec(definition.default_cstr_value, definition.default_uint_value != 0)));
break;
case OptionValue::eTypeFileSpecList:
// "definition.default_uint_value" is not used for a OptionValue::eTypeFileSpecList
m_value_sp.reset (new OptionValueFileSpecList());
break;
case OptionValue::eTypeFormat:
// "definition.default_uint_value" is the default format enumeration value if
// "definition.default_cstr_value" is NULL, otherwise interpret
// "definition.default_cstr_value" as a string value that represents the default
// value.
{
Format new_format = eFormatInvalid;
if (definition.default_cstr_value)
Args::StringToFormat (definition.default_cstr_value, new_format, nullptr);
else
new_format = (Format)definition.default_uint_value;
m_value_sp.reset (new OptionValueFormat(new_format));
}
break;
case OptionValue::eTypePathMap:
// "definition.default_uint_value" tells us if notifications should occur for
// path mappings
m_value_sp.reset (new OptionValuePathMappings(definition.default_uint_value != 0));
break;
case OptionValue::eTypeRegex:
// "definition.default_uint_value" is used to the regular expression flags
// "definition.default_cstr_value" the default regular expression value
// value.
m_value_sp.reset (new OptionValueRegex(definition.default_cstr_value, definition.default_uint_value));
break;
case OptionValue::eTypeSInt64:
// "definition.default_uint_value" is the default integer value if
// "definition.default_cstr_value" is NULL, otherwise interpret
// "definition.default_cstr_value" as a string value that represents the default
// value.
m_value_sp.reset (new OptionValueSInt64(definition.default_cstr_value ? Args::StringToSInt64 (definition.default_cstr_value) : definition.default_uint_value));
break;
case OptionValue::eTypeUInt64:
// "definition.default_uint_value" is the default unsigned integer value if
// "definition.default_cstr_value" is NULL, otherwise interpret
// "definition.default_cstr_value" as a string value that represents the default
// value.
m_value_sp.reset (new OptionValueUInt64(definition.default_cstr_value ? Args::StringToUInt64 (definition.default_cstr_value) : definition.default_uint_value));
break;
case OptionValue::eTypeUUID:
// "definition.default_uint_value" is not used for a OptionValue::eTypeUUID
// "definition.default_cstr_value" can contain a default UUID value
{
UUID uuid;
if (definition.default_cstr_value)
uuid.SetFromCString (definition.default_cstr_value);
m_value_sp.reset (new OptionValueUUID(uuid));
}
break;
case OptionValue::eTypeString:
// "definition.default_uint_value" can contain the string option flags OR'ed together
// "definition.default_cstr_value" can contain a default string value
{
OptionValueString *string_value = new OptionValueString(definition.default_cstr_value);
if (definition.default_uint_value != 0)
string_value->GetOptions().Reset(definition.default_uint_value);
m_value_sp.reset (string_value);
}
break;
}
}
示例13: convert_obj_id_to_dht_key
void CraqObjectSegmentation::convert_obj_id_to_dht_key(const UUID& obj_id, CraqDataKey& returner) const
{
returner[0] = myUniquePrefixKey;
strncpy(returner+1,obj_id.rawHexData().c_str(),obj_id.rawHexData().size() + 1);
}
示例14: CONTEXT_SPACETRACE
/*
If we get a message to move an object that our server holds, then we add the object's id to mInTransit.
Whatever calls this must verify that the object is on this server.
I can do the check in the function by querrying bambooDht as well
*/
void CraqObjectSegmentation::migrateObject(const UUID& obj_id, const OSegEntry& new_server_id)
{
if (mStopping)
return;
//log the message.
CONTEXT_SPACETRACE(objectBeginMigrate,
obj_id,mContext->id(),
new_server_id.server());
InTransitMap::const_iterator transIter = mInTransitOrLookup.find(obj_id);
TransLookup tmpTransLookup;
tmpTransLookup.sID = CraqEntry(new_server_id);
Duration tmpDurer = Time::local() - Time::epoch();
tmpTransLookup.timeAdmitted = (int)tmpDurer.toMilliseconds();
mInTransitOrLookup[obj_id] = tmpTransLookup;
//erases the local copy of obj_id
UUID tmp_id = obj_id; //note: can probably delete this line
//erase the local copy of the object.
size_t num_erased = mObjects.erase(obj_id);
#ifdef CRAQ_DEBUG
if (num_erased == 0)
{
std::cout<<"\n\nThe object clearly wasn't registered on this server. This is obj id: " << obj_id.toString() << ". This is time: " <<mContext->simTime().raw() << " Oh no. ";
if (clearToMigrate(obj_id))
std::cout<<" Likely a problem with clear to migrate\n\n";
else
std::cout<<"\n\n clear to migrate is fine migration is being called from somewhere besides server.cpp\n\n";
}
#endif
}
示例15: tmp
dmz::Config
dmz::ArchivePluginObject::_archive_object (const Handle ObjectHandle) {
Config result;
ObjectModule *objMod (get_object_module ());
if (objMod) {
Config tmp ("object");
Boolean archiveObject (True);
const ObjectType Type (objMod->lookup_object_type (ObjectHandle));
if (Type) {
if (_currentFilterList) {
FilterStruct *filter = _currentFilterList->list;
while (filter) {
if (filter->mode & LocalExportMask) {
if (filter->exTypes.get_count () &&
filter->exTypes.contains_type (Type)) {
archiveObject = False;
filter = 0;
}
if (filter && filter->inTypes.get_count () &&
!filter->inTypes.contains_type (Type)) {
archiveObject = False;
filter = 0;
}
}
if (filter) { filter = filter->next; }
}
}
}
else { archiveObject = False; }
if (archiveObject) {
tmp.store_attribute ("type", Type.get_name ());
UUID uuid;
if (objMod->lookup_uuid (ObjectHandle, uuid)) {
tmp.store_attribute ("uuid", uuid.to_string ());
}
_currentConfig = result = tmp;
objMod->dump_all_object_attributes (ObjectHandle, *this);
}
}
_attrTable.empty ();
_currentConfig.set_config_context (0);
return result;
}