本文整理汇总了C++中HeaderMap::add方法的典型用法代码示例。如果您正苦于以下问题:C++ HeaderMap::add方法的具体用法?C++ HeaderMap::add怎么用?C++ HeaderMap::add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HeaderMap
的用法示例。
在下文中一共展示了HeaderMap::add方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HeadermapSearchPaths
void Tool::HeadermapResolver::
resolve(
Tool::Context *toolContext,
pbxsetting::Environment const &environment,
pbxproj::PBX::Target::shared_ptr const &target
) const
{
/* Add the compiler default environment, which contains the headermap setting defaults. */
pbxsetting::Environment compilerEnvironment = pbxsetting::Environment(environment);
compilerEnvironment.insertFront(_compiler->defaultSettings(), true);
if (!pbxsetting::Type::ParseBoolean(compilerEnvironment.resolve("USE_HEADERMAP"))) {
return;
}
if (pbxsetting::Type::ParseBoolean(compilerEnvironment.resolve("HEADERMAP_USES_VFS"))) {
// TODO(grp): Support VFS-based header maps.
}
HeaderMap targetName;
HeaderMap ownTargetHeaders;
HeaderMap projectHeaders;
HeaderMap allTargetHeaders;
HeaderMap allNonFrameworkTargetHeaders;
bool includeFlatEntriesForTargetBeingBuilt = pbxsetting::Type::ParseBoolean(compilerEnvironment.resolve("HEADERMAP_INCLUDES_FLAT_ENTRIES_FOR_TARGET_BEING_BUILT"));
bool includeFrameworkEntriesForAllProductTypes = pbxsetting::Type::ParseBoolean(compilerEnvironment.resolve("HEADERMAP_INCLUDES_FRAMEWORK_ENTRIES_FOR_ALL_PRODUCT_TYPES"));
bool includeProjectHeaders = pbxsetting::Type::ParseBoolean(compilerEnvironment.resolve("HEADERMAP_INCLUDES_PROJECT_HEADERS"));
// TODO(grp): Populate generated headers.
HeaderMap generatedFiles;
pbxproj::PBX::Project::shared_ptr project = target->project();
std::vector<std::string> headermapSearchPaths = HeadermapSearchPaths(_specManager, compilerEnvironment, target, toolContext->searchPaths(), toolContext->workingDirectory());
for (std::string const &path : headermapSearchPaths) {
Filesystem::GetDefaultUNSAFE()->readDirectory(path, false, [&](std::string const &fileName) -> bool {
// TODO(grp): Use FileTypeResolver when reliable.
std::string extension = FSUtil::GetFileExtension(fileName);
if (extension != "h" && extension != "hpp") {
return true;
}
targetName.add(fileName, path + "/", fileName);
return true;
});
}
for (pbxproj::PBX::FileReference::shared_ptr const &fileReference : project->fileReferences()) {
std::string filePath = compilerEnvironment.expand(fileReference->resolve());
pbxspec::PBX::FileType::shared_ptr fileType = FileTypeResolver::Resolve(Filesystem::GetDefaultUNSAFE(), _specManager, { pbxspec::Manager::AnyDomain() }, fileReference, filePath);
if (fileType == nullptr || (fileType->identifier() != "sourcecode.c.h" && fileType->identifier() != "sourcecode.cpp.h")) {
continue;
}
std::string fileName = FSUtil::GetBaseName(filePath);
std::string fileDirectory = FSUtil::GetDirectoryName(filePath) + "/";
projectHeaders.add(fileName, fileDirectory, fileName);
if (includeProjectHeaders) {
targetName.add(fileName, fileDirectory, fileName);
}
}
for (pbxproj::PBX::Target::shared_ptr const &projectTarget : project->targets()) {
for (pbxproj::PBX::BuildPhase::shared_ptr const &buildPhase : projectTarget->buildPhases()) {
if (buildPhase->type() != pbxproj::PBX::BuildPhase::Type::Headers) {
continue;
}
for (pbxproj::PBX::BuildFile::shared_ptr const &buildFile : buildPhase->files()) {
if (buildFile->fileRef() == nullptr || buildFile->fileRef()->type() != pbxproj::PBX::GroupItem::Type::FileReference) {
continue;
}
pbxproj::PBX::FileReference::shared_ptr const &fileReference = std::static_pointer_cast <pbxproj::PBX::FileReference> (buildFile->fileRef());
std::string filePath = compilerEnvironment.expand(fileReference->resolve());
pbxspec::PBX::FileType::shared_ptr fileType = FileTypeResolver::Resolve(Filesystem::GetDefaultUNSAFE(), _specManager, { pbxspec::Manager::AnyDomain() }, fileReference, filePath);
if (fileType == nullptr || (fileType->identifier() != "sourcecode.c.h" && fileType->identifier() != "sourcecode.cpp.h")) {
continue;
}
std::string fileName = FSUtil::GetBaseName(filePath);
std::string fileDirectory = FSUtil::GetDirectoryName(filePath) + "/";
std::string frameworkName = projectTarget->productName() + "/" + fileName;
std::vector<std::string> const &attributes = buildFile->attributes();
bool isPublic = std::find(attributes.begin(), attributes.end(), "Public") != attributes.end();
bool isPrivate = std::find(attributes.begin(), attributes.end(), "Private") != attributes.end();
if (projectTarget == target) {
ownTargetHeaders.add(fileName, fileDirectory, fileName);
if (!isPublic && !isPrivate) {
ownTargetHeaders.add(frameworkName, fileDirectory, fileName);
if (includeFlatEntriesForTargetBeingBuilt) {
targetName.add(frameworkName, fileDirectory, fileName);
}
}
}
//.........这里部分代码省略.........