Convenience functions to_hex(memory_cptr), find_and_clone_binary<>()

This commit is contained in:
Moritz Bunkus 2012-04-09 10:50:35 +02:00
parent 77b24f3422
commit ae4b8c7e13
2 changed files with 20 additions and 0 deletions

View File

@ -203,6 +203,21 @@ GetFirstOrNextChild(EbmlMaster *master,
return nullptr == previous_child ? GetChild<A>(*master) : GetNextChild<A>(*master, *previous_child);
}
template<typename T>
memory_cptr
find_and_clone_binary(EbmlElement &parent) {
auto child = FindChild<T>(static_cast<EbmlMaster &>(parent));
if (child)
return memory_c::clone(child->GetBuffer(), child->GetSize());
return memory_cptr{};
}
template<typename T>
memory_cptr
find_and_clone_binary(EbmlElement *parent) {
return find_and_clone_binary<T>(*parent);
}
EbmlElement *empty_ebml_master(EbmlElement *e);
EbmlElement *create_ebml_element(const EbmlCallbacks &callbacks, const EbmlId &id);
EbmlMaster *sort_ebml_master(EbmlMaster *e);

View File

@ -64,6 +64,11 @@ to_hex(const std::string &buf,
bool compact = false) {
return to_hex(reinterpret_cast<const unsigned char *>(buf.c_str()), buf.length(), compact);
}
inline std::string
to_hex(memory_cptr const &buf,
bool compact = false) {
return to_hex(buf->get_buffer(), buf->get_size(), compact);
}
std::string create_minutes_seconds_time_string(unsigned int seconds, bool omit_minutes_if_zero = false);