From 38f94b2a19aeadc6ea55883bd8301d450324d019 Mon Sep 17 00:00:00 2001
From: Danilo Piparo <danilo.piparo@cern.ch>
Date: Tue, 14 May 2019 19:02:22 +0200
Subject: [PATCH] [forest] Convert to string stringview w/o using the to_string
 method

since it does not exist in the c++17 stl.
---
 tree/forest/v7/inc/ROOT/RField.hxx       | 6 +++---
 tree/forest/v7/inc/ROOT/RForestView.hxx  | 2 +-
 tree/forest/v7/src/RField.cxx            | 8 ++++----
 tree/forest/v7/src/RForest.cxx           | 2 +-
 tree/forest/v7/src/RForestDescriptor.cxx | 6 +++---
 tree/forest/v7/src/RPageStorageRoot.cxx  | 4 ++--
 6 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/tree/forest/v7/inc/ROOT/RField.hxx b/tree/forest/v7/inc/ROOT/RField.hxx
index 0438eb2f832..a2e10708946 100644
--- a/tree/forest/v7/inc/ROOT/RField.hxx
+++ b/tree/forest/v7/inc/ROOT/RField.hxx
@@ -642,7 +642,7 @@ class ROOT::Experimental::RField<std::vector<ItemT>> : public ROOT::Experimental
 public:
    static std::string MyTypeName() { return "std::vector<" + RField<ItemT>::MyTypeName() + ">"; }
    explicit RField(std::string_view name)
-      : RFieldVector(name, std::make_unique<RField<ItemT>>(GetCollectionName(name.to_string())))
+      : RFieldVector(name, std::make_unique<RField<ItemT>>(GetCollectionName(std::string(name))))
    {}
    RField(RField&& other) = default;
    RField& operator =(RField&& other) = default;
@@ -709,14 +709,14 @@ public:
       Attach(std::move(itemField));
    }
    explicit RField(std::string_view name)
-      : RField(name, std::make_unique<RField<ItemT>>(GetCollectionName(name.to_string())))
+      : RField(name, std::make_unique<RField<ItemT>>(GetCollectionName(std::string(name))))
    {
    }
    RField(RField&& other) = default;
    RField& operator =(RField&& other) = default;
    ~RField() = default;
    RFieldBase* Clone(std::string_view newName) final {
-      auto newItemField = fSubFields[0]->Clone(GetCollectionName(newName.to_string()));
+      auto newItemField = fSubFields[0]->Clone(GetCollectionName(std::string(newName)));
       return new RField<ROOT::VecOps::RVec<ItemT>>(newName, std::unique_ptr<Detail::RFieldBase>(newItemField));
    }
 
diff --git a/tree/forest/v7/inc/ROOT/RForestView.hxx b/tree/forest/v7/inc/ROOT/RForestView.hxx
index ddd7c6caa4c..15d4d25d351 100644
--- a/tree/forest/v7/inc/ROOT/RForestView.hxx
+++ b/tree/forest/v7/inc/ROOT/RForestView.hxx
@@ -157,7 +157,7 @@ private:
    std::string GetSubName(std::string_view name) {
       std::string prefix(fCollectionName);
       prefix.push_back(Detail::RFieldBase::kCollectionSeparator);
-      return prefix + name.to_string();
+      return prefix + std::string(name);
    }
 
 public:
diff --git a/tree/forest/v7/src/RField.cxx b/tree/forest/v7/src/RField.cxx
index f5627dbd303..90996feb656 100644
--- a/tree/forest/v7/src/RField.cxx
+++ b/tree/forest/v7/src/RField.cxx
@@ -326,10 +326,10 @@ void ROOT::Experimental::RField<std::string>::CommitCluster()
 
 ROOT::Experimental::RFieldClass::RFieldClass(std::string_view fieldName, std::string_view className)
    : ROOT::Experimental::Detail::RFieldBase(fieldName, className, EForestStructure::kRecord, false /* isSimple */)
-   , fClass(TClass::GetClass(className.to_string().c_str()))
+   , fClass(TClass::GetClass(std::string(className).c_str()))
 {
    if (fClass == nullptr) {
-      throw std::runtime_error("RField: no I/O support for type " + className.to_string());
+      throw std::runtime_error("RField: no I/O support for type " + std::string(className));
    }
    TIter next(fClass->GetListOfDataMembers());
    while (auto dataMember = static_cast<TDataMember *>(next())) {
@@ -413,7 +413,7 @@ ROOT::Experimental::RFieldVector::RFieldVector(
 
 ROOT::Experimental::Detail::RFieldBase* ROOT::Experimental::RFieldVector::Clone(std::string_view newName)
 {
-   auto newItemField = fSubFields[0]->Clone(GetCollectionName(newName.to_string()));
+   auto newItemField = fSubFields[0]->Clone(GetCollectionName(std::string(newName)));
    return new RFieldVector(newName, std::unique_ptr<Detail::RFieldBase>(newItemField));
 }
 
@@ -530,7 +530,7 @@ ROOT::Experimental::Detail::RFieldBase* ROOT::Experimental::RFieldCollection::Cl
    //auto result = new RFieldCollection(newName, fCollectionForest, RForestModel::Create());
    //for (auto& f : fSubFields) {
    //   // switch the name prefix for the new parent name
-   //   std::string cloneName = newName.to_string() + f->GetName().substr(GetName().length());
+   //   std::string cloneName = std::string(newName) + f->GetName().substr(GetName().length());
    //   auto clone = f->Clone(cloneName);
    //   result->Attach(std::unique_ptr<RFieldBase>(clone));
    //}
diff --git a/tree/forest/v7/src/RForest.cxx b/tree/forest/v7/src/RForest.cxx
index aad86704848..d44c37b811f 100644
--- a/tree/forest/v7/src/RForest.cxx
+++ b/tree/forest/v7/src/RForest.cxx
@@ -127,7 +127,7 @@ std::unique_ptr<ROOT::Experimental::ROutputForest> ROOT::Experimental::ROutputFo
    std::string_view storage)
 {
    // TODO(jblomer): heuristics based on storage
-   TFile *file = TFile::Open(storage.to_string().c_str(), "RECREATE");
+   TFile *file = TFile::Open(std::string(storage).c_str(), "RECREATE");
    Detail::RPageSinkRoot::RSettings settings;
    settings.fFile = file;
    settings.fTakeOwnership = true;
diff --git a/tree/forest/v7/src/RForestDescriptor.cxx b/tree/forest/v7/src/RForestDescriptor.cxx
index 3fe9ffba84f..9fdd67653d8 100644
--- a/tree/forest/v7/src/RForestDescriptor.cxx
+++ b/tree/forest/v7/src/RForestDescriptor.cxx
@@ -18,7 +18,7 @@
 #include <ROOT/RStringView.hxx>
 
 void ROOT::Experimental::RForestDescriptorBuilder::SetForest(std::string_view name, const RForestVersion &version) {
-   fDescriptor.fName = name.to_string();
+   fDescriptor.fName = std::string(name);
    fDescriptor.fVersion = version;
 }
 
@@ -30,8 +30,8 @@ void ROOT::Experimental::RForestDescriptorBuilder::AddField(
    f.fFieldId = fieldId;
    f.fFieldVersion = fieldVersion;
    f.fTypeVersion = typeVersion;
-   f.fFieldName = fieldName.to_string();
-   f.fTypeName = typeName.to_string();
+   f.fFieldName = std::string(fieldName);
+   f.fTypeName = std::string(typeName);
    f.fStructure = structure;
    fDescriptor.fFieldDescriptors[fieldId] = f;
 }
diff --git a/tree/forest/v7/src/RPageStorageRoot.cxx b/tree/forest/v7/src/RPageStorageRoot.cxx
index 2da3851c211..de2e2bf97b1 100644
--- a/tree/forest/v7/src/RPageStorageRoot.cxx
+++ b/tree/forest/v7/src/RPageStorageRoot.cxx
@@ -46,7 +46,7 @@ ROOT::Experimental::Detail::RPageSinkRoot::RPageSinkRoot(std::string_view forest
 {
    R__WARNING_HERE("Forest") << "The RForest file format will change. " <<
       "Do not store real data with this version of RForest!";
-   TFile *file = TFile::Open(path.to_string().c_str(), "UPDATE");
+   TFile *file = TFile::Open(std::string(path).c_str(), "UPDATE");
    fSettings.fFile = file;
    fSettings.fTakeOwnership = true;
 }
@@ -158,7 +158,7 @@ ROOT::Experimental::Detail::RPageSourceRoot::RPageSourceRoot(std::string_view fo
    , fForestName(forestName)
    , fDirectory(nullptr)
 {
-   TFile *file = TFile::Open(path.to_string().c_str(), "READ");
+   TFile *file = TFile::Open(std::string(path).c_str(), "READ");
    fSettings.fFile = file;
    fSettings.fTakeOwnership = true;
 }
-- 
GitLab