当前位置: 首页>>代码示例>>C++>>正文


C++ Identifier::str方法代码示例

本文整理汇总了C++中Identifier::str方法的典型用法代码示例。如果您正苦于以下问题:C++ Identifier::str方法的具体用法?C++ Identifier::str怎么用?C++ Identifier::str使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Identifier的用法示例。


在下文中一共展示了Identifier::str方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

std::unique_ptr<proto::Bip44Address> Blockchain::LoadAddress(
    const Identifier& nymID,
    const Identifier& accountID,
    const std::uint32_t index,
    const BIP44Chain chain) const
{
    LOCK_ACCOUNT()

    std::unique_ptr<proto::Bip44Address> output{};
    const std::string sNymID = nymID.str();
    const std::string sAccountID = accountID.str();
    auto account = load_account(accountLock, sNymID, sAccountID);

    if (false == bool(account)) {
        otErr << OT_METHOD << __FUNCTION__ << ": Account does not exist."
              << std::endl;

        return output;
    }

    const auto allocatedIndex =
        chain ? account->internalindex() : account->externalindex();

    if (index > allocatedIndex) {
        otErr << OT_METHOD << __FUNCTION__
              << ": Address has not been allocated." << std::endl;

        return output;
    }

    auto& address = find_address(index, chain, *account);
    output.reset(new proto::Bip44Address(address));

    return output;
}
开发者ID:Open-Transactions,项目名称:opentxs,代码行数:35,代码来源:Blockchain.cpp

示例2: addParameters

static void addParameters(ArrayRef<Identifier> &ArgNames,
                          const ParameterList *paramList,
                          TextEntity &Ent,
                          SourceManager &SM,
                          unsigned BufferID) {
  for (auto &param : *paramList) {
    StringRef Arg;
    if (!ArgNames.empty()) {
      Identifier Id = ArgNames.front();
      Arg = Id.empty() ? "_" : Id.str();
      ArgNames = ArgNames.slice(1);
    }

    if (auto typeRepr = param->getTypeLoc().getTypeRepr()) {
      SourceRange TypeRange = param->getTypeLoc().getSourceRange();
      if (auto InOutTyR = dyn_cast_or_null<InOutTypeRepr>(typeRepr))
        TypeRange = InOutTyR->getBase()->getSourceRange();
      if (TypeRange.isInvalid())
        continue;
      
      unsigned StartOffs = SM.getLocOffsetInBuffer(TypeRange.Start, BufferID);
      unsigned EndOffs =
        SM.getLocOffsetInBuffer(Lexer::getLocForEndOfToken(SM, TypeRange.End),
                                BufferID);
      TextRange TR{ StartOffs, EndOffs-StartOffs };
      TextEntity Param(param, Arg, TR, StartOffs);
      Ent.SubEntities.push_back(std::move(Param));
    }
  }
}
开发者ID:CrazyCamouflage,项目名称:swift,代码行数:30,代码来源:SwiftDocSupport.cpp

示例3: StoreOutgoing

bool Blockchain::StoreOutgoing(
    const Identifier& senderNymID,
    const Identifier& accountID,
    const Identifier& recipientContactID,
    const proto::BlockchainTransaction& transaction) const
{
    LOCK_ACCOUNT()

    const std::string sNymID = senderNymID.str();
    const std::string sAccountID = accountID.str();
    auto account = load_account(accountLock, sNymID, sAccountID);

    if (false == bool(account)) {
        otErr << OT_METHOD << __FUNCTION__ << ": Account does not exist."
              << std::endl;

        return false;
    }

    const auto& txid = transaction.txid();
    account->add_outgoing(txid);
    auto saved = api_.Storage().Store(sNymID, account->type(), *account);

    if (false == saved) {
        otErr << OT_METHOD << __FUNCTION__ << ": Failed to save account."
              << std::endl;

        return false;
    }

    saved = api_.Storage().Store(transaction);

    if (false == saved) {
        otErr << OT_METHOD << __FUNCTION__ << ": Failed to save transaction."
              << std::endl;

        return false;
    }

    if (recipientContactID.empty()) { return true; }

    return activity_.AddBlockchainTransaction(
        senderNymID,
        recipientContactID,
        StorageBox::OUTGOINGBLOCKCHAIN,
        transaction);
}
开发者ID:Open-Transactions,项目名称:opentxs,代码行数:47,代码来源:Blockchain.cpp

示例4: compare

int Identifier::compare(Identifier other) const {
  // Handle empty identifiers.
  if (empty() || other.empty()) {
    if (empty() != other.empty()) {
      return other.empty() ? -1 : 1;
    }

    return 0;
  }

  return str().compare(other.str());
}
开发者ID:wincc0823,项目名称:swift,代码行数:12,代码来源:Identifier.cpp

示例5: addParameters

static void addParameters(ArrayRef<Identifier> &ArgNames,
                          const Pattern *Pat,
                          TextEntity &Ent,
                          SourceManager &SM,
                          unsigned BufferID) {
  if (auto ParenPat = dyn_cast<ParenPattern>(Pat)) {
    addParameters(ArgNames, ParenPat->getSubPattern(), Ent, SM, BufferID);
    return;
  }

  if (auto Tuple = dyn_cast<TuplePattern>(Pat)) {
    for (const auto &Elt : Tuple->getElements())
      addParameters(ArgNames, Elt.getPattern(), Ent, SM, BufferID);

    return;
  }

  StringRef Arg;
  if (!ArgNames.empty()) {
    Identifier Id = ArgNames.front();
    Arg = Id.empty() ? "_" : Id.str();
    ArgNames = ArgNames.slice(1);
  }

  if (auto Typed = dyn_cast<TypedPattern>(Pat)) {
    VarDecl *VD = nullptr;
    if (auto Named = dyn_cast<NamedPattern>(Typed->getSubPattern())) {
      VD = Named->getDecl();
    }
    SourceRange TypeRange = Typed->getTypeLoc().getSourceRange();
    if (auto InOutTyR =
        dyn_cast_or_null<InOutTypeRepr>(Typed->getTypeLoc().getTypeRepr())) {
      TypeRange = InOutTyR->getBase()->getSourceRange();
    }
    if (TypeRange.isInvalid())
      return;
    unsigned StartOffs = SM.getLocOffsetInBuffer(TypeRange.Start, BufferID);
    unsigned EndOffs =
      SM.getLocOffsetInBuffer(Lexer::getLocForEndOfToken(SM, TypeRange.End),
                              BufferID);
    TextRange TR{ StartOffs, EndOffs-StartOffs };
    TextEntity Param(VD, Arg, TR, StartOffs);
    Ent.SubEntities.push_back(std::move(Param));
  }
}
开发者ID:asdfeng,项目名称:swift,代码行数:45,代码来源:SwiftDocSupport.cpp

示例6: assert

SILWitnessTable *
SILWitnessTable::create(SILModule &M, SILLinkage Linkage,
                        NormalProtocolConformance *Conformance) {
  assert(Conformance && "Cannot create a witness table for a null "
         "conformance.");

  // Create the mangled name of our witness table...
  Identifier Name = M.getASTContext().getIdentifier(mangleConstant(Conformance));


  // Allocate the witness table and initialize it.
  void *buf = M.allocate(sizeof(SILWitnessTable), alignof(SILWitnessTable));
  SILWitnessTable *wt = ::new (buf) SILWitnessTable(M, Linkage, Name.str(),
                                                    Conformance);

  wt->addWitnessTable();

  // Return the resulting witness table.
  return wt;
}
开发者ID:yasirmcs,项目名称:swift,代码行数:20,代码来源:SILWitnessTable.cpp

示例7: AddContract

bool Nym::AddContract(
    const Identifier& instrumentDefinitionID,
    const proto::ContactItemType currency,
    const bool primary,
    const bool active)
{
    const std::string id(instrumentDefinitionID.str());

    if (id.empty()) { return false; }

    eLock lock(shared_lock_);

    if (false == bool(contact_data_)) { init_claims(lock); }

    contact_data_.reset(new ContactData(
        contact_data_->AddContract(id, currency, primary, active)));

    OT_ASSERT(contact_data_);

    return set_contact_data(lock, contact_data_->Serialize());
}
开发者ID:Open-Transactions,项目名称:opentxs,代码行数:21,代码来源:Nym.cpp

示例8: AddChildKeyCredential

std::string Nym::AddChildKeyCredential(
    const Identifier& masterID,
    const NymParameters& nymParameters)
{
    eLock lock(shared_lock_);

    std::string output;
    std::string master = masterID.str();
    auto it = m_mapCredentialSets.find(master);
    const bool noMaster = (it == m_mapCredentialSets.end());

    if (noMaster) {
        otErr << __FUNCTION__ << ": master ID not found." << std::endl;

        return output;
    }

    if (it->second) {
        output = it->second->AddChildKeyCredential(nymParameters);
    }

    return output;
}
开发者ID:Open-Transactions,项目名称:opentxs,代码行数:23,代码来源:Nym.cpp

示例9: NewAccount

OTIdentifier Blockchain::NewAccount(
    const Identifier& nymID,
    const BlockchainAccountType standard,
    const proto::ContactItemType type) const
{
    LOCK_NYM()

    const std::string sNymID = nymID.str();
    auto existing = api_.Storage().BlockchainAccountList(sNymID, type);

    if (0 < existing.size()) {
        otErr << OT_METHOD << __FUNCTION__ << ": Account already exists."
              << std::endl;

        return Identifier::Factory(*existing.begin());
    }

    auto nym = api_.Wallet().Nym(nymID);

    if (false == bool(nym)) {
        otErr << OT_METHOD << __FUNCTION__ << ": Nym does not exist."
              << std::endl;

        return Identifier::Factory();
    }

    proto::HDPath nymPath{};

    if (false == nym->Path(nymPath)) {
        otErr << OT_METHOD << __FUNCTION__ << ": No nym path." << std::endl;

        return Identifier::Factory();
    }

    if (0 == nymPath.root().size()) {
        otErr << OT_METHOD << __FUNCTION__ << ": Missing root." << std::endl;

        return Identifier::Factory();
    }

    if (2 > nymPath.child().size()) {
        otErr << OT_METHOD << __FUNCTION__ << ": Invalid path." << std::endl;

        return Identifier::Factory();
    }

    proto::HDPath accountPath{};
    init_path(
        nymPath.root(),
        type,
        nymPath.child(1) | static_cast<std::uint32_t>(Bip32Child::HARDENED),
        standard,
        accountPath);
    const auto accountID = Identifier::Factory(type, accountPath);
    Lock accountLock(account_lock_[accountID]);
    proto::Bip44Account account{};
    account.set_version(ACCOUNT_VERSION);
    account.set_id(accountID->str());
    account.set_type(type);
    account.set_revision(0);
    *account.mutable_path() = accountPath;
    account.set_internalindex(0);
    account.set_externalindex(0);
    account.clear_internaladdress();
    account.clear_externaladdress();

    const bool saved = api_.Storage().Store(sNymID, type, account);

    if (saved) { return accountID; }

    otErr << OT_METHOD << __FUNCTION__ << ": Failed to save account."
          << std::endl;

    return Identifier::Factory();
}
开发者ID:Open-Transactions,项目名称:opentxs,代码行数:75,代码来源:Blockchain.cpp

示例10: performCompile


//.........这里部分代码省略.........
      SF = &Instance.getMainModule()->getMainSourceFile(Kind);
    }
    if (Action == FrontendOptions::PrintAST)
      SF->print(llvm::outs(), PrintOptions::printEverything());
    else if (Action == FrontendOptions::DumpTypeRefinementContexts)
      SF->getTypeRefinementContext()->dump(llvm::errs(), Context.SourceMgr);
    else if (Action == FrontendOptions::DumpInterfaceHash)
      SF->dumpInterfaceHash(llvm::errs());
    else
      SF->dump();
    return false;
  }

  // If we were asked to print Clang stats, do so.
  if (opts.PrintClangStats && Context.getClangModuleLoader())
    Context.getClangModuleLoader()->printStatistics();

  if (!opts.DependenciesFilePath.empty())
    (void)emitMakeDependencies(Context.Diags, *Instance.getDependencyTracker(),
                               opts);

  if (shouldTrackReferences)
    emitReferenceDependencies(Context.Diags, Instance.getPrimarySourceFile(),
                              *Instance.getDependencyTracker(), opts);

  if (Context.hadError())
    return true;

  // FIXME: This is still a lousy approximation of whether the module file will
  // be externally consumed.
  bool moduleIsPublic =
      !Instance.getMainModule()->hasEntryPoint() &&
      opts.ImplicitObjCHeaderPath.empty() &&
      !Context.LangOpts.EnableAppExtensionRestrictions;

  // We've just been told to perform a parse, so we can return now.
  if (Action == FrontendOptions::Parse) {
    if (!opts.ObjCHeaderOutputPath.empty())
      return printAsObjC(opts.ObjCHeaderOutputPath, Instance.getMainModule(),
                         opts.ImplicitObjCHeaderPath, moduleIsPublic);
    return false;
  }

  assert(Action >= FrontendOptions::EmitSILGen &&
         "All actions not requiring SILGen must have been handled!");

  std::unique_ptr<SILModule> SM = Instance.takeSILModule();
  if (!SM) {
    if (opts.PrimaryInput.hasValue() && opts.PrimaryInput.getValue().isFilename()) {
      FileUnit *PrimaryFile = PrimarySourceFile;
      if (!PrimaryFile) {
        auto Index = opts.PrimaryInput.getValue().Index;
        PrimaryFile = Instance.getMainModule()->getFiles()[Index];
      }
      SM = performSILGeneration(*PrimaryFile, Invocation.getSILOptions(),
                                None, opts.SILSerializeAll);
    } else {
      SM = performSILGeneration(Instance.getMainModule(), Invocation.getSILOptions(),
                                opts.SILSerializeAll,
                                true);
    }
  }

  // We've been told to emit SIL after SILGen, so write it now.
  if (Action == FrontendOptions::EmitSILGen) {
    // If we are asked to link all, link all.
开发者ID:AaronPelzer,项目名称:swift,代码行数:67,代码来源:frontend_main.cpp

示例11: printValue

/// Print an identifier value.
static void printValue(llvm::raw_ostream &os, Identifier value) {
  os << value.str();
}
开发者ID:ahoppen,项目名称:swift,代码行数:4,代码来源:ConstraintGraph.cpp

示例12: performCompile


//.........这里部分代码省略.........
      }

      // Print the resulting map.
      scope.print(llvm::errs());
    } else if (Action == FrontendOptions::DumpTypeRefinementContexts)
      SF->getTypeRefinementContext()->dump(llvm::errs(), Context.SourceMgr);
    else if (Action == FrontendOptions::DumpInterfaceHash)
      SF->dumpInterfaceHash(llvm::errs());
    else
      SF->dump();
    return Context.hadError();
  }

  // If we were asked to print Clang stats, do so.
  if (opts.PrintClangStats && Context.getClangModuleLoader())
    Context.getClangModuleLoader()->printStatistics();

  if (!opts.DependenciesFilePath.empty())
    (void)emitMakeDependencies(Context.Diags, *Instance->getDependencyTracker(),
                               opts);

  if (shouldTrackReferences)
    emitReferenceDependencies(Context.Diags, Instance->getPrimarySourceFile(),
                              *Instance->getDependencyTracker(), opts);

  if (Context.hadError())
    return true;

  // FIXME: This is still a lousy approximation of whether the module file will
  // be externally consumed.
  bool moduleIsPublic =
      !Instance->getMainModule()->hasEntryPoint() &&
      opts.ImplicitObjCHeaderPath.empty() &&
      !Context.LangOpts.EnableAppExtensionRestrictions;

  // We've just been told to perform a typecheck, so we can return now.
  if (Action == FrontendOptions::Typecheck) {
    if (!opts.ObjCHeaderOutputPath.empty())
      return printAsObjC(opts.ObjCHeaderOutputPath, Instance->getMainModule(),
                         opts.ImplicitObjCHeaderPath, moduleIsPublic);
    return Context.hadError();
  }

  assert(Action >= FrontendOptions::EmitSILGen &&
         "All actions not requiring SILGen must have been handled!");

  std::unique_ptr<SILModule> SM = Instance->takeSILModule();
  if (!SM) {
    if (opts.PrimaryInput.hasValue() && opts.PrimaryInput.getValue().isFilename()) {
      FileUnit *PrimaryFile = PrimarySourceFile;
      if (!PrimaryFile) {
        auto Index = opts.PrimaryInput.getValue().Index;
        PrimaryFile = Instance->getMainModule()->getFiles()[Index];
      }
      SM = performSILGeneration(*PrimaryFile, Invocation.getSILOptions(),
                                None, opts.SILSerializeAll);
    } else {
      SM = performSILGeneration(Instance->getMainModule(), Invocation.getSILOptions(),
                                opts.SILSerializeAll,
                                true);
    }
  }

  if (observer) {
    observer->performedSILGeneration(*SM);
  }
开发者ID:apple,项目名称:swift,代码行数:67,代码来源:FrontendTool.cpp

示例13: formatValue

	void formatValue(std::ostream& out, const char* /*fmtBegin*/, const char* fmtEnd, int ntrunc, const Identifier& id)
	{
		out << id.str();
	}
开发者ID:flax-lang,项目名称:flax,代码行数:4,代码来源:identifier.cpp

示例14: versionString

void swift::serialization::diagnoseSerializedASTLoadFailure(
    ASTContext &Ctx, SourceLoc diagLoc,
    const serialization::ValidationInfo &loadInfo,
    const serialization::ExtendedValidationInfo &extendedInfo,
    StringRef moduleBufferID, StringRef moduleDocBufferID,
    ModuleFile *loadedModuleFile, Identifier ModuleName) {
  auto diagnoseDifferentLanguageVersion = [&](StringRef shortVersion) -> bool {
    if (shortVersion.empty())
      return false;

    SmallString<32> versionBuf;
    llvm::raw_svector_ostream versionString(versionBuf);
    versionString << Version::getCurrentLanguageVersion();
    if (versionString.str() == shortVersion)
      return false;

    Ctx.Diags.diagnose(
        diagLoc, diag::serialization_module_language_version_mismatch,
        loadInfo.shortVersion, versionString.str(), moduleBufferID);
    return true;
  };

  switch (loadInfo.status) {
  case serialization::Status::Valid:
    llvm_unreachable("At this point we know loading has failed");

  case serialization::Status::FormatTooNew:
    if (diagnoseDifferentLanguageVersion(loadInfo.shortVersion))
      break;
    Ctx.Diags.diagnose(diagLoc, diag::serialization_module_too_new,
                       moduleBufferID);
    break;
  case serialization::Status::FormatTooOld:
    if (diagnoseDifferentLanguageVersion(loadInfo.shortVersion))
      break;
    Ctx.Diags.diagnose(diagLoc, diag::serialization_module_too_old, ModuleName,
                       moduleBufferID);
    break;
  case serialization::Status::Malformed:
    Ctx.Diags.diagnose(diagLoc, diag::serialization_malformed_module,
                       moduleBufferID);
    break;

  case serialization::Status::MalformedDocumentation:
    assert(!moduleDocBufferID.empty());
    Ctx.Diags.diagnose(diagLoc, diag::serialization_malformed_module,
                       moduleDocBufferID);
    break;

  case serialization::Status::MissingDependency: {
    // Figure out /which/ dependencies are missing.
    // FIXME: Dependencies should be de-duplicated at serialization time,
    // not now.
    llvm::StringSet<> duplicates;
    llvm::SmallVector<ModuleFile::Dependency, 4> missing;
    std::copy_if(
        loadedModuleFile->getDependencies().begin(),
        loadedModuleFile->getDependencies().end(), std::back_inserter(missing),
        [&duplicates](const ModuleFile::Dependency &dependency) -> bool {
          if (dependency.isLoaded() || dependency.isHeader() ||
              dependency.isImplementationOnly()) {
            return false;
          }
          return duplicates.insert(dependency.RawPath).second;
        });

    // FIXME: only show module part of RawAccessPath
    assert(!missing.empty() && "unknown missing dependency?");
    if (missing.size() == 1) {
      Ctx.Diags.diagnose(diagLoc, diag::serialization_missing_single_dependency,
                         missing.front().getPrettyPrintedPath());
    } else {
      llvm::SmallString<64> missingNames;
      missingNames += '\'';
      interleave(missing,
                 [&](const ModuleFile::Dependency &next) {
                   missingNames += next.getPrettyPrintedPath();
                 },
                 [&] { missingNames += "', '"; });
      missingNames += '\'';

      Ctx.Diags.diagnose(diagLoc, diag::serialization_missing_dependencies,
                         missingNames);
    }

    if (Ctx.SearchPathOpts.SDKPath.empty() &&
        llvm::Triple(llvm::sys::getProcessTriple()).isMacOSX()) {
      Ctx.Diags.diagnose(SourceLoc(), diag::sema_no_import_no_sdk);
      Ctx.Diags.diagnose(SourceLoc(), diag::sema_no_import_no_sdk_xcrun);
    }
    break;
  }

  case serialization::Status::CircularDependency: {
    auto circularDependencyIter =
        llvm::find_if(loadedModuleFile->getDependencies(),
                      [](const ModuleFile::Dependency &next) {
                        return !next.Import.second->hasResolvedImports();
                      });
    assert(circularDependencyIter !=
//.........这里部分代码省略.........
开发者ID:benrimmington,项目名称:swift,代码行数:101,代码来源:SerializedModuleLoader.cpp

示例15: AssignAddress

bool Blockchain::AssignAddress(
    const Identifier& nymID,
    const Identifier& accountID,
    const std::uint32_t index,
    const Identifier& contactID,
    const BIP44Chain chain) const
{
    LOCK_ACCOUNT()

    const std::string sNymID = nymID.str();
    const std::string sAccountID = accountID.str();
    const std::string sContactID = contactID.str();
    auto account = load_account(accountLock, sNymID, sAccountID);

    if (false == bool(account)) {
        otErr << OT_METHOD << __FUNCTION__ << ": Account does not exist."
              << std::endl;

        return false;
    }

    const auto& type = account->type();
    const auto allocatedIndex =
        chain ? account->internalindex() : account->externalindex();

    if (index > allocatedIndex) {
        otErr << OT_METHOD << __FUNCTION__
              << ": Address has not been allocated." << std::endl;

        return false;
    }

    auto& address = find_address(index, chain, *account);
    const auto& existing = address.contact();

    if (false == existing.empty()) {
        move_transactions(nymID, address, existing, sContactID);
    }

    address.set_contact(sContactID);
    account->set_revision(account->revision() + 1);

    // check: does the activity thread exist between nym and contact?
    bool threadExists = false;
    const auto threadList = api_.Storage().ThreadList(sNymID, false);
    for (const auto it : threadList) {
        const auto& id = it.first;

        if (id == sContactID) { threadExists = true; }
    }

    if (threadExists) {
        // check: does every incoming transaction exist as an activity
        std::shared_ptr<proto::StorageThread> thread =
            activity_.Thread(nymID, contactID);
        OT_ASSERT(thread);
        for (const std::string& txID : address.incoming()) {
            bool exists = false;
            for (const auto activity : thread->item())
                if (txID.compare(activity.id()) == 0) exists = true;

            // add: transaction to the thread
            if (!exists) {
                activity_.AddBlockchainTransaction(
                    nymID,
                    contactID,
                    StorageBox::INCOMINGBLOCKCHAIN,
                    *Transaction(txID));
            }
        }
    } else {
        // create the thread and add the transactions
        for (const auto txID : address.incoming()) {
            activity_.AddBlockchainTransaction(
                nymID,
                contactID,
                StorageBox::INCOMINGBLOCKCHAIN,
                *Transaction(txID));
        }
    }

    return api_.Storage().Store(sNymID, type, *account);
}
开发者ID:Open-Transactions,项目名称:opentxs,代码行数:83,代码来源:Blockchain.cpp


注:本文中的Identifier::str方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。