Remove dependency on libutils.
As part of this, TypeDef has also been converted to a NamedType. This is
because originally, Scope contained just a KeyedVector<localname, idx> of
types which it contained, and an std::vector<type> which idx indexes into
(KeyedVector<localname, type> alone would have also worked). However, now
it contains a std::map<localname, idx> instead. Because of this, we have lost
the ability to iterate over the keys (localnames) in O(n). By converting
TypeDef to a NamedType, name => idx => type such that name == type->name.
This also means that in function hierarchy calling Scope::addType, we no
longer have to pass around the tuple (name, type) since type->name == name,
and we can pass around only type.
Change-Id: I8f85afe0e389979a2fd98ff5eeccf47e3fcc8307
diff --git a/Annotation.h b/Annotation.h
index f1aaf52..fc9b663 100644
--- a/Annotation.h
+++ b/Annotation.h
@@ -19,27 +19,39 @@
#define ANNOTATION_H_
#include <android-base/macros.h>
-
+#include <map>
#include <string>
-#include <utils/KeyedVector.h>
namespace android {
struct Formatter;
-using AnnotationParamVector =
- DefaultKeyedVector<std::string, std::vector<std::string> *>;
+
+struct AnnotationParam {
+ AnnotationParam(const std::string &name,
+ std::vector<std::string> *values);
+
+ const std::string &getName() const;
+ const std::vector<std::string> *getValues() const;
+
+private:
+ const std::string mName;
+ std::vector<std::string> *mValues;
+};
+
+using AnnotationParamVector = std::vector<const AnnotationParam*>;
struct Annotation {
Annotation(const char *name, AnnotationParamVector *params);
std::string name() const;
const AnnotationParamVector ¶ms() const;
+ const AnnotationParam *getParam(const std::string &name);
void dump(Formatter &out) const;
private:
std::string mName;
- AnnotationParamVector *mParamsByName;
+ AnnotationParamVector *mParams;
DISALLOW_COPY_AND_ASSIGN(Annotation);
};