41 lines
758 B
C++
41 lines
758 B
C++
#include "sand/type_builder.h"
|
|
|
|
#include "sand/rule_builder.h"
|
|
#include "sand/type_range.h"
|
|
|
|
#include <cassert>
|
|
using namespace sand;
|
|
|
|
type::builder::builder() :
|
|
// 0 is a special ID
|
|
next_id(1),
|
|
default_conversions{ OFF_GRID }
|
|
{
|
|
}
|
|
|
|
type type::builder::assign()
|
|
{
|
|
default_conversions.push_back(next_id);
|
|
return next_id++;
|
|
}
|
|
|
|
type::range type::builder::assign_range(unsigned int count)
|
|
{
|
|
assert(count > 0 && "count must be greater than 0");
|
|
|
|
type::range r(next_id, next_id + count);
|
|
next_id += count;
|
|
|
|
return r;
|
|
}
|
|
|
|
void type::builder::set_default_conversion(const type& to, const type& from)
|
|
{
|
|
default_conversions[to] = from;
|
|
}
|
|
|
|
rule::builder type::builder::build()
|
|
{
|
|
return rule::builder(type::range(0, next_id), default_conversions);
|
|
}
|