-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwnt_SourceBuffer.h
64 lines (42 loc) · 1.52 KB
/
wnt_SourceBuffer.h
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*=====================================================================
SourceBuffer.h
-------------------
Copyright Nicholas Chapman
Generated at 2011-06-11 19:19:16 +0100
=====================================================================*/
#pragma once
#include <utils/Reference.h>
#include <utils/RefCounted.h>
#include <string>
#include <map>
namespace Winter
{
/*=====================================================================
SourceBuffer
-------------------
=====================================================================*/
class SourceBuffer : public RefCounted
{
public:
SourceBuffer(const std::string& name_, const std::string& source_) : name(name_), source(source_) {}
~SourceBuffer();
static Reference<SourceBuffer> loadFromDisk(const std::string& path); // Throw BaseException on failure
std::string name;
std::string source;
std::map<std::string, std::string> user_data; // Stringly-typed user data.
private:
};
typedef Reference<SourceBuffer> SourceBufferRef;
typedef Reference<const SourceBuffer> SourceBufferConstRef;
class SrcLocation
{
public:
SrcLocation(size_t char_index_, size_t len_, const SourceBuffer* buf) :
char_index(char_index_), len(len_), source_buffer(buf) {}
static const SrcLocation invalidLocation() { return SrcLocation(4000000000u, 0, NULL); }
bool isValid() const { return char_index != 4000000000u; }
size_t char_index;
size_t len;
const SourceBuffer* source_buffer;
};
} // end namespace Winter