Change const char* to std::string
This is just to make the constructors more consistent.
Bug: 137953313
Test: TH
Change-Id: Id297da99cf246cd64095b3e1e2d219300fec99ff
diff --git a/Annotation.cpp b/Annotation.cpp
index 4c9637f..eefead1 100644
--- a/Annotation.cpp
+++ b/Annotation.cpp
@@ -20,6 +20,7 @@
#include <hidl-util/Formatter.h>
#include <hidl-util/StringHelper.h>
#include <algorithm>
+#include <string>
#include <vector>
namespace android {
@@ -104,7 +105,7 @@
return ret;
}
-Annotation::Annotation(const char* name, AnnotationParamVector* params)
+Annotation::Annotation(const std::string& name, AnnotationParamVector* params)
: mName(name), mParams(params) {}
std::string Annotation::name() const {
diff --git a/Annotation.h b/Annotation.h
index dfeb59e..d0d8167 100644
--- a/Annotation.h
+++ b/Annotation.h
@@ -78,7 +78,7 @@
using AnnotationParamVector = std::vector<AnnotationParam*>;
struct Annotation {
- Annotation(const char *name, AnnotationParamVector *params);
+ Annotation(const std::string& name, AnnotationParamVector* params);
std::string name() const;
const AnnotationParamVector ¶ms() const;
diff --git a/CompoundType.cpp b/CompoundType.cpp
index 53020b2..9d1cf7e 100644
--- a/CompoundType.cpp
+++ b/CompoundType.cpp
@@ -23,11 +23,12 @@
#include <android-base/logging.h>
#include <hidl-util/Formatter.h>
#include <iostream>
+#include <string>
#include <unordered_set>
namespace android {
-CompoundType::CompoundType(Style style, const char* localName, const FQName& fullName,
+CompoundType::CompoundType(Style style, const std::string& localName, const FQName& fullName,
const Location& location, Scope* parent)
: Scope(localName, fullName, location, parent), mStyle(style), mFields(nullptr) {}
diff --git a/CompoundType.h b/CompoundType.h
index 2c5a055..c1cfce0 100644
--- a/CompoundType.h
+++ b/CompoundType.h
@@ -21,6 +21,7 @@
#include "Reference.h"
#include "Scope.h"
+#include <string>
#include <vector>
namespace android {
@@ -32,7 +33,7 @@
STYLE_SAFE_UNION,
};
- CompoundType(Style style, const char* localName, const FQName& fullName,
+ CompoundType(Style style, const std::string& localName, const FQName& fullName,
const Location& location, Scope* parent);
Style style() const;
diff --git a/EnumType.cpp b/EnumType.cpp
index d0e88a3..9f483cc 100644
--- a/EnumType.cpp
+++ b/EnumType.cpp
@@ -19,6 +19,7 @@
#include <hidl-util/Formatter.h>
#include <inttypes.h>
#include <iostream>
+#include <string>
#include <unordered_map>
#include "Annotation.h"
@@ -27,7 +28,7 @@
namespace android {
-EnumType::EnumType(const char* localName, const FQName& fullName, const Location& location,
+EnumType::EnumType(const std::string& localName, const FQName& fullName, const Location& location,
const Reference<Type>& storageType, Scope* parent)
: Scope(localName, fullName, location, parent), mValues(), mStorageType(storageType) {}
@@ -770,7 +771,7 @@
////////////////////////////////////////////////////////////////////////////////
-EnumValue::EnumValue(const char* name, ConstantExpression* value, const Location& location)
+EnumValue::EnumValue(const std::string& name, ConstantExpression* value, const Location& location)
: mName(name), mValue(value), mLocation(location), mIsAutoFill(false) {}
std::string EnumValue::name() const {
diff --git a/EnumType.h b/EnumType.h
index ab796d1..98ed818 100644
--- a/EnumType.h
+++ b/EnumType.h
@@ -22,6 +22,7 @@
#include "Reference.h"
#include "Scope.h"
+#include <string>
#include <vector>
namespace android {
@@ -30,7 +31,7 @@
struct BitFieldType;
struct EnumType : public Scope {
- EnumType(const char* localName, const FQName& fullName, const Location& location,
+ EnumType(const std::string& localName, const FQName& fullName, const Location& location,
const Reference<Type>& storageType, Scope* parent);
const Type *storageType() const;
@@ -146,7 +147,7 @@
};
struct EnumValue : public LocalIdentifier, DocCommentable {
- EnumValue(const char* name, ConstantExpression* value, const Location& location);
+ EnumValue(const std::string& name, ConstantExpression* value, const Location& location);
std::string name() const;
std::string rawValue(ScalarType::Kind castKind) const;
diff --git a/FmqType.cpp b/FmqType.cpp
index ed323f2..fa49928 100644
--- a/FmqType.cpp
+++ b/FmqType.cpp
@@ -18,12 +18,14 @@
#include "HidlTypeAssertion.h"
-#include <hidl-util/Formatter.h>
#include <android-base/logging.h>
+#include <hidl-util/Formatter.h>
+#include <string>
namespace android {
-FmqType::FmqType(const char* nsp, const char* name, Scope* parent, const char* definedName)
+FmqType::FmqType(const std::string& nsp, const std::string& name, Scope* parent,
+ const std::string& definedName)
: TemplatedType(parent, definedName), mNamespace(nsp), mName(name) {}
std::string FmqType::templatedTypeName() const {
diff --git a/FmqType.h b/FmqType.h
index f6b1f18..92a7273 100644
--- a/FmqType.h
+++ b/FmqType.h
@@ -20,10 +20,13 @@
#include "Type.h"
+#include <string>
+
namespace android {
struct FmqType : public TemplatedType {
- FmqType(const char* nsp, const char* name, Scope* parent, const char* definedName);
+ FmqType(const std::string& nsp, const std::string& name, Scope* parent,
+ const std::string& definedName);
std::string fullName() const;
diff --git a/Interface.cpp b/Interface.cpp
index ff33972..1fa9ed3 100644
--- a/Interface.cpp
+++ b/Interface.cpp
@@ -30,6 +30,7 @@
#include <iostream>
#include <memory>
#include <sstream>
+#include <string>
#include <unordered_map>
#include <android-base/logging.h>
@@ -71,7 +72,7 @@
const std::unique_ptr<ConstantExpression> Interface::FLAG_ONE_WAY =
std::make_unique<LiteralConstantExpression>(ScalarType::KIND_UINT32, 0x01, "oneway");
-Interface::Interface(const char* localName, const FQName& fullName, const Location& location,
+Interface::Interface(const std::string& localName, const FQName& fullName, const Location& location,
Scope* parent, const Reference<Type>& superType, const Hash* fileHash)
: Scope(localName, fullName, location, parent), mSuperType(superType), mFileHash(fileHash) {}
diff --git a/Interface.h b/Interface.h
index e0fcb8b..78ba5aa 100644
--- a/Interface.h
+++ b/Interface.h
@@ -18,6 +18,7 @@
#define INTERFACE_H_
+#include <string>
#include <vector>
#include <hidl-hash/Hash.h>
@@ -34,7 +35,7 @@
struct Interface : public Scope {
const static std::unique_ptr<ConstantExpression> FLAG_ONE_WAY;
- Interface(const char* localName, const FQName& fullName, const Location& location,
+ Interface(const std::string& localName, const FQName& fullName, const Location& location,
Scope* parent, const Reference<Type>& superType, const Hash* fileHash);
const Hash* getFileHash() const;
diff --git a/Method.cpp b/Method.cpp
index 42b4d5c..797e503 100644
--- a/Method.cpp
+++ b/Method.cpp
@@ -26,11 +26,12 @@
#include <hidl-util/FQName.h>
#include <hidl-util/Formatter.h>
#include <algorithm>
+#include <string>
#include <vector>
namespace android {
-Method::Method(const char* name, std::vector<NamedReference<Type>*>* args,
+Method::Method(const std::string& name, std::vector<NamedReference<Type>*>* args,
std::vector<NamedReference<Type>*>* results, bool oneway,
std::vector<Annotation*>* annotations, const Location& location)
: mName(name),
diff --git a/Method.h b/Method.h
index 5c5ac47..3860f91 100644
--- a/Method.h
+++ b/Method.h
@@ -52,7 +52,7 @@
using MethodImpl = std::map<MethodImplType, std::function<void(Formatter &)>>;
struct Method : DocCommentable {
- Method(const char* name, std::vector<NamedReference<Type>*>* args,
+ Method(const std::string& name, std::vector<NamedReference<Type>*>* args,
std::vector<NamedReference<Type>*>* results, bool oneway,
std::vector<Annotation*>* annotations, const Location& location);
diff --git a/NamedType.cpp b/NamedType.cpp
index dba9248..2024237 100644
--- a/NamedType.cpp
+++ b/NamedType.cpp
@@ -16,9 +16,11 @@
#include "NamedType.h"
+#include <string>
+
namespace android {
-NamedType::NamedType(const char* localName, const FQName& fullName, const Location& loc,
+NamedType::NamedType(const std::string& localName, const FQName& fullName, const Location& loc,
Scope* parent)
: Type(parent, localName), mLocalName(localName), mFullName(fullName), mLocation(loc) {}
diff --git a/NamedType.h b/NamedType.h
index 857f3a3..9b0fcf0 100644
--- a/NamedType.h
+++ b/NamedType.h
@@ -28,7 +28,8 @@
namespace android {
struct NamedType : public Type {
- NamedType(const char* localName, const FQName& fullName, const Location& loc, Scope* parent);
+ NamedType(const std::string& localName, const FQName& fullName, const Location& loc,
+ Scope* parent);
bool isNamedType() const override;
diff --git a/Scope.cpp b/Scope.cpp
index cfe004d..c8f57b8 100644
--- a/Scope.cpp
+++ b/Scope.cpp
@@ -25,11 +25,13 @@
#include <hidl-util/StringHelper.h>
#include <algorithm>
#include <iostream>
+#include <string>
#include <vector>
namespace android {
-Scope::Scope(const char* localName, const FQName& fullName, const Location& location, Scope* parent)
+Scope::Scope(const std::string& localName, const FQName& fullName, const Location& location,
+ Scope* parent)
: NamedType(localName, fullName, location, parent) {}
Scope::~Scope(){}
diff --git a/Scope.h b/Scope.h
index a62bad8..2331d80 100644
--- a/Scope.h
+++ b/Scope.h
@@ -21,6 +21,7 @@
#include "NamedType.h"
#include <map>
+#include <string>
#include <unordered_map>
#include <vector>
@@ -33,7 +34,8 @@
struct LocalIdentifier;
struct Scope : public NamedType {
- Scope(const char* localName, const FQName& fullName, const Location& location, Scope* parent);
+ Scope(const std::string& localName, const FQName& fullName, const Location& location,
+ Scope* parent);
virtual ~Scope();
void addType(NamedType* type);
diff --git a/TypeDef.cpp b/TypeDef.cpp
index 2e36c28..452795d 100644
--- a/TypeDef.cpp
+++ b/TypeDef.cpp
@@ -16,12 +16,13 @@
#include "TypeDef.h"
-#include <hidl-util/Formatter.h>
#include <android-base/logging.h>
+#include <hidl-util/Formatter.h>
+#include <string>
namespace android {
-TypeDef::TypeDef(const char* localName, const FQName& fullName, const Location& location,
+TypeDef::TypeDef(const std::string& localName, const FQName& fullName, const Location& location,
Scope* parent, const Reference<Type>& type)
: NamedType(localName, fullName, location, parent), mReferencedType(type) {}
diff --git a/TypeDef.h b/TypeDef.h
index d620765..330e0c3 100644
--- a/TypeDef.h
+++ b/TypeDef.h
@@ -20,11 +20,13 @@
#include "NamedType.h"
+#include <string>
+
namespace android {
struct TypeDef : public NamedType {
- TypeDef(const char* localName, const FQName& fullName, const Location& location, Scope* parent,
- const Reference<Type>& type);
+ TypeDef(const std::string& localName, const FQName& fullName, const Location& location,
+ Scope* parent, const Reference<Type>& type);
const ScalarType *resolveToScalarType() const override;