/src/CMake/Source/cmObjectLocation.cxx
Line | Count | Source |
1 | | /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying |
2 | | file LICENSE.rst or https://cmake.org/licensing for details. */ |
3 | | |
4 | | #include "cmObjectLocation.h" |
5 | | |
6 | | void cmObjectLocation::Update(std::string path) |
7 | 0 | { |
8 | 0 | this->Path = std::move(path); |
9 | 0 | } |
10 | | |
11 | | std::string const& cmObjectLocation::GetPath() const |
12 | 0 | { |
13 | 0 | return this->Path; |
14 | 0 | } |
15 | | |
16 | | cm::string_view cmObjectLocation::GetDirectory() const |
17 | 0 | { |
18 | 0 | auto const pos = this->Path.rfind('/'); |
19 | 0 | if (pos == std::string::npos) { |
20 | 0 | return {}; |
21 | 0 | } |
22 | 0 | return cm::string_view(this->Path.c_str(), pos); |
23 | 0 | } |
24 | | |
25 | | cm::string_view cmObjectLocation::GetName() const |
26 | 0 | { |
27 | 0 | auto const pos = this->Path.rfind('/'); |
28 | 0 | if (pos == std::string::npos) { |
29 | 0 | return this->Path; |
30 | 0 | } |
31 | 0 | auto const nameStart = pos + 1; |
32 | 0 | return cm::string_view(this->Path.c_str() + nameStart, |
33 | 0 | this->Path.size() - nameStart); |
34 | 0 | } |
35 | | |
36 | | cmObjectLocation const& cmObjectLocations::GetLocation(UseShortPath use) const |
37 | 0 | { |
38 | 0 | if (use == UseShortPath::Yes && this->ShortLoc) { |
39 | 0 | return *this->ShortLoc; |
40 | 0 | } |
41 | 0 | return this->LongLoc; |
42 | 0 | } |
43 | | |
44 | | std::string const& cmObjectLocations::GetPath(UseShortPath use) const |
45 | 0 | { |
46 | 0 | return this->GetLocation(use).GetPath(); |
47 | 0 | } |
48 | | |
49 | | cmObjectLocation const& cmObjectLocations::GetInstallLocation( |
50 | | UseShortPath use, std::string const& config) const |
51 | 0 | { |
52 | 0 | if (use == UseShortPath::Yes && this->ShortLoc) { |
53 | 0 | return *this->ShortLoc; |
54 | 0 | } |
55 | 0 | auto it = this->InstallLongLoc.find(config); |
56 | 0 | if (it != this->InstallLongLoc.end()) { |
57 | 0 | return it->second; |
58 | 0 | } |
59 | 0 | return this->LongLoc; |
60 | 0 | } |
61 | | |
62 | | std::string const& cmObjectLocations::GetInstallPath( |
63 | | UseShortPath use, std::string const& config) const |
64 | 0 | { |
65 | 0 | return this->GetInstallLocation(use, config).GetPath(); |
66 | 0 | } |