Merge "[view-compiler] Better namespacing of util functions" am: ff77ea8d58
am: 36c3953339
Change-Id: I5aa433d38991ec73280b267076ca20b784a032f8
This commit is contained in:
@@ -32,6 +32,7 @@
|
|||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
using namespace tinyxml2;
|
using namespace tinyxml2;
|
||||||
|
using namespace startop::util;
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
constexpr char kStdoutFilename[]{"stdout"};
|
constexpr char kStdoutFilename[]{"stdout"};
|
||||||
|
|||||||
@@ -18,6 +18,9 @@
|
|||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
|
namespace startop {
|
||||||
|
namespace util {
|
||||||
|
|
||||||
// TODO: see if we can borrow this from somewhere else, like aapt2.
|
// TODO: see if we can borrow this from somewhere else, like aapt2.
|
||||||
string FindLayoutNameFromFilename(const string& filename) {
|
string FindLayoutNameFromFilename(const string& filename) {
|
||||||
size_t start = filename.rfind("/");
|
size_t start = filename.rfind("/");
|
||||||
@@ -30,3 +33,6 @@ string FindLayoutNameFromFilename(const string& filename) {
|
|||||||
|
|
||||||
return filename.substr(start, end - start);
|
return filename.substr(start, end - start);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace util
|
||||||
|
} // namespace startop
|
||||||
|
|||||||
@@ -13,11 +13,17 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
#ifndef UTIL_H_
|
#ifndef VIEW_COMPILER_UTIL_H_
|
||||||
#define UTIL_H_
|
#define VIEW_COMPILER_UTIL_H_
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
namespace startop {
|
||||||
|
namespace util {
|
||||||
|
|
||||||
std::string FindLayoutNameFromFilename(const std::string& filename);
|
std::string FindLayoutNameFromFilename(const std::string& filename);
|
||||||
|
|
||||||
#endif // UTIL_H_
|
} // namespace util
|
||||||
|
} // namespace startop
|
||||||
|
|
||||||
|
#endif // VIEW_COMPILER_UTIL_H_
|
||||||
|
|||||||
@@ -20,9 +20,15 @@
|
|||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
|
namespace startop {
|
||||||
|
namespace util {
|
||||||
|
|
||||||
TEST(UtilTest, FindLayoutNameFromFilename) {
|
TEST(UtilTest, FindLayoutNameFromFilename) {
|
||||||
EXPECT_EQ("bar", ::FindLayoutNameFromFilename("foo/bar.xml"));
|
EXPECT_EQ("bar", startop::util::FindLayoutNameFromFilename("foo/bar.xml"));
|
||||||
EXPECT_EQ("bar", ::FindLayoutNameFromFilename("bar.xml"));
|
EXPECT_EQ("bar", startop::util::FindLayoutNameFromFilename("bar.xml"));
|
||||||
EXPECT_EQ("bar", ::FindLayoutNameFromFilename("./foo/bar.xml"));
|
EXPECT_EQ("bar", startop::util::FindLayoutNameFromFilename("./foo/bar.xml"));
|
||||||
EXPECT_EQ("bar", ::FindLayoutNameFromFilename("/foo/bar.xml"));
|
EXPECT_EQ("bar", startop::util::FindLayoutNameFromFilename("/foo/bar.xml"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace util
|
||||||
|
} // namespace startop
|
||||||
|
|||||||
Reference in New Issue
Block a user