summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Android Build Merger (Role) <noreply-android-build-merger@google.com> 2019-01-02 19:59:13 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2019-01-02 19:59:13 +0000
commitf569bb29b0dc82a2c6c744b84f20e607abc27cd4 (patch)
treef09a52ace16ffd84be52c4fa52673e3ce64f2951
parent7e2a7339b1b0bc98ec46e3ed9462b4fb856516af (diff)
parent4d4ce9080595d7e8a2b6f8e68716f2d28350afd7 (diff)
Merge "Merge "[view-compiler] Better namespacing of util functions" am: ff77ea8d58 am: 36c3953339 am: b63e813feb"
-rw-r--r--startop/view_compiler/main.cc1
-rw-r--r--startop/view_compiler/util.cc6
-rw-r--r--startop/view_compiler/util.h12
-rw-r--r--startop/view_compiler/util_test.cc14
4 files changed, 26 insertions, 7 deletions
diff --git a/startop/view_compiler/main.cc b/startop/view_compiler/main.cc
index 55bfdc78ec1b..609bcf377b46 100644
--- a/startop/view_compiler/main.cc
+++ b/startop/view_compiler/main.cc
@@ -32,6 +32,7 @@
namespace {
using namespace tinyxml2;
+using namespace startop::util;
using std::string;
constexpr char kStdoutFilename[]{"stdout"};
diff --git a/startop/view_compiler/util.cc b/startop/view_compiler/util.cc
index 69df41dff3d7..a0637e6da32f 100644
--- a/startop/view_compiler/util.cc
+++ b/startop/view_compiler/util.cc
@@ -18,6 +18,9 @@
using std::string;
+namespace startop {
+namespace util {
+
// TODO: see if we can borrow this from somewhere else, like aapt2.
string FindLayoutNameFromFilename(const string& filename) {
size_t start = filename.rfind("/");
@@ -30,3 +33,6 @@ string FindLayoutNameFromFilename(const string& filename) {
return filename.substr(start, end - start);
}
+
+} // namespace util
+} // namespace startop
diff --git a/startop/view_compiler/util.h b/startop/view_compiler/util.h
index 03e093920bfa..0176175920c1 100644
--- a/startop/view_compiler/util.h
+++ b/startop/view_compiler/util.h
@@ -13,11 +13,17 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#ifndef UTIL_H_
-#define UTIL_H_
+#ifndef VIEW_COMPILER_UTIL_H_
+#define VIEW_COMPILER_UTIL_H_
#include <string>
+namespace startop {
+namespace util {
+
std::string FindLayoutNameFromFilename(const std::string& filename);
-#endif // UTIL_H_
+} // namespace util
+} // namespace startop
+
+#endif // VIEW_COMPILER_UTIL_H_
diff --git a/startop/view_compiler/util_test.cc b/startop/view_compiler/util_test.cc
index d1540d3a6e43..50682a04e3b1 100644
--- a/startop/view_compiler/util_test.cc
+++ b/startop/view_compiler/util_test.cc
@@ -20,9 +20,15 @@
using std::string;
+namespace startop {
+namespace util {
+
TEST(UtilTest, FindLayoutNameFromFilename) {
- EXPECT_EQ("bar", ::FindLayoutNameFromFilename("foo/bar.xml"));
- EXPECT_EQ("bar", ::FindLayoutNameFromFilename("bar.xml"));
- EXPECT_EQ("bar", ::FindLayoutNameFromFilename("./foo/bar.xml"));
- EXPECT_EQ("bar", ::FindLayoutNameFromFilename("/foo/bar.xml"));
+ EXPECT_EQ("bar", startop::util::FindLayoutNameFromFilename("foo/bar.xml"));
+ EXPECT_EQ("bar", startop::util::FindLayoutNameFromFilename("bar.xml"));
+ EXPECT_EQ("bar", startop::util::FindLayoutNameFromFilename("./foo/bar.xml"));
+ EXPECT_EQ("bar", startop::util::FindLayoutNameFromFilename("/foo/bar.xml"));
}
+
+} // namespace util
+} // namespace startop