summaryrefslogtreecommitdiff
path: root/tools/minicargo/helpers.h
diff options
context:
space:
mode:
authorJohn Hodge <tpg@mutabah.net>2018-03-18 10:48:26 +0800
committerJohn Hodge <tpg@mutabah.net>2018-04-01 14:02:32 +0800
commit5701df58fa8c9e067474659e6c54e47856cef7f0 (patch)
treec288493eb4ed7f9fe7ae998bde3c553484a989b2 /tools/minicargo/helpers.h
parentc643adf22ea365bd7c8ed40f971c0cc99c9cf2a6 (diff)
downloadmrust-5701df58fa8c9e067474659e6c54e47856cef7f0.tar.gz
All - Move toml parser and path header to a common library, start on custom target specs.
Diffstat (limited to 'tools/minicargo/helpers.h')
-rw-r--r--tools/minicargo/helpers.h53
1 files changed, 0 insertions, 53 deletions
diff --git a/tools/minicargo/helpers.h b/tools/minicargo/helpers.h
deleted file mode 100644
index 8111483a..00000000
--- a/tools/minicargo/helpers.h
+++ /dev/null
@@ -1,53 +0,0 @@
-#pragma once
-
-#include <string>
-#include <cstring>
-#include <iostream>
-
-namespace helpers {
-
-class string_view
-{
- const char* m_start;
- const size_t m_len;
-public:
- string_view(const char* s, size_t n):
- m_start(s), m_len(n)
- {
- }
-
- bool operator==(const ::std::string& s) const {
- return *this == s.c_str();
- }
- bool operator==(const char* s) const {
- if(::std::strncmp(m_start, s, m_len) != 0)
- return false;
- return s[m_len] == '\0';
- }
-
- char operator[](size_t n) const {
- return m_start[n];
- }
-
- operator ::std::string() const {
- return ::std::string { m_start, m_start + m_len };
- }
- friend ::std::string& operator+=(::std::string& x, const string_view& sv) {
- x.append(sv.m_start, sv.m_start+sv.m_len);
- return x;
- }
- friend ::std::ostream& operator<<(::std::ostream& os, const string_view& sv) {
- os.write(sv.m_start, sv.m_len);
- return os;
- }
-
- const char* begin() const {
- return m_start;
- }
- const char* end() const {
- return m_start+m_len;
- }
-};
-
-
-} // namespace helpers