blob: 119a65393f63f06e8b7a5a77e38e1f4fb4b7ba08 [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 Huber84f89de2016-07-28 15:39:51 -070036
Andreas Huber0e00de42016-08-03 09:56:02 -070037 // Returns an absolute C++ namespace prefix, i.e.
38 // ::android::hardware::Foo.
39 std::string cppNamespace() const;
40
41 // Returns a fully qualified absolute C++ type name, i.e.
42 // ::android::hardware::Foo::bar::baz.
43 std::string cppName() const;
44
45 void getPackageComponents(std::vector<std::string> *components) const;
46
47 void getPackageAndVersionComponents(
48 std::vector<std::string> *components,
49 bool cpp_compatible) const;
50
Andreas Huber84f89de2016-07-28 15:39:51 -070051private:
52 bool mValid;
53 std::string mPackage;
54 std::string mVersion;
55 std::string mName;
Andreas Huber84f89de2016-07-28 15:39:51 -070056};
57
58} // namespace android
59
60#endif // FQNAME_H_