From: Adam Dickmeiss Date: Mon, 29 Jun 2009 14:44:43 +0000 (+0200) Subject: New utility int GDU::get_size X-Git-Tag: v1.1.3~8 X-Git-Url: http://git.indexdata.com/?p=yazpp-moved-to-github.git;a=commitdiff_plain;h=f9728dc910413e30b7fe33c043b78d3736859ab4 New utility int GDU::get_size --- diff --git a/include/yazpp/gdu.h b/include/yazpp/gdu.h index 1e253a8..5450a28 100644 --- a/include/yazpp/gdu.h +++ b/include/yazpp/gdu.h @@ -42,6 +42,7 @@ namespace yazpp_1 { GDU &operator=(const GDU &); Z_GDU *get() const; void move_away_gdu(ODR dst, Z_GDU **gdu); + int get_size(); private: void base(Z_GDU *gdu, ODR o); Z_GDU *m_gdu; diff --git a/src/gdu.cpp b/src/gdu.cpp index 8df705e..10860cf 100644 --- a/src/gdu.cpp +++ b/src/gdu.cpp @@ -46,6 +46,15 @@ void GDU::base(Z_GDU *gdu, ODR encode) odr_destroy(encode); } +int GDU::get_size() +{ + int len = 0; + ODR encode = odr_createmem(ODR_ENCODE); + if (m_gdu && z_GDU(encode, &m_gdu, 0, "encode")) + odr_getbuf(encode, &len, 0); + odr_destroy(encode); + return len; +} GDU &GDU::operator=(const GDU &g) {