summaryrefslogtreecommitdiff
path: root/starts/meaning-vm/level-1/baseref.hpp
blob: 8c358ccb596e8e1c63a88db98469e6443695ddb1 (plain)
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
#pragma once

#include "common.hpp"
#include "funcs.hpp"

#include "../level-0/ref.hpp"

namespace intellect {
namespace level1 {

template <typename ref>
struct baseref : public level0::baseref<ref>
{
	baseref(concept * p) : level0::baseref<ref>(p) { }
	baseref(level0::ref const & other) : baseref(other.ptr()) { }
	baseref(std::string const & name) : baseref(getnamed(name)) { }
	baseref(const char *name) : baseref(std::string(name)) { }
	baseref(bool b) : baseref(b ? "true" : "false") { }
	baseref() : baseref("nothing") { }

	bool isa(ref group) const { return level1::isa(self, group); }
	bool isan(ref group) const { return isa(group); }

	std::string const & name() const { return getname(self)->data; }
	operator std::string const &() const { return getname(self)->data; }
	operator char const *() const { return getname(self)->data.c_str(); }

	ref operator-(ref other) { return hyphenate(self.ptr(), other.ptr()); }

	std::string dump(ref skipmarkertype, ref skipmarkertarget);
};

}
}