blob: ae7fe800304fd72cc55a003e5d85f09f315ed449 [file] [log] [blame]
Andreas Huber84f89de2016-07-28 15:39:51 -07001#ifndef FQNAME_H_
2
3#define FQNAME_H_
4
5#include <android-base/macros.h>
6#include <string>
Andreas Huber0e00de42016-08-03 09:56:02 -07007#include <vector>
Andreas Huber84f89de2016-07-28 15:39:51 -07008
9namespace android {
10
11struct FQName {
Andreas Huberda51b8e2016-07-28 16:00:57 -070012 explicit FQName();
Andreas Huber84f89de2016-07-28 15:39:51 -070013 explicit FQName(const std::string &s);
14
Andreas Huber68f24592016-07-29 14:53:48 -070015 FQName(const std::string &package,
16 const std::string &version,
17 const std::string &name);
18
Andreas Huber84f89de2016-07-28 15:39:51 -070019 bool isValid() const;
20 bool setTo(const std::string &s);
21
22 void applyDefaults(
23 const std::string &defaultPackage,
24 const std::string &defaultVersion);
25
26 std::string package() const;
27 std::string version() const;
28 std::string name() const;
29
Andreas Huber68f24592016-07-29 14:53:48 -070030 bool isFullyQualified() const;
31
Andreas Huberda51b8e2016-07-28 16:00:57 -070032 void print() const;
Andreas Huber68f24592016-07-29 14:53:48 -070033 std::string string() const;
34
35 bool operator<(const FQName &other) const;
Andreas Huberd2943e12016-08-05 11:59:31 -070036 bool operator==(const FQName &other) const;
Andreas Huber84f89de2016-07-28 15:39:51 -070037
Andreas Huber0e00de42016-08-03 09:56:02 -070038 // Returns an absolute C++ namespace prefix, i.e.
Andreas Huber2831d512016-08-15 09:33:47 -070039 // ::android::hardware::Foo::V1_0.
Andreas Huber0e00de42016-08-03 09:56:02 -070040 std::string cppNamespace() const;
41
42 // Returns a fully qualified absolute C++ type name, i.e.
Andreas Huber2831d512016-08-15 09:33:47 -070043 // ::android::hardware::Foo::V1_0::bar::baz.
Andreas Huber0e00de42016-08-03 09:56:02 -070044 std::string cppName() const;
45
Andreas Huber2831d512016-08-15 09:33:47 -070046 // Returns the java package name, i.e. "android.hardware.Foo.V1_0".
47 std::string javaPackage() const;
48
49 // Returns the fully qualified java type name,
50 // i.e. "android.hardware.Foo.V1_0.IBar"
51 std::string javaName() const;
52
Andreas Huber0e00de42016-08-03 09:56:02 -070053 void getPackageComponents(std::vector<std::string> *components) const;
54
55 void getPackageAndVersionComponents(
56 std::vector<std::string> *components,
57 bool cpp_compatible) const;
58
Andreas Huberd2943e12016-08-05 11:59:31 -070059 static std::string JoinStrings(
60 const std::vector<std::string> &components,
61 const std::string &separator);
62
Andreas Huber84f89de2016-07-28 15:39:51 -070063private:
64 bool mValid;
65 std::string mPackage;
66 std::string mVersion;
67 std::string mName;
Andreas Huber84f89de2016-07-28 15:39:51 -070068};
69
70} // namespace android
71
72#endif // FQNAME_H_