本文整理汇总了C++中HashMap类的典型用法代码示例。如果您正苦于以下问题:C++ HashMap类的具体用法?C++ HashMap怎么用?C++ HashMap使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了HashMap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ASSERT
MutationObserverInterestGroup::MutationObserverInterestGroup(HashMap<WebKitMutationObserver*, MutationRecordDeliveryOptions>& observers, MutationRecordDeliveryOptions oldValueFlag)
: m_oldValueFlag(oldValueFlag)
{
ASSERT(!observers.isEmpty());
m_observers.swap(observers);
}
示例2: update_tree
void CreateDialog::update_tree() {
tree->clear();
List<String> type_list;
ObjectTypeDB::get_type_list(&type_list);
HashMap<String,TreeItem*> types;
TreeItem *root = tree->create_item();
root->set_text(0,base);
List<String>::Element *I=type_list.front();
for(;I;I=I->next()) {
String type=I->get();
if (!ObjectTypeDB::can_instance(type))
continue; // cant create what can't be instanced
if (filter->get_text()=="")
add_type(type,types,root);
else {
bool found=false;
String type=I->get();
while(type!="" && ObjectTypeDB::is_type(type,base) && type!=base) {
if (type.findn(filter->get_text())!=-1) {
found=true;
break;
}
type=ObjectTypeDB::type_inherits_from(type);
}
if (found)
add_type(I->get(),types,root);
}
if (EditorNode::get_editor_data().get_custom_types().has(type)) {
//there are custom types based on this... cool.
const Vector<EditorData::CustomType> &ct = EditorNode::get_editor_data().get_custom_types()[type];
for(int i=0;i<ct.size();i++) {
bool show = filter->get_text()=="" || ct[i].name.findn(filter->get_text())!=-1;
if (!show)
continue;
if (!types.has(type))
add_type(type,types,root);
TreeItem *ti;
if (types.has(type) )
ti=types[type];
else
ti=tree->get_root();
TreeItem *item = tree->create_item(ti);
item->set_metadata(0,type);
item->set_text(0,ct[i].name);
if (ct[i].icon.is_valid()) {
item->set_icon(0,ct[i].icon);
}
}
}
}
}
示例3: getDeletedPlugins
bool PluginDatabase::refresh()
{
bool pluginSetChanged = false;
if (!m_plugins.isEmpty()) {
PluginSet pluginsToUnload;
getDeletedPlugins(pluginsToUnload);
// Unload plugins
PluginSet::const_iterator end = pluginsToUnload.end();
for (PluginSet::const_iterator it = pluginsToUnload.begin(); it != end; ++it)
remove(it->get());
pluginSetChanged = !pluginsToUnload.isEmpty();
}
HashSet<String> paths;
getPluginPathsInDirectories(paths);
HashMap<String, time_t> pathsWithTimes;
// We should only skip unchanged files if we didn't remove any plugins above. If we did remove
// any plugins, we need to look at every plugin file so that, e.g., if the user has two versions
// of RealPlayer installed and just removed the newer one, we'll pick up the older one.
bool shouldSkipUnchangedFiles = !pluginSetChanged;
HashSet<String>::const_iterator pathsEnd = paths.end();
for (HashSet<String>::const_iterator it = paths.begin(); it != pathsEnd; ++it) {
time_t lastModified;
if (!getFileModificationTime(*it, lastModified))
continue;
pathsWithTimes.add(*it, lastModified);
// If the path's timestamp hasn't changed since the last time we ran refresh(), we don't have to do anything.
if (shouldSkipUnchangedFiles && m_pluginPathsWithTimes.get(*it) == lastModified)
continue;
if (RefPtr<PluginPackage> oldPackage = m_pluginsByPath.get(*it)) {
ASSERT(!shouldSkipUnchangedFiles || oldPackage->lastModified() != lastModified);
remove(oldPackage.get());
}
if (!m_client || m_client->shouldLoadPluginAtPath(*it)) {
RefPtr<PluginPackage> package = PluginPackage::createPackage(*it, lastModified);
if (package && (!m_client || m_client->shouldLoadPluginPackage(package.get())) && add(package.release()))
pluginSetChanged = true;
}
}
// Cache all the paths we found with their timestamps for next time.
pathsWithTimes.swap(m_pluginPathsWithTimes);
if (!pluginSetChanged)
return false;
m_registeredMIMETypes.clear();
// Register plug-in MIME types
PluginSet::const_iterator end = m_plugins.end();
for (PluginSet::const_iterator it = m_plugins.begin(); it != end; ++it) {
// Get MIME types
MIMEToDescriptionsMap::const_iterator map_it = (*it)->mimeToDescriptions().begin();
MIMEToDescriptionsMap::const_iterator map_end = (*it)->mimeToDescriptions().end();
for (; map_it != map_end; ++map_it)
m_registeredMIMETypes.add(map_it->first);
}
return true;
}
示例4: adoptRef
namespace WebCore {
static int s_maxTextureSize = 0;
static HashMap<int, CanvasTexture*> s_textures;
static android::Mutex s_texturesLock;
/********************************************
* Called by both threads
********************************************/
PassRefPtr<CanvasTexture> CanvasTexture::getCanvasTexture(CanvasLayer* layer)
{
android::Mutex::Autolock lock(s_texturesLock);
RefPtr<CanvasTexture> texture = s_textures.get(layer->uniqueId());
if (texture.get())
return texture.release();
return adoptRef(new CanvasTexture(layer->uniqueId()));
}
bool CanvasTexture::setHwAccelerated(bool hwAccelerated)
{
android::Mutex::Autolock lock(m_surfaceLock);
if (m_useHwAcceleration == hwAccelerated)
return false;
m_useHwAcceleration = hwAccelerated;
if (!m_ANW.get())
return false;
destroySurfaceTextureLocked();
return true;
}
/********************************************
* Called by WebKit thread
********************************************/
void CanvasTexture::setSize(const IntSize& size)
{
android::Mutex::Autolock lock(m_surfaceLock);
if (m_size == size)
return;
m_size = size;
if (m_ANW.get()) {
if (useSurfaceTexture()) {
int result = native_window_set_buffers_dimensions(m_ANW.get(),
m_size.width(), m_size.height());
GLUtils::checkSurfaceTextureError("native_window_set_buffers_dimensions", result);
if (result != NO_ERROR)
m_useHwAcceleration = false; // On error, drop out of HWA
}
if (!useSurfaceTexture())
destroySurfaceTextureLocked();
}
}
SurfaceTextureClient* CanvasTexture::nativeWindow()
{
android::Mutex::Autolock lock(m_surfaceLock);
if (m_ANW.get())
return m_ANW.get();
if (!m_texture)
return 0;
if (!useSurfaceTexture())
return 0;
m_surfaceTexture = new android::SurfaceTexture(m_texture, false);
m_ANW = new android::SurfaceTextureClient(m_surfaceTexture);
int result = native_window_set_buffers_format(m_ANW.get(), HAL_PIXEL_FORMAT_RGBA_8888);
GLUtils::checkSurfaceTextureError("native_window_set_buffers_format", result);
if (result == NO_ERROR) {
result = native_window_set_buffers_dimensions(m_ANW.get(),
m_size.width(), m_size.height());
GLUtils::checkSurfaceTextureError("native_window_set_buffers_dimensions", result);
}
if (result != NO_ERROR) {
m_useHwAcceleration = false;
destroySurfaceTextureLocked();
return 0;
}
return m_ANW.get();
}
bool CanvasTexture::uploadImageBuffer(ImageBuffer* imageBuffer)
{
m_hasValidTexture = false;
SurfaceTextureClient* anw = nativeWindow();
if (!anw)
return false;
// Size mismatch, early abort (will fall back to software)
if (imageBuffer->size() != m_size)
return false;
GraphicsContext* gc = imageBuffer ? imageBuffer->context() : 0;
if (!gc)
return false;
const SkBitmap& bitmap = android_gc2canvas(gc)->getDevice()->accessBitmap(false);
if (!GLUtils::updateSharedSurfaceTextureWithBitmap(anw, bitmap))
return false;
m_hasValidTexture = true;
return true;
}
/********************************************
//.........这里部分代码省略.........
示例5: demoteValues
void demoteValues(Procedure& proc, const IndexSet<Value>& values)
{
HashMap<Value*, StackSlotValue*> map;
HashMap<Value*, StackSlotValue*> phiMap;
// Create stack slots.
InsertionSet insertionSet(proc);
for (Value* value : values.values(proc.values())) {
StackSlotValue* stack = insertionSet.insert<StackSlotValue>(
0, value->origin(), sizeofType(value->type()), StackSlotKind::Anonymous);
map.add(value, stack);
if (value->opcode() == Phi) {
StackSlotValue* phiStack = insertionSet.insert<StackSlotValue>(
0, value->origin(), sizeofType(value->type()), StackSlotKind::Anonymous);
phiMap.add(value, phiStack);
}
}
insertionSet.execute(proc[0]);
if (verbose) {
dataLog("Demoting values as follows:\n");
dataLog(" map = ");
CommaPrinter comma;
for (auto& entry : map)
dataLog(comma, *entry.key, "=>", *entry.value);
dataLog("\n");
dataLog(" phiMap = ");
comma = CommaPrinter();
for (auto& entry : phiMap)
dataLog(comma, *entry.key, "=>", *entry.value);
dataLog("\n");
}
// Change accesses to the values to accesses to the stack slots.
for (BasicBlock* block : proc) {
for (unsigned valueIndex = 0; valueIndex < block->size(); ++valueIndex) {
Value* value = block->at(valueIndex);
if (value->opcode() == Phi) {
if (StackSlotValue* stack = phiMap.get(value)) {
value->replaceWithIdentity(
insertionSet.insert<MemoryValue>(
valueIndex, Load, value->type(), value->origin(), stack));
}
} else {
for (Value*& child : value->children()) {
if (StackSlotValue* stack = map.get(child)) {
child = insertionSet.insert<MemoryValue>(
valueIndex, Load, child->type(), value->origin(), stack);
}
}
if (UpsilonValue* upsilon = value->as<UpsilonValue>()) {
if (StackSlotValue* stack = phiMap.get(upsilon->phi())) {
insertionSet.insert<MemoryValue>(
valueIndex, Store, upsilon->origin(), upsilon->child(0), stack);
value->replaceWithNop();
}
}
}
if (StackSlotValue* stack = map.get(value)) {
insertionSet.insert<MemoryValue>(
valueIndex + 1, Store, value->origin(), value, stack);
}
}
insertionSet.execute(block);
}
}
示例6: DECLARE_THROW_SCOPE
void IntlDateTimeFormat::initializeDateTimeFormat(ExecState& exec, JSValue locales, JSValue originalOptions)
{
VM& vm = exec.vm();
auto scope = DECLARE_THROW_SCOPE(vm);
// 12.1.1 InitializeDateTimeFormat (dateTimeFormat, locales, options) (ECMA-402 2.0)
// 1. If dateTimeFormat.[[initializedIntlObject]] is true, throw a TypeError exception.
// 2. Set dateTimeFormat.[[initializedIntlObject]] to true.
// 3. Let requestedLocales be CanonicalizeLocaleList(locales).
Vector<String> requestedLocales = canonicalizeLocaleList(exec, locales);
// 4. ReturnIfAbrupt(requestedLocales),
RETURN_IF_EXCEPTION(scope, void());
// 5. Let options be ToDateTimeOptions(options, "any", "date").
JSObject* options = toDateTimeOptionsAnyDate(exec, originalOptions);
// 6. ReturnIfAbrupt(options).
RETURN_IF_EXCEPTION(scope, void());
// 7. Let opt be a new Record.
HashMap<String, String> localeOpt;
// 8. Let matcher be GetOption(options, "localeMatcher", "string", «"lookup", "best fit"», "best fit").
String localeMatcher = intlStringOption(exec, options, vm.propertyNames->localeMatcher, { "lookup", "best fit" }, "localeMatcher must be either \"lookup\" or \"best fit\"", "best fit");
// 9. ReturnIfAbrupt(matcher).
RETURN_IF_EXCEPTION(scope, void());
// 10. Set opt.[[localeMatcher]] to matcher.
localeOpt.add(vm.propertyNames->localeMatcher.string(), localeMatcher);
// 11. Let localeData be the value of %DateTimeFormat%.[[localeData]].
// 12. Let r be ResolveLocale( %DateTimeFormat%.[[availableLocales]], requestedLocales, opt, %DateTimeFormat%.[[relevantExtensionKeys]], localeData).
const HashSet<String> availableLocales = exec.callee()->globalObject()->intlDateTimeFormatAvailableLocales();
HashMap<String, String> resolved = resolveLocale(exec, availableLocales, requestedLocales, localeOpt, relevantExtensionKeys, WTF_ARRAY_LENGTH(relevantExtensionKeys), localeData);
// 13. Set dateTimeFormat.[[locale]] to the value of r.[[locale]].
m_locale = resolved.get(vm.propertyNames->locale.string());
if (m_locale.isEmpty()) {
throwTypeError(&exec, scope, ASCIILiteral("failed to initialize DateTimeFormat due to invalid locale"));
return;
}
// 14. Set dateTimeFormat.[[calendar]] to the value of r.[[ca]].
m_calendar = resolved.get(ASCIILiteral("ca"));
// Switch to preferred aliases.
if (m_calendar == "gregory")
m_calendar = ASCIILiteral("gregorian");
else if (m_calendar == "islamicc")
m_calendar = ASCIILiteral("islamic-civil");
else if (m_calendar == "ethioaa")
m_calendar = ASCIILiteral("ethiopic-amete-alem");
// 15. Set dateTimeFormat.[[numberingSystem]] to the value of r.[[nu]].
m_numberingSystem = resolved.get(ASCIILiteral("nu"));
// 16. Let dataLocale be the value of r.[[dataLocale]].
String dataLocale = resolved.get(ASCIILiteral("dataLocale"));
// 17. Let tz be Get(options, "timeZone").
JSValue tzValue = options->get(&exec, vm.propertyNames->timeZone);
// 18. ReturnIfAbrupt(tz).
RETURN_IF_EXCEPTION(scope, void());
// 19. If tz is not undefined, then
String tz;
if (!tzValue.isUndefined()) {
// a. Let tz be ToString(tz).
String originalTz = tzValue.toWTFString(&exec);
// b. ReturnIfAbrupt(tz).
RETURN_IF_EXCEPTION(scope, void());
// c. If the result of IsValidTimeZoneName(tz) is false, then i. Throw a RangeError exception.
// d. Let tz be CanonicalizeTimeZoneName(tz).
tz = canonicalizeTimeZoneName(originalTz);
if (tz.isNull()) {
throwRangeError(&exec, scope, String::format("invalid time zone: %s", originalTz.utf8().data()));
return;
}
} else {
// 20. Else,
// a. Let tz be DefaultTimeZone().
tz = defaultTimeZone();
}
// 21. Set dateTimeFormat.[[timeZone]] to tz.
m_timeZone = tz;
// 22. Let opt be a new Record.
// Rather than building a record, build the skeleton pattern.
StringBuilder skeletonBuilder;
// 23. For each row of Table 3, except the header row, do:
// a. Let prop be the name given in the Property column of the row.
// b. Let value be GetOption(options, prop, "string", «the strings given in the Values column of the row», undefined).
// c. ReturnIfAbrupt(value).
// d. Set opt.[[<prop>]] to value.
auto narrowShortLong = { "narrow", "short", "long" };
auto twoDigitNumeric = { "2-digit", "numeric" };
auto twoDigitNumericNarrowShortLong = { "2-digit", "numeric", "narrow", "short", "long" };
auto shortLong = { "short", "long" };
String weekday = intlStringOption(exec, options, vm.propertyNames->weekday, narrowShortLong, "weekday must be \"narrow\", \"short\", or \"long\"", nullptr);
RETURN_IF_EXCEPTION(scope, void());
if (!weekday.isNull()) {
if (weekday == "narrow")
//.........这里部分代码省略.........
示例7: allowsAnyHTTPSCertificateHosts
namespace WebCore {
typedef std::tuple<WTF::String, WTF::String> clientCertificate;
static HashMap<String, ListHashSet<String>> allowedHosts;
static HashMap<String, clientCertificate> allowedClientHosts;
void allowsAnyHTTPSCertificateHosts(const String& host)
{
ListHashSet<String> certificates;
allowedHosts.set(host, certificates);
}
void addAllowedClientCertificate(const String& host, const String& certificate, const String& key)
{
clientCertificate clientInfo(certificate, key);
allowedClientHosts.set(host.lower(), clientInfo);
}
void setSSLClientCertificate(ResourceHandle* handle)
{
String host = handle->firstRequest().url().host();
HashMap<String, clientCertificate>::iterator it = allowedClientHosts.find(host.lower());
if (it == allowedClientHosts.end())
return;
ResourceHandleInternal* d = handle->getInternal();
clientCertificate clientInfo = it->value;
curl_easy_setopt(d->m_handle, CURLOPT_SSLCERT, std::get<0>(clientInfo).utf8().data());
curl_easy_setopt(d->m_handle, CURLOPT_SSLCERTTYPE, "P12");
curl_easy_setopt(d->m_handle, CURLOPT_SSLCERTPASSWD, std::get<1>(clientInfo).utf8().data());
}
bool sslIgnoreHTTPSCertificate(const String& host, const ListHashSet<String>& certificates)
{
HashMap<String, ListHashSet<String>>::iterator it = allowedHosts.find(host);
if (it != allowedHosts.end()) {
if ((it->value).isEmpty()) {
it->value = certificates;
return true;
}
if (certificates.size() != it->value.size())
return false;
ListHashSet<String>::const_iterator certsIter = certificates.begin();
ListHashSet<String>::iterator valueIter = (it->value).begin();
for (; valueIter != (it->value).end(); ++valueIter, ++certsIter) {
if (*certsIter != *valueIter)
return false;
}
return true;
}
return false;
}
unsigned sslCertificateFlag(const unsigned& sslError)
{
switch (sslError) {
case X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT : // the issuer certificate could not be found: this occurs if the issuer certificate of an untrusted certificate cannot be found.
case X509_V_ERR_UNABLE_TO_GET_CRL : // the CRL of a certificate could not be found.
case X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY : // the issuer certificate of a locally looked up certificate could not be found. This normally means the list of trusted certificates is not complete.
return SSL_CERTIFICATE_UNKNOWN_CA;
case X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE : // the certificate signature could not be decrypted. This means that the actual signature value could not be determined rather than it not matching the expected value, this is only meaningful for RSA keys.
case X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE : // the CRL signature could not be decrypted: this means that the actual signature value could not be determined rather than it not matching the expected value. Unused.
case X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY : // the public key in the certificate SubjectPublicKeyInfo could not be read.
case X509_V_ERR_CERT_SIGNATURE_FAILURE : // the signature of the certificate is invalid.
case X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT : // the passed certificate is self signed and the same certificate cannot be found in the list of trusted certificates.
case X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN : // the certificate chain could be built up using the untrusted certificates but the root could not be found locally.
case X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE : // no signatures could be verified because the chain contains only one certificate and it is not self signed.
case X509_V_ERR_INVALID_PURPOSE : // the supplied certificate cannot be used for the specified purpose.
case X509_V_ERR_CERT_UNTRUSTED : // the root CA is not marked as trusted for the specified purpose.
case X509_V_ERR_CERT_REJECTED : // the root CA is marked to reject the specified purpose.
case X509_V_ERR_NO_EXPLICIT_POLICY : // the verification flags were set to require and explicit policy but none was present.
case X509_V_ERR_DIFFERENT_CRL_SCOPE : // the only CRLs that could be found did not match the scope of the certificate.
return SSL_CERTIFICATE_INSECURE;
case X509_V_ERR_CERT_NOT_YET_VALID : // the certificate is not yet valid: the notBefore date is after the current time.
case X509_V_ERR_CRL_NOT_YET_VALID : // the CRL is not yet valid.
return SSL_CERTIFICATE_NOT_ACTIVATED;
case X509_V_ERR_CERT_HAS_EXPIRED : // the certificate has expired: that is the notAfter date is before the current time.
case X509_V_ERR_CRL_HAS_EXPIRED : // the CRL has expired.
return SSL_CERTIFICATE_EXPIRED;
case X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD : // the certificate notBefore field contains an invalid time.
case X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD : // the certificate notAfter field contains an invalid time.
case X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD : // the CRL lastUpdate field contains an invalid time.
case X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD : // the CRL nextUpdate field contains an invalid time.
case X509_V_ERR_OUT_OF_MEM : // an error occurred trying to allocate memory. This should never happen.
case X509_V_ERR_CERT_CHAIN_TOO_LONG : // the certificate chain length is greater than the supplied maximum depth. Unused.
case X509_V_ERR_PATH_LENGTH_EXCEEDED : // the basicConstraints pathlength parameter has been exceeded.
case X509_V_ERR_INVALID_EXTENSION : // a certificate extension had an invalid value (for example an incorrect encoding) or some value inconsistent with other extensions.
case X509_V_ERR_INVALID_POLICY_EXTENSION : // a certificate policies extension had an invalid value (for example an incorrect encoding) or some value inconsistent with other extensions. This error only occurs if policy processing is enabled.
case X509_V_ERR_UNSUPPORTED_EXTENSION_FEATURE : // some feature of a certificate extension is not supported. Unused.
case X509_V_ERR_PERMITTED_VIOLATION : // a name constraint violation occured in the permitted subtrees.
case X509_V_ERR_EXCLUDED_VIOLATION : // a name constraint violation occured in the excluded subtrees.
case X509_V_ERR_SUBTREE_MINMAX : // a certificate name constraints extension included a minimum or maximum field: this is not supported.
case X509_V_ERR_UNSUPPORTED_CONSTRAINT_TYPE : // an unsupported name constraint type was encountered. OpenSSL currently only supports directory name, DNS name, email and URI types.
case X509_V_ERR_UNSUPPORTED_CONSTRAINT_SYNTAX : // the format of the name constraint is not recognised: for example an email address format of a form not mentioned in RFC3280. This could be caused by a garbage extension or some new feature not currently supported.
case X509_V_ERR_CRL_PATH_VALIDATION_ERROR : // an error occured when attempting to verify the CRL path. This error can only happen if extended CRL checking is enabled.
case X509_V_ERR_APPLICATION_VERIFICATION : // an application specific error. This will never be returned unless explicitly set by an application.
return SSL_CERTIFICATE_GENERIC_ERROR;
case X509_V_ERR_CERT_REVOKED : // the certificate has been revoked.
return SSL_CERTIFICATE_REVOKED;
case X509_V_ERR_INVALID_CA : // a CA certificate is invalid. Either it is not a CA or its extensions are not consistent with the supplied purpose.
//.........这里部分代码省略.........
示例8: while
void
MainForm::OnParsingCompleted(ArrayList &feedData) {
AppResource *pAppResource = Application::GetInstance()->GetAppResource();
if (feedData.GetCount() == 0) {
// no service this day
String emptyText;
pAppResource->GetString("IDS_NOSERVICE", emptyText);
__pListFood->SetTextOfEmptyList(emptyText);
} else {
IEnumerator *pEnum = feedData.GetEnumeratorN();
HashMap *pItem = null;
int mensaIndex = -1;
String *currentMensa = null;
String currencySymbol;
pAppResource->GetString("IDS_CURRENCY", currencySymbol);
String soldOut;
pAppResource->GetString("IDS_SOLDOUT", soldOut);
// iterate over items (meals) in feed
while (pEnum->MoveNext() == E_SUCCESS) {
pItem = (HashMap *)pEnum->GetCurrent();
// check if mensa is already in the list (we assume the feed to be ordered)
if (!currentMensa || !(static_cast<String *>(pItem->GetValue(*(new String("author")))))->Equals(*currentMensa, false)) {
currentMensa = static_cast<String *>(pItem->GetValue(*(new String("author"))));
mensaIndex++;
// Create a main item of the ExpandableList
CustomListItem* pMainItem = new CustomListItem();
pMainItem->Construct(100);
pMainItem->SetItemFormat(*__pMainItemFormat);
pMainItem->SetElement(TEXT_ID, *(new String(*currentMensa)));
// Add the item to the ExpandableList
__pListFood->AddItem(*pMainItem, mensaIndex);
}
String *title = static_cast<String *>(pItem->GetValue(*(new String("title"))));
title->Trim();
String priceStudents;
String priceStaff;
int stringLength = title->GetLength();
// Create a sub item of the ExpandableList
CustomListItem *pSubItem = new CustomListItem();
pSubItem->Construct(100);
pSubItem->SetItemFormat(*__pSubItemFormat);
// get prices
if (title->EndsWith(L" EUR)")) {
// parse price
title->SubString(stringLength - 20, 5, priceStudents);
priceStudents.Append(currencySymbol);
title->SubString(stringLength - 9, 5, priceStaff);
priceStaff.Append(currencySymbol);
title->Remove(stringLength - 22, 22);
pSubItem->SetElement(PRICESTUDENT_ID, priceStudents);
pSubItem->SetElement(PRICESTAFF_ID, priceStaff);
} else if (title->EndsWith(L"(ausverkauft)")) {
// sold out
title->Remove(stringLength - 14, 14);
pSubItem->SetElement(REMARK_ID, soldOut);
}
pSubItem->SetElement(TEXT_ID, *title);
// Add sub item to the ExpandableList
__pListFood->AddSubItem(mensaIndex, *pSubItem);
}
// clean up
delete pEnum;
}
__pListFood->RequestRedraw();
__pListFood->ScrollToTop();
StopLoadingAnimation();
}
示例9: TEST_CASE
static const char alphanum[] =
"0123456789"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz";
for (int i = 0; i < len; ++i) {
s[i] = alphanum[rand() % (sizeof(alphanum) - 1)];
}
s[len] = 0;
}
}
TEST_CASE("HashMap insert/remove testing", "[HashMap]")
{
HashMap<int> map;
map.insert("jorma", 2000);
map.insert("jarmo", 2);
map.insert("pentti", 666);
map.insert("hahahaha", -24);
map.insert("moi", 1);
REQUIRE(map.getSize() == 5);
char *str = (char*)malloc(15);
for (unsigned i = 0; i < 3500; ++i)
{
helper::gen_random(str, 10);
str[10] = '\n';
示例10: decodeDataObject
static bool decodeDataObject(ArgumentDecoder& decoder, RefPtr<DataObjectGtk>& dataObject)
{
RefPtr<DataObjectGtk> data = DataObjectGtk::create();
bool hasText;
if (!decoder.decode(hasText))
return false;
if (hasText) {
String text;
if (!decoder.decode(text))
return false;
data->setText(text);
}
bool hasMarkup;
if (!decoder.decode(hasMarkup))
return false;
if (hasMarkup) {
String markup;
if (!decoder.decode(markup))
return false;
data->setMarkup(markup);
}
bool hasURL;
if (!decoder.decode(hasURL))
return false;
if (hasURL) {
String url;
if (!decoder.decode(url))
return false;
data->setURL(URL(URL(), url), String());
}
bool hasURIList;
if (!decoder.decode(hasURIList))
return false;
if (hasURIList) {
String uriList;
if (!decoder.decode(uriList))
return false;
data->setURIList(uriList);
}
bool hasImage;
if (!decoder.decode(hasImage))
return false;
if (hasImage) {
GRefPtr<GdkPixbuf> image;
if (!decodeImage(decoder, image))
return false;
data->setImage(image.get());
}
bool hasUnknownTypeData;
if (!decoder.decode(hasUnknownTypeData))
return false;
if (hasUnknownTypeData) {
HashMap<String, String> unknownTypes;
if (!decoder.decode(unknownTypes))
return false;
auto end = unknownTypes.end();
for (auto it = unknownTypes.begin(); it != end; ++it)
data->setUnknownTypeData(it->key, it->value);
}
dataObject = data;
return true;
}
示例11: GetDOIFromContentID
/*! \brief Get simple DOI identifier from full DOI content ID string.
\param contentID input, full DOI contentID string.
\param doi output, simple DOI identifier.
\returns Boolean indicating success or failure.
*/
bool OsmsOpenIPMPMessenger::GetDOIFromContentID(const std::string& contentID,
std::string& doiID) {
XMLDocument pIPMP_ContentId;
if (pIPMP_ContentId.decode(contentID.data(), "IPMP_ContentIdentity") == false) {
return false;
}
HashMap* identifier = pIPMP_ContentId.getDocList("Identifier");
if (identifier == 0) {
return false;
}
if (identifier->size() == 0) {
identifier->clear();
delete identifier;
return false;
}
XMLDocument* node = (XMLDocument*)identifier->first();
if (node == 0) {
for (int j = 1; j < identifier->size(); j++) {
node = (XMLDocument*)identifier->next();
if (node != 0) delete node;
}
identifier->clear();
delete identifier;
return false;
}
char* identifierType = node->getString("IdentifierType");
char* identifierValue = node->getString("IdentifierValue");
if ((identifierType == 0) || (identifierValue == 0)) {
delete node;
for (int j = 1; j < identifier->size(); j++) {
node = (XMLDocument*)identifier->next();
if (node != 0) delete node;
}
identifier->clear();
delete identifier;
return false;
}
if (strcmp(identifierType, "DOI") == 0) {
doiID = identifierValue;
delete[] identifierType;
delete[] identifierValue;
delete node;
for (int j = 1; j < identifier->size(); j++) {
node = (XMLDocument*)identifier->next();
if (node != 0) delete node;
}
identifier->clear();
delete identifier;
return true;
}
delete[] identifierType;
delete[] identifierValue;
delete node;
for (int i = 1; i < identifier->size(); i++) {
node = (XMLDocument*)identifier->next();
if (node == 0) {
for (int j = (i + 1); j < identifier->size(); j++) {
node = (XMLDocument*)identifier->next();
if (node != 0) delete node;
}
identifier->clear();
delete identifier;
return false;
}
char* identifierType = node->getString("IdentifierType");
char* identifierValue = node->getString("IdentifierValue");
if ((identifierType == 0) || (identifierValue == 0)) {
delete node;
for (int j = (i + 1); j < identifier->size(); j++) {
node = (XMLDocument*)identifier->next();
if (node != 0) delete node;
}
identifier->clear();
delete identifier;
return false;
}
if (strcmp(identifierType, "DOI") == 0) {
doiID = identifierValue;
delete[] identifierType;
delete[] identifierValue;
delete node;
for (int j = (i + 1); j < identifier->size(); j++) {
node = (XMLDocument*)identifier->next();
if (node != 0) delete node;
}
identifier->clear();
delete identifier;
return true;
}
delete[] identifierType;
delete[] identifierValue;
delete node;
//.........这里部分代码省略.........
示例12: fixSSA
bool fixSSA(Procedure& proc)
{
PhaseScope phaseScope(proc, "fixSSA");
// Collect the stack "variables". If there aren't any, then we don't have anything to do.
// That's a fairly common case.
HashMap<StackSlotValue*, Type> stackVariable;
for (Value* value : proc.values()) {
if (StackSlotValue* stack = value->as<StackSlotValue>()) {
if (stack->kind() == StackSlotKind::Anonymous)
stackVariable.add(stack, Void);
}
}
if (stackVariable.isEmpty())
return false;
// Make sure that we know how to optimize all of these. We only know how to handle Load and
// Store on anonymous variables.
for (Value* value : proc.values()) {
auto reject = [&] (Value* value) {
if (StackSlotValue* stack = value->as<StackSlotValue>())
stackVariable.remove(stack);
};
auto handleAccess = [&] (Value* access, Type type) {
StackSlotValue* stack = access->lastChild()->as<StackSlotValue>();
if (!stack)
return;
if (value->as<MemoryValue>()->offset()) {
stackVariable.remove(stack);
return;
}
auto result = stackVariable.find(stack);
if (result == stackVariable.end())
return;
if (result->value == Void) {
result->value = type;
return;
}
if (result->value == type)
return;
stackVariable.remove(result);
};
switch (value->opcode()) {
case Load:
// We're OK with loads from stack variables at an offset of zero.
handleAccess(value, value->type());
break;
case Store:
// We're OK with stores to stack variables, but not storing stack variables.
reject(value->child(0));
handleAccess(value, value->child(0)->type());
break;
default:
for (Value* child : value->children())
reject(child);
break;
}
}
Vector<StackSlotValue*> deadValues;
for (auto& entry : stackVariable) {
if (entry.value == Void)
deadValues.append(entry.key);
}
for (StackSlotValue* deadValue : deadValues) {
deadValue->replaceWithNop();
stackVariable.remove(deadValue);
}
if (stackVariable.isEmpty())
return false;
// We know that we have variables to optimize, so do that now.
breakCriticalEdges(proc);
SSACalculator ssa(proc);
// Create a SSACalculator::Variable for every stack variable.
Vector<StackSlotValue*> variableToStack;
HashMap<StackSlotValue*, SSACalculator::Variable*> stackToVariable;
for (auto& entry : stackVariable) {
StackSlotValue* stack = entry.key;
SSACalculator::Variable* variable = ssa.newVariable();
RELEASE_ASSERT(variable->index() == variableToStack.size());
variableToStack.append(stack);
stackToVariable.add(stack, variable);
}
// Create Defs for all of the stores to the stack variable.
for (BasicBlock* block : proc) {
for (Value* value : *block) {
if (value->opcode() != Store)
continue;
//.........这里部分代码省略.........
示例13: createHTMLElementWrapper
gpointer createHTMLElementWrapper(PassRefPtr<WebCore::HTMLElement> element)
{
static HashMap<WTF::AtomicStringImpl*, CreateHTMLElementWrapperFunction> map;
if (map.isEmpty()) {
map.set(aTag.localName().impl(), createAnchorWrapper);
map.set(appletTag.localName().impl(), createAppletWrapper);
#if ENABLE(VIDEO)
map.set(audioTag.localName().impl(), createAudioWrapper);
map.set(videoTag.localName().impl(), createVideoWrapper);
#endif
map.set(areaTag.localName().impl(), createAreaWrapper);
map.set(baseTag.localName().impl(), createBaseWrapper);
map.set(basefontTag.localName().impl(), createBaseFontWrapper);
map.set(blockquoteTag.localName().impl(), createQuoteWrapper);
map.set(bodyTag.localName().impl(), createBodyWrapper);
map.set(brTag.localName().impl(), createBRWrapper);
map.set(buttonTag.localName().impl(), createButtonWrapper);
map.set(canvasTag.localName().impl(), createCanvasWrapper);
map.set(captionTag.localName().impl(), createTableCaptionWrapper);
map.set(colTag.localName().impl(), createTableColWrapper);
map.set(delTag.localName().impl(), createModWrapper);
map.set(dirTag.localName().impl(), createDirectoryWrapper);
map.set(divTag.localName().impl(), createDivWrapper);
map.set(dlTag.localName().impl(), createDListWrapper);
map.set(embedTag.localName().impl(), createEmbedWrapper);
map.set(fieldsetTag.localName().impl(), createFieldSetWrapper);
map.set(fontTag.localName().impl(), createFontWrapper);
map.set(formTag.localName().impl(), createFormWrapper);
map.set(frameTag.localName().impl(), createFrameWrapper);
map.set(framesetTag.localName().impl(), createFrameSetWrapper);
map.set(h1Tag.localName().impl(), createHeadingWrapper);
map.set(headTag.localName().impl(), createHeadWrapper);
map.set(hrTag.localName().impl(), createHRWrapper);
map.set(htmlTag.localName().impl(), createHtmlWrapper);
map.set(iframeTag.localName().impl(), createIFrameWrapper);
map.set(imgTag.localName().impl(), createImageWrapper);
map.set(inputTag.localName().impl(), createInputWrapper);
map.set(isindexTag.localName().impl(), createIsIndexWrapper);
map.set(labelTag.localName().impl(), createLabelWrapper);
map.set(legendTag.localName().impl(), createLegendWrapper);
map.set(liTag.localName().impl(), createLIWrapper);
map.set(linkTag.localName().impl(), createLinkWrapper);
map.set(mapTag.localName().impl(), createMapWrapper);
map.set(marqueeTag.localName().impl(), createMarqueeWrapper);
map.set(menuTag.localName().impl(), createMenuWrapper);
map.set(metaTag.localName().impl(), createMetaWrapper);
map.set(objectTag.localName().impl(), createObjectWrapper);
map.set(olTag.localName().impl(), createOListWrapper);
map.set(optgroupTag.localName().impl(), createOptGroupWrapper);
map.set(optionTag.localName().impl(), createOptionWrapper);
map.set(pTag.localName().impl(), createParagraphWrapper);
map.set(paramTag.localName().impl(), createParamWrapper);
map.set(preTag.localName().impl(), createPreWrapper);
map.set(qTag.localName().impl(), createQuoteWrapper);
map.set(scriptTag.localName().impl(), createScriptWrapper);
map.set(selectTag.localName().impl(), createSelectWrapper);
map.set(styleTag.localName().impl(), createStyleWrapper);
map.set(tableTag.localName().impl(), createTableWrapper);
map.set(tbodyTag.localName().impl(), createTableSectionWrapper);
map.set(tdTag.localName().impl(), createTableCellWrapper);
map.set(textareaTag.localName().impl(), createTextAreaWrapper);
map.set(titleTag.localName().impl(), createTitleWrapper);
map.set(trTag.localName().impl(), createTableRowWrapper);
map.set(ulTag.localName().impl(), createUListWrapper);
map.set(colgroupTag.localName().impl(), createTableColWrapper);
map.set(h2Tag.localName().impl(), createHeadingWrapper);
map.set(h3Tag.localName().impl(), createHeadingWrapper);
map.set(h4Tag.localName().impl(), createHeadingWrapper);
map.set(h5Tag.localName().impl(), createHeadingWrapper);
map.set(h6Tag.localName().impl(), createHeadingWrapper);
map.set(imageTag.localName().impl(), createImageWrapper);
map.set(insTag.localName().impl(), createModWrapper);
map.set(keygenTag.localName().impl(), createKeygenWrapper);
map.set(listingTag.localName().impl(), createPreWrapper);
map.set(tfootTag.localName().impl(), createTableSectionWrapper);
map.set(thTag.localName().impl(), createTableCellWrapper);
map.set(theadTag.localName().impl(), createTableSectionWrapper);
map.set(xmpTag.localName().impl(), createPreWrapper);
}
CreateHTMLElementWrapperFunction createWrapperFunction =
map.get(element->localName().impl());
if (createWrapperFunction)
return createWrapperFunction(element);
return wrapHTMLElement(element.get());
}
示例14:
HashMap * IMAPNamespace::serializable()
{
HashMap * result = Object::serializable();
result->setObjectForKey(MCSTR("items"), mItems->serializable());
return result;
}
示例15: resolveKeyframes
static void resolveKeyframes(StyleResolver* resolver, Element* element, const RenderStyle& style, const AtomicString& name, TimingFunction* defaultTimingFunction,
Vector<std::pair<KeyframeAnimationEffect::KeyframeVector, RefPtr<TimingFunction> > >& keyframesAndTimingFunctions)
{
ASSERT(RuntimeEnabledFeatures::webAnimationsCSSEnabled());
const StyleRuleKeyframes* keyframesRule = CSSAnimations::matchScopedKeyframesRule(resolver, element, name.impl());
if (!keyframesRule)
return;
const Vector<RefPtr<StyleKeyframe> >& styleKeyframes = keyframesRule->keyframes();
if (styleKeyframes.isEmpty())
return;
// Construct and populate the style for each keyframe
PropertySet specifiedProperties;
KeyframeAnimationEffect::KeyframeVector keyframes;
HashMap<double, RefPtr<TimingFunction> > perKeyframeTimingFunctions;
for (size_t i = 0; i < styleKeyframes.size(); ++i) {
const StyleKeyframe* styleKeyframe = styleKeyframes[i].get();
RefPtr<RenderStyle> keyframeStyle = resolver->styleForKeyframe(element, style, styleKeyframe, name);
RefPtr<Keyframe> keyframe = Keyframe::create();
const Vector<double>& offsets = styleKeyframe->keys();
ASSERT(!offsets.isEmpty());
keyframe->setOffset(offsets[0]);
TimingFunction* timingFunction = defaultTimingFunction;
const StylePropertySet* properties = styleKeyframe->properties();
for (unsigned j = 0; j < properties->propertyCount(); j++) {
CSSPropertyID property = properties->propertyAt(j).id();
specifiedProperties.add(property);
if (property == CSSPropertyWebkitAnimationTimingFunction || property == CSSPropertyAnimationTimingFunction)
timingFunction = KeyframeValue::timingFunction(*keyframeStyle);
else if (CSSAnimations::isAnimatableProperty(property))
keyframe->setPropertyValue(property, CSSAnimatableValueFactory::create(property, *keyframeStyle).get());
}
keyframes.append(keyframe);
// The last keyframe specified at a given offset is used.
perKeyframeTimingFunctions.set(offsets[0], timingFunction);
for (size_t j = 1; j < offsets.size(); ++j) {
keyframes.append(keyframe->cloneWithOffset(offsets[j]));
perKeyframeTimingFunctions.set(offsets[j], timingFunction);
}
}
ASSERT(!keyframes.isEmpty());
if (!perKeyframeTimingFunctions.contains(0))
perKeyframeTimingFunctions.set(0, defaultTimingFunction);
for (PropertySet::const_iterator iter = specifiedProperties.begin(); iter != specifiedProperties.end(); ++iter) {
const CSSPropertyID property = *iter;
ASSERT(property != CSSPropertyInvalid);
blink::Platform::current()->histogramSparse("WebCore.Animation.CSSProperties", UseCounter::mapCSSPropertyIdToCSSSampleIdForHistogram(property));
}
// Remove duplicate keyframes. In CSS the last keyframe at a given offset takes priority.
std::stable_sort(keyframes.begin(), keyframes.end(), Keyframe::compareOffsets);
size_t targetIndex = 0;
for (size_t i = 1; i < keyframes.size(); i++) {
if (keyframes[i]->offset() != keyframes[targetIndex]->offset())
targetIndex++;
if (targetIndex != i)
keyframes[targetIndex] = keyframes[i];
}
keyframes.shrink(targetIndex + 1);
// Add 0% and 100% keyframes if absent.
RefPtr<Keyframe> startKeyframe = keyframes[0];
if (startKeyframe->offset()) {
startKeyframe = Keyframe::create();
startKeyframe->setOffset(0);
keyframes.prepend(startKeyframe);
}
RefPtr<Keyframe> endKeyframe = keyframes[keyframes.size() - 1];
if (endKeyframe->offset() != 1) {
endKeyframe = Keyframe::create();
endKeyframe->setOffset(1);
keyframes.append(endKeyframe);
}
ASSERT(keyframes.size() >= 2);
ASSERT(!keyframes.first()->offset());
ASSERT(keyframes.last()->offset() == 1);
// Snapshot current property values for 0% and 100% if missing.
PropertySet allProperties;
size_t numKeyframes = keyframes.size();
for (size_t i = 0; i < numKeyframes; i++) {
const PropertySet& keyframeProperties = keyframes[i]->properties();
for (PropertySet::const_iterator iter = keyframeProperties.begin(); iter != keyframeProperties.end(); ++iter)
allProperties.add(*iter);
}
const PropertySet& startKeyframeProperties = startKeyframe->properties();
const PropertySet& endKeyframeProperties = endKeyframe->properties();
bool missingStartValues = startKeyframeProperties.size() < allProperties.size();
bool missingEndValues = endKeyframeProperties.size() < allProperties.size();
if (missingStartValues || missingEndValues) {
for (PropertySet::const_iterator iter = allProperties.begin(); iter != allProperties.end(); ++iter) {
const CSSPropertyID property = *iter;
bool startNeedsValue = missingStartValues && !startKeyframeProperties.contains(property);
bool endNeedsValue = missingEndValues && !endKeyframeProperties.contains(property);
if (!startNeedsValue && !endNeedsValue)
continue;
RefPtr<AnimatableValue> snapshotValue = CSSAnimatableValueFactory::create(property, style);
//.........这里部分代码省略.........