forked from OctaForge/libcubescript
add get_strr to retrieve read-only range without allocs
parent
6922853d66
commit
49e09a117e
|
@ -598,6 +598,26 @@ ostd::String Ident::get_str() const {
|
|||
return cs_get_str(val, get_valtype(), valtype >> 4);
|
||||
}
|
||||
|
||||
static inline ostd::ConstCharRange cs_get_strr(IdentValue const &v, int type, int len) {
|
||||
switch (type) {
|
||||
case VAL_STR:
|
||||
case VAL_MACRO:
|
||||
case VAL_CSTR:
|
||||
return ostd::ConstCharRange(v.s, len);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return ostd::ConstCharRange();
|
||||
}
|
||||
|
||||
ostd::ConstCharRange TaggedValue::get_strr() const {
|
||||
return cs_get_strr(*this, get_type(), p_type >> 4);
|
||||
}
|
||||
|
||||
ostd::ConstCharRange Ident::get_strr() const {
|
||||
return cs_get_strr(val, get_valtype(), valtype >> 4);
|
||||
}
|
||||
|
||||
static inline void cs_get_val(IdentValue const &v, int type, int len, TaggedValue &r) {
|
||||
switch (type) {
|
||||
case VAL_STR:
|
||||
|
|
|
@ -125,6 +125,7 @@ struct OSTD_EXPORT TaggedValue: IdentValue {
|
|||
}
|
||||
|
||||
ostd::String get_str() const;
|
||||
ostd::ConstCharRange get_strr() const;
|
||||
int get_int() const;
|
||||
float get_float() const;
|
||||
ostd::Uint32 *get_code() const;
|
||||
|
@ -275,6 +276,7 @@ struct OSTD_EXPORT Ident {
|
|||
float get_float() const;
|
||||
int get_int() const;
|
||||
ostd::String get_str() const;
|
||||
ostd::ConstCharRange get_strr() const;
|
||||
void get_val(TaggedValue &r) const;
|
||||
void get_cstr(TaggedValue &v) const;
|
||||
void get_cval(TaggedValue &v) const;
|
||||
|
|
Loading…
Reference in New Issue