Skip to content

Commit

Permalink
byml: Add non-const overloads of GetString/Array/Hash
Browse files Browse the repository at this point in the history
  • Loading branch information
leoetlino committed Mar 15, 2020
1 parent a90cd59 commit cd34918
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion py/py_byml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ void BindByml(py::module& parent) {
m.def("get_float", BorrowByml(&Byml::GetFloat), "data"_a);
m.def("get_int", BorrowByml(&Byml::GetInt), "data"_a);
m.def("get_int64", BorrowByml(&Byml::GetInt64), "data"_a);
m.def("get_string", BorrowByml(&Byml::GetString), "data"_a);
m.def("get_string", BorrowByml(py::overload_cast<>(&Byml::GetString, py::const_)), "data"_a);
m.def("get_uint", BorrowByml(&Byml::GetUInt), "data"_a);
m.def("get_uint64", BorrowByml(&Byml::GetUInt64), "data"_a);

Expand Down
12 changes: 12 additions & 0 deletions src/byml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,18 @@ std::vector<u8> Byml::ToBinary(bool big_endian, int version) const {
return ctx.writer.Finalize();
}

Byml::Hash& Byml::GetHash() {
return Get<Type::Hash>();
}

Byml::Array& Byml::GetArray() {
return Get<Type::Array>();
}

Byml::String& Byml::GetString() {
return Get<Type::String>();
}

const Byml::Hash& Byml::GetHash() const {
return Get<Type::Hash>();
}
Expand Down
3 changes: 3 additions & 0 deletions src/include/oead/byml.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ class Byml {
// Some of them will perform type conversions automatically.
// If value types are incorrect, an exception is thrown.

Hash& GetHash();
Array& GetArray();
String& GetString();
const Hash& GetHash() const;
const Array& GetArray() const;
const String& GetString() const;
Expand Down

0 comments on commit cd34918

Please sign in to comment.