forked from sass/libsass
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtoken.hpp
32 lines (22 loc) · 854 Bytes
/
token.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#define SASS_TOKEN
#include <cstring>
#include <string>
#include <sstream>
namespace Sass {
using namespace std;
// Token type for representing lexed chunks of text
struct Token {
const char* begin;
const char* end;
Token() : begin(0), end(0) { }
Token(const char* s) : begin(s), end(s + strlen(s)) { }
Token(const char* b, const char* e) : begin(b), end(e) { }
size_t length() const { return end - begin; }
string to_string() const { return string(begin, end - begin); }
string unquote() const;
void unquote_to_stream(stringstream& buf) const;
operator bool() { return begin && end && begin >= end; }
operator string() { return to_string(); }
bool operator==(Token t) { return to_string() == t.to_string(); }
};
}