本文整理汇总了C++中StringHash函数的典型用法代码示例。如果您正苦于以下问题:C++ StringHash函数的具体用法?C++ StringHash怎么用?C++ StringHash使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了StringHash函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MakePair
SharedPtr<Technique> Technique::CloneWithDefines(const String& vsDefines, const String& psDefines)
{
// Return self if no actual defines
if (vsDefines.Empty() && psDefines.Empty())
return SharedPtr<Technique>(this);
Pair<StringHash, StringHash> key = MakePair(StringHash(vsDefines), StringHash(psDefines));
// Return existing if possible
HashMap<Pair<StringHash, StringHash>, SharedPtr<Technique> >::Iterator i = cloneTechniques_.Find(key);
if (i != cloneTechniques_.End())
return i->second_;
// Set same name as the original for the clones to ensure proper serialization of the material. This should not be a problem
// since the clones are never stored to the resource cache
i = cloneTechniques_.Insert(MakePair(key, Clone(GetName())));
for (Vector<SharedPtr<Pass> >::ConstIterator j = i->second_->passes_.Begin(); j != i->second_->passes_.End(); ++j)
{
Pass* pass = (*j);
if (!pass)
continue;
if (!vsDefines.Empty())
pass->SetVertexShaderDefines(pass->GetVertexShaderDefines() + " " + vsDefines);
if (!psDefines.Empty())
pass->SetPixelShaderDefines(pass->GetPixelShaderDefines() + " " + psDefines);
}
return i->second_;
}
示例2: onWrite
static size_t onWrite(char *ptr, size_t size, size_t nmemb, void *userdata)
{
WebRequestInternalState *is_(reinterpret_cast<WebRequestInternalState*>(userdata));
is_->state = HTTP_OPEN;
if (is_->isAborted)
{
is_->state = HTTP_CLOSED;
// This should probably be CURL_WRITEFUNC_ABORT, but that doesn't
// exist. It probably would be the same numeric value, if it did.
// The docs say that it just has to be a number of bytes that is
// not "size * nmemb" to abort.
return CURL_READFUNC_ABORT;
}
// Find the size in bytes.
size_t real_size(size * nmemb);
// Write the date into the download buffer queue.
Serializer* download(dynamic_cast<Serializer*>(is_->download.Get()));
download->Write(ptr, (unsigned int)real_size);
// Emit a "download_chunk" event.
VariantMap eventData;
eventData.Insert(MakePair(StringHash("download"), Variant(is_->download)));
eventData.Insert(MakePair(StringHash("size"), Variant((unsigned int)real_size)));
is_->es.SendEvent("download_chunk", eventData);
return real_size;
}
示例3: StringHash
ea::shared_ptr<Technique> Technique::CloneWithDefines(const ea::string& vsDefines, const ea::string& psDefines)
{
// Return self if no actual defines
if (vsDefines.empty() && psDefines.empty())
return ea::shared_ptr<Technique>(this);
ea::pair<StringHash, StringHash> key = ea::make_pair(StringHash(vsDefines), StringHash(psDefines));
// Return existing if possible
auto i = cloneTechniques_.find(key);
if (i != cloneTechniques_.end())
return i->second;
// Set same name as the original for the clones to ensure proper serialization of the material. This should not be a problem
// since the clones are never stored to the resource cache
i = cloneTechniques_.insert(ea::make_pair(key, Clone(GetName()))).first;
for (auto j = i->second->passes_.begin(); j != i->second->passes_.end(); ++j)
{
Pass* pass = (*j);
if (!pass)
continue;
if (!vsDefines.empty())
pass->SetVertexShaderDefines(pass->GetVertexShaderDefines() + " " + vsDefines);
if (!psDefines.empty())
pass->SetPixelShaderDefines(pass->GetPixelShaderDefines() + " " + psDefines);
}
return i->second;
}
示例4: update_scene
void update_scene()
{
main_context::access(m_server, [&](main_context::Interface *imc)
{
Scene *scene = imc->check_scene(m_main_scene);
Context *context = scene->GetContext();
ResourceCache *cache = context->GetSubsystem<ResourceCache>();
{
Node *n = scene->GetChild("Base");
n->SetScale(Vector3(1.0f, 1.0f, 1.0f));
//n->SetPosition(Vector3(0.0f, 0.5f, 0.0f));
n->SetPosition(Vector3(0.0f, 0.5f, 0.0f));
//n->SetRotation(Quaternion(0, 90, 0));
int w = 10, h = 3, d = 10;
ss_ data =
"222222222211211111211111111111"
"222222222211111111111111111111"
"222222222211111111111111111111"
"222222222211111111111111111111"
"222222222211122111111112111111"
"222233222211123111111112111111"
"222233222211111111111111111111"
"222222222211111111111111111111"
"222222222211111111111111111111"
"222222222211111111111111111111"
;
// Convert data to the actually usable voxel type id namespace
// starting from VOXELTYPEID_UNDEFINED=0
for(size_t i = 0; i < data.size(); i++){
data[i] = data[i] - '0';
}
// Crude way of dynamically defining a voxel model
n->SetVar(StringHash("simple_voxel_data"), Variant(
PODVector<uint8_t>((const uint8_t*)data.c_str(),
data.size())));
n->SetVar(StringHash("simple_voxel_w"), Variant(w));
n->SetVar(StringHash("simple_voxel_h"), Variant(h));
n->SetVar(StringHash("simple_voxel_d"), Variant(d));
// Load the same model in here and give it to the physics
// subsystem so that it can be collided to
SharedPtr<Model> model(interface::mesh::
create_8bit_voxel_physics_model(context, w, h, d, data,
m_voxel_reg.get()));
RigidBody *body = n->CreateComponent<RigidBody>(LOCAL);
body->SetFriction(0.75f);
CollisionShape *shape = n->CreateComponent<CollisionShape>(
LOCAL);
shape->SetTriangleMesh(model, 0, Vector3::ONE);
}
});
}
示例5: onRead
static size_t onRead(char *buffer, size_t size, size_t nitems, void *instream)
{
WebRequestInternalState *is_(reinterpret_cast<WebRequestInternalState*>(instream));
is_->state = HTTP_OPEN;
if (is_->isAborted)
{
is_->state = HTTP_CLOSED;
return CURL_READFUNC_ABORT;
}
// Find the size in bytes.
size_t real_size(size * nitems);
// Read as much as we can from the upload buffer queue.
Deserializer* upload(dynamic_cast<Deserializer*>(is_->upload.Get()));
size_t size_queued(upload->GetSize());
size_t size_left(real_size);
if ((size_left > 0) && (size_queued > 0))
{
size_t read_size(std::min(size_queued, size_left));
upload->Read(buffer, (unsigned int)read_size);
size_left -= read_size;
}
// If we still have bytes to fill, then emit a "upload_chunk" event.
if (size_left > 0)
{
VariantMap eventData;
eventData.Insert(MakePair(StringHash("upload"), Variant(is_->upload)));
eventData.Insert(MakePair(StringHash("size"), Variant((unsigned int)size_left)));
is_->es.SendEvent("upload_chunk", eventData);
}
// Read as much as we can from the upload buffer queue (again).
size_queued = upload->GetSize();
size_left = real_size;
if ((size_left > 0) && (size_queued > 0))
{
size_t read_size(std::min(size_queued, size_left));
upload->Read(buffer, (unsigned int)read_size);
size_left -= read_size;
}
// If we still have bytes to fill, then something went wrong, so we should abort.
if (size_left > 0)
{
is_->isAborted = true;
return CURL_READFUNC_ABORT;
}
return real_size;
}
示例6: CreateProperty
void LFO::CreateProperty(UnsignedType aPropertyID, Property *aProperty)
{
/* Shared Property Instantiation */
if (aPropertyID == StringHash("Wave Type", true))
{
m_Type = NumberProperty<UnsignedType>::New(aProperty);
return;
}
if (aPropertyID == StringHash("Frequency", true))
{
m_Freq = NumberProperty<FloatType>::New(aProperty);
return;
}
}
示例7: postMessage
void WindowButton::onMenuUp()
{
m_Flags &= ~DEPRESSED;
// post message to listeners
postMessage( WB_MENUUP, StringHash( name() ), 0 );
}
示例8: StringHash
void Node::SetName(const String& name)
{
name_ = name;
nameHash_ = StringHash(name);
MarkNetworkUpdate();
}
示例9: SelectClass
static bool SelectClass(EvalContext *ctx, const Rlist *list, const Promise *pp)
{
int count = 0;
for (const Rlist *rp = list; rp != NULL; rp = rp->next)
{
count++;
}
if (count == 0)
{
Log(LOG_LEVEL_ERR, "No classes to select on RHS");
PromiseRef(LOG_LEVEL_ERR, pp);
return false;
}
assert(list);
char splay[CF_MAXVARSIZE];
snprintf(splay, CF_MAXVARSIZE, "%s+%s+%ju",
VFQNAME, VIPADDRESS, (uintmax_t)getuid());
double hash = (double) StringHash(splay, 0, CF_HASHTABLESIZE);
assert(hash < CF_HASHTABLESIZE);
int n = (int) (count * hash / (double) CF_HASHTABLESIZE);
assert(n < count);
while (n > 0 && list->next != NULL)
{
n--;
list = list->next;
}
EvalContextClassPutSoft(ctx, RlistScalarValue(list),
CONTEXT_SCOPE_NAMESPACE, "source=promise");
return true;
}
示例10: onEnd
void onEnd(int code)
{
VariantMap eventData;
if (code != CURLE_OK)
{
state = HTTP_ERROR;
eventData.Insert(MakePair(StringHash("error"), Variant(String(error, (unsigned int)strnlen(error, sizeof(error))))));
}
else
{
state = HTTP_CLOSED;
eventData.Insert(MakePair(StringHash("download"), Variant(download)));
eventData.Insert(MakePair(StringHash("upload"), Variant(upload)));
}
es.SendEvent("complete", eventData);
}
示例11: SetInterpolationMethod
bool ValueAnimation::LoadJSON(const JSONValue& source)
{
valueType_ = VAR_NONE;
eventFrames_.Clear();
String interpMethodString = source.Get("interpolationmethod").GetString();
InterpMethod method = (InterpMethod)GetStringListIndex(interpMethodString.CString(), interpMethodNames, IM_LINEAR);
SetInterpolationMethod(method);
if (interpolationMethod_ == IM_SPLINE)
splineTension_ = source.Get("splinetension").GetFloat();
// Load keyframes
JSONArray keyFramesArray = source.Get("keyframes").GetArray();
for (unsigned i = 0; i < keyFramesArray.Size(); i++)
{
const JSONValue& val = keyFramesArray[i];
float time = val.Get("time").GetFloat();
Variant value = val.Get("value").GetVariant();
SetKeyFrame(time, value);
}
// Load event frames
JSONArray eventFramesArray = source.Get("eventframes").GetArray();
for (unsigned i = 0; i < eventFramesArray.Size(); i++)
{
const JSONValue& eventFrameVal = eventFramesArray[i];
float time = eventFrameVal.Get("time").GetFloat();
unsigned eventType = eventFrameVal.Get("eventtype").GetUInt();
VariantMap eventData = eventFrameVal.Get("eventdata").GetVariantMap();
SetEventFrame(time, StringHash(eventType), eventData);
}
return true;
}
示例12: URHO3D_LOGWARNING
QString Localization::Get(const QString& id)
{
if (id.isEmpty())
return s_dummy;
if (GetNumLanguages() == 0)
{
URHO3D_LOGWARNING("Localization::Get(id): no loaded languages");
return id;
}
QString result = strings_[StringHash(GetLanguage())][StringHash(id)];
if (result.isEmpty())
{
URHO3D_LOGWARNING("Localization::Get(\"" + id + "\") not found translation, language=\"" + GetLanguage() + "\"");
return id;
}
return result;
}
示例13: LOGWARNING
String Localization::Get(const String& id)
{
if (id.Empty())
return String::EMPTY;
if (GetNumLanguages() == 0)
{
LOGWARNING("Localization::Get(id): no loaded languages");
return id;
}
String result = strings_[StringHash(GetLanguage())][StringHash(id)];
if (result.Empty())
{
LOGWARNING("Localization::Get(\"" + id + "\") not found translation, language=\"" + GetLanguage() + "\"");
return id;
}
return result;
}
示例14: LockEnabled
int LockEnabled()
{
int retval = 1;
HookCallbacks::RunCallback(StringHash("mouseLock"), &retval);
return retval;
}
示例15: SanitateResourceName
Resource* ResourceCache::GetResource(ShortStringHash type, const String& nameIn)
{
String name = SanitateResourceName(nameIn);
// Add the name to the hash map, so if this is an unknown resource, the error will not be unintelligible
StoreNameHash(name);
return GetResource(type, StringHash(name));
}