hidl-gen: auto-generate depdendencies for nested types

HIDL allows for types to be defined within interfaces, and for these
types to be able to be referred to from outside of these interfaces.
hidl-gen was not emitting the correct #include and import paths in C++
and Java respectively for such cases, and also Makefile dependencies.

b/31268323

Change-Id: I168c52823098348b4161b5d2c151d1d8eadec9b8
Signed-off-by: Iliyan Malchev <malchev@google.com>
diff --git a/FQName.cpp b/FQName.cpp
index 9aa5a61..6f6fd09 100644
--- a/FQName.cpp
+++ b/FQName.cpp
@@ -17,7 +17,9 @@
 #include "FQName.h"
 
 #include <android-base/logging.h>
+#include <iostream>
 #include <regex>
+#include <sstream>
 
 #define RE_COMPONENT    "[a-zA-Z_][a-zA-Z_0-9]*"
 #define RE_PATH         RE_COMPONENT "([.]" RE_COMPONENT ")*"
@@ -102,6 +104,16 @@
     return mName;
 }
 
+std::vector<std::string> FQName::names() const {
+    std::vector<std::string> res {};
+    std::istringstream ss(name());
+    std::string s;
+    while (std::getline(ss, s, '.')) {
+        res.push_back(s);
+    }
+    return res;
+}
+
 void FQName::applyDefaults(
         const std::string &defaultPackage,
         const std::string &defaultVersion) {