forked from OctaForge/libcubescript
use listparser more
This commit is contained in:
parent
7ed92f19cc
commit
97b070b972
|
@ -4004,23 +4004,24 @@ endblock:
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace util {
|
namespace util {
|
||||||
ostd::Size list_length(const char *str) {
|
ostd::Size list_length(ostd::ConstCharRange s) {
|
||||||
ListParser p(str);
|
ListParser p(s);
|
||||||
ostd::Size ret = 0;
|
ostd::Size ret = 0;
|
||||||
while (p.parse()) ++ret;
|
while (p.parse()) ++ret;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ostd::Maybe<ostd::String> list_index(const char *s, ostd::Size idx) {
|
ostd::Maybe<ostd::String> list_index(ostd::ConstCharRange s,
|
||||||
|
ostd::Size idx) {
|
||||||
|
ListParser p(s);
|
||||||
for (ostd::Size i = 0; i < idx; ++i)
|
for (ostd::Size i = 0; i < idx; ++i)
|
||||||
if (!parselist(s)) return ostd::nothing;
|
if (!p.parse()) return ostd::nothing;
|
||||||
const char *start, *end, *qstart;
|
if (!p.parse())
|
||||||
if (!parselist(s, start, end, qstart))
|
|
||||||
return ostd::nothing;
|
return ostd::nothing;
|
||||||
return ostd::move(listelem(start, end, qstart));
|
return ostd::move(p.element());
|
||||||
}
|
}
|
||||||
|
|
||||||
ostd::Vector<ostd::String> list_explode(const char *s,
|
ostd::Vector<ostd::String> list_explode(ostd::ConstCharRange s,
|
||||||
ostd::Size limit) {
|
ostd::Size limit) {
|
||||||
ostd::Vector<ostd::String> ret;
|
ostd::Vector<ostd::String> ret;
|
||||||
ListParser p(s);
|
ListParser p(s);
|
||||||
|
|
|
@ -470,9 +470,10 @@ namespace util {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ostd::Size list_length(const char *str);
|
ostd::Size list_length(ostd::ConstCharRange s);
|
||||||
ostd::Maybe<ostd::String> list_index(const char *s, ostd::Size idx);
|
ostd::Maybe<ostd::String> list_index(ostd::ConstCharRange s,
|
||||||
ostd::Vector<ostd::String> list_explode(const char *s,
|
ostd::Size idx);
|
||||||
|
ostd::Vector<ostd::String> list_explode(ostd::ConstCharRange s,
|
||||||
ostd::Size limit = -1);
|
ostd::Size limit = -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue