blob: 02c03bdc4fadd6a76e6db7005289badc6a71689c [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.
39 // ::android::hardware::Foo.
40 std::string cppNamespace() const;
41
42 // Returns a fully qualified absolute C++ type name, i.e.
43 // ::android::hardware::Foo::bar::baz.
44 std::string cppName() const;
45
46 void getPackageComponents(std::vector<std::string> *components) const;
47
48 void getPackageAndVersionComponents(
49 std::vector<std::string> *components,
50 bool cpp_compatible) const;
51
Andreas Huberd2943e12016-08-05 11:59:31 -070052 static std::string JoinStrings(
53 const std::vector<std::string> &components,
54 const std::string &separator);
55
Andreas Huber84f89de2016-07-28 15:39:51 -070056private:
57 bool mValid;
58 std::string mPackage;
59 std::string mVersion;
60 std::string mName;
Andreas Huber84f89de2016-07-28 15:39:51 -070061};
62
63} // namespace android
64
65#endif // FQNAME_H_