From f9728dc910413e30b7fe33c043b78d3736859ab4 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Mon, 29 Jun 2009 16:44:43 +0200 Subject: [PATCH] New utility int GDU::get_size --- include/yazpp/gdu.h | 1 + src/gdu.cpp | 9 +++++++++ 2 files changed, 10 insertions(+) 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) { -- 1.7.10.4