def build_result_object(sid,input)
t,code = read(input)
dputs ": code=#{code}"
raise IOError.new("Wrong Result message: code field is not integer1.") unless t == T_INTEGER1
case code
when R_OK
t,value = read(input)
return ResultOkObject.new(sid,value)
when R_APP_ERROR,R_PROTOCOL_ERROR,R_FATAL_ERROR
t,err_klass = read(input)
raise IOError.new("Wrong Result message: error-class field is not string. #{t}") unless t == T_STRING || t == T_NULL
t,err_message = read(input)
raise IOError.new("Wrong Result message: error-message field is not string. #{t}") unless t == T_STRING || t == T_NULL
t,err_detail = read(input)
raise IOError.new("Wrong Result message: error-detail field is not string. #{t}") unless t == T_STRING || t == T_NULL
return ResultErrObject.new(sid,code,err_klass,err_message,err_detail)
else
raise IOError.new("Unknown return code: #{@code}")
end
end