Lines Matching refs:name
53 return lhs->name.compare(0, lhs->name.size(), rhs.data(), rhs.size()) < 0; in less_than_struct_with_name()
59 int name_cmp = lhs->name.compare(0, lhs->name.size(), rhs.first.data(), rhs.first.size()); in less_than_struct_with_name_and_id()
63 ResourceTablePackage* ResourceTable::FindPackage(const StringPiece& name) const { in FindPackage()
65 auto iter = std::lower_bound(packages.begin(), last, name, in FindPackage()
67 if (iter != last && name == (*iter)->name) { in FindPackage()
82 ResourceTablePackage* ResourceTable::CreatePackage(const StringPiece& name, Maybe<uint8_t> id) { in CreatePackage() argument
84 ResourceTablePackage* package = FindOrCreatePackage(name); in CreatePackage()
96 ResourceTablePackage* ResourceTable::CreatePackageAllowingDuplicateNames(const StringPiece& name, in CreatePackageAllowingDuplicateNames() argument
99 auto iter = std::lower_bound(packages.begin(), last, std::make_pair(name, id), in CreatePackageAllowingDuplicateNames()
102 if (iter != last && name == (*iter)->name && id == (*iter)->id) { in CreatePackageAllowingDuplicateNames()
107 new_package->name = name.to_string(); in CreatePackageAllowingDuplicateNames()
112 ResourceTablePackage* ResourceTable::FindOrCreatePackage(const StringPiece& name) { in FindOrCreatePackage() argument
114 auto iter = std::lower_bound(packages.begin(), last, name, in FindOrCreatePackage()
116 if (iter != last && name == (*iter)->name) { in FindOrCreatePackage()
121 new_package->name = name.to_string(); in FindOrCreatePackage()
149 ResourceEntry* ResourceTableType::FindEntry(const StringPiece& name, const Maybe<uint16_t> id) { in FindEntry() argument
151 auto iter = std::lower_bound(entries.begin(), last, std::make_pair(name, id), in FindEntry()
153 if (iter != last && name == (*iter)->name && (!id || id == (*iter)->id)) { in FindEntry()
159 ResourceEntry* ResourceTableType::FindOrCreateEntry(const StringPiece& name, in FindOrCreateEntry() argument
162 auto iter = std::lower_bound(entries.begin(), last, std::make_pair(name, id), in FindOrCreateEntry()
164 if (iter != last && name == (*iter)->name && (!id || id == (*iter)->id)) { in FindOrCreateEntry()
168 auto new_entry = new ResourceEntry(name); in FindOrCreateEntry()
333 static StringPiece ResourceNameValidator(const StringPiece& name) { in ResourceNameValidator() argument
334 if (!IsValidResourceEntryName(name)) { in ResourceNameValidator()
335 return name; in ResourceNameValidator()
344 bool ResourceTable::AddResource(const ResourceNameRef& name, in AddResource() argument
349 return AddResourceImpl(name, ResourceId{}, config, product, std::move(value), in AddResource()
354 bool ResourceTable::AddResourceWithId(const ResourceNameRef& name, const ResourceId& res_id, in AddResourceWithId() argument
357 return AddResourceImpl(name, res_id, config, product, std::move(value), in AddResourceWithId()
362 bool ResourceTable::AddResourceMangled(const ResourceNameRef& name, const ConfigDescription& config, in AddResourceMangled() argument
365 return AddResourceImpl(name, ResourceId{}, config, product, std::move(value), SkipNameValidator, in AddResourceMangled()
369 bool ResourceTable::AddResourceWithIdMangled(const ResourceNameRef& name, const ResourceId& id, in AddResourceWithIdMangled() argument
373 return AddResourceImpl(name, id, config, product, std::move(value), SkipNameValidator, in AddResourceWithIdMangled()
377 bool ResourceTable::ValidateName(NameValidator name_validator, const ResourceNameRef& name, in ValidateName() argument
379 const StringPiece bad_char = name_validator(name.entry); in ValidateName()
381 diag->Error(DiagMessage(source) << "resource '" << name << "' has invalid entry name '" in ValidateName()
382 << name.entry << "'. Invalid character '" << bad_char << "'"); in ValidateName()
388 bool ResourceTable::AddResourceImpl(const ResourceNameRef& name, const ResourceId& res_id, in AddResourceImpl() argument
397 if (!ValidateName(name_validator, name, source, diag)) { in AddResourceImpl()
402 ResourceTablePackage* package = FindOrCreatePackage(name.package); in AddResourceImpl()
405 << "trying to add resource '" << name << "' with ID " << res_id in AddResourceImpl()
406 << " but package '" << package->name << "' already has ID " in AddResourceImpl()
416 ResourceTableType* type = package->FindOrCreateType(name.type, use_id ? res_id.type_id() in AddResourceImpl()
422 << "trying to add resource '" << name << "' with ID " << res_id in AddResourceImpl()
428 ResourceEntry* entry = type->FindOrCreateEntry(name.entry, use_id ? res_id.entry_id() in AddResourceImpl()
434 << "trying to add resource '" << name << "' with ID " << res_id in AddResourceImpl()
458 diag->Error(DiagMessage(source) << "duplicate value for resource '" << name << "' " in AddResourceImpl()
481 bool ResourceTable::SetVisibility(const ResourceNameRef& name, const Visibility& visibility, in SetVisibility() argument
483 return SetVisibilityImpl(name, visibility, {}, ResourceNameValidator, diag); in SetVisibility()
486 bool ResourceTable::SetVisibilityWithId(const ResourceNameRef& name, const Visibility& visibility, in SetVisibilityWithId() argument
488 return SetVisibilityImpl(name, visibility, res_id, ResourceNameValidator, diag); in SetVisibilityWithId()
491 bool ResourceTable::SetVisibilityWithIdMangled(const ResourceNameRef& name, in SetVisibilityWithIdMangled() argument
494 return SetVisibilityImpl(name, visibility, res_id, SkipNameValidator, diag); in SetVisibilityWithIdMangled()
497 bool ResourceTable::SetVisibilityImpl(const ResourceNameRef& name, const Visibility& visibility, in SetVisibilityImpl() argument
503 if (!ValidateName(name_validator, name, source, diag)) { in SetVisibilityImpl()
508 ResourceTablePackage* package = FindOrCreatePackage(name.package); in SetVisibilityImpl()
511 << "trying to add resource '" << name << "' with ID " << res_id in SetVisibilityImpl()
512 << " but package '" << package->name << "' already has ID " in SetVisibilityImpl()
522 ResourceTableType* type = package->FindOrCreateType(name.type, use_id ? res_id.type_id() in SetVisibilityImpl()
528 << "trying to add resource '" << name << "' with ID " << res_id in SetVisibilityImpl()
534 ResourceEntry* entry = type->FindOrCreateEntry(name.entry, use_id ? res_id.entry_id() in SetVisibilityImpl()
540 << "trying to add resource '" << name << "' with ID " << res_id in SetVisibilityImpl()
573 bool ResourceTable::SetAllowNew(const ResourceNameRef& name, const AllowNew& allow_new, in SetAllowNew() argument
575 return SetAllowNewImpl(name, allow_new, ResourceNameValidator, diag); in SetAllowNew()
578 bool ResourceTable::SetAllowNewMangled(const ResourceNameRef& name, const AllowNew& allow_new, in SetAllowNewMangled() argument
580 return SetAllowNewImpl(name, allow_new, SkipNameValidator, diag); in SetAllowNewMangled()
583 bool ResourceTable::SetAllowNewImpl(const ResourceNameRef& name, const AllowNew& allow_new, in SetAllowNewImpl() argument
587 if (!ValidateName(name_validator, name, allow_new.source, diag)) { in SetAllowNewImpl()
591 ResourceTablePackage* package = FindOrCreatePackage(name.package); in SetAllowNewImpl()
592 ResourceTableType* type = package->FindOrCreateType(name.type); in SetAllowNewImpl()
593 ResourceEntry* entry = type->FindOrCreateEntry(name.entry); in SetAllowNewImpl()
598 bool ResourceTable::SetOverlayable(const ResourceNameRef& name, const OverlayableItem& overlayable, in SetOverlayable() argument
600 return SetOverlayableImpl(name, overlayable, ResourceNameValidator, diag); in SetOverlayable()
603 bool ResourceTable::SetOverlayableImpl(const ResourceNameRef& name, in SetOverlayableImpl() argument
608 if (!ValidateName(name_validator, name, overlayable.source, diag)) { in SetOverlayableImpl()
612 ResourceTablePackage* package = FindOrCreatePackage(name.package); in SetOverlayableImpl()
613 ResourceTableType* type = package->FindOrCreateType(name.type); in SetOverlayableImpl()
614 ResourceEntry* entry = type->FindOrCreateEntry(name.entry); in SetOverlayableImpl()
618 << "duplicate overlayable declaration for resource '" << name << "'"); in SetOverlayableImpl()
628 Maybe<ResourceTable::SearchResult> ResourceTable::FindResource(const ResourceNameRef& name) const { in FindResource()
629 ResourceTablePackage* package = FindPackage(name.package); in FindResource()
634 ResourceTableType* type = package->FindType(name.type); in FindResource()
639 ResourceEntry* entry = type->FindEntry(name.entry); in FindResource()
649 ResourceTablePackage* new_pkg = new_table->CreatePackage(pkg->name, pkg->id); in Clone()
656 ResourceEntry* new_entry = new_type->FindOrCreateEntry(entry->name); in Clone()