Class: VCDiff::Decoder
- Inherits:
-
Object
- Object
- VCDiff::Decoder
- Defined in:
- ext/vcdiff_wrap.cxx
Instance Method Summary collapse
-
#decode(dictionary, delta) ⇒ String?
Performs decoding of the delta using the provided dictionary, returning str, or
nil
if the decoder fails.
Instance Method Details
#decode(dictionary, delta) ⇒ String?
Performs decoding of the delta using the provided dictionary, returning str, or nil
if the decoder fails.
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 |
# File 'ext/vcdiff_wrap.cxx', line 152
static VALUE _wrap_VCDiffDecoder_Decode(VALUE self, VALUE dict, VALUE delta) {
open_vcdiff::VCDiffDecoder *decoder = NULL;
bool result;
VALUE str;
VALUE d;
string output;
string *c_delta;
Data_Get_Struct(self, open_vcdiff::VCDiffDecoder, decoder);
str = StringValue(dict);
d = StringValue(delta);
c_delta = new string(RSTRING_PTR(d), RSTRING_LEN(d));
result = decoder->Decode((char const *)RSTRING_PTR(str), RSTRING_LEN(str), *c_delta , &output);
delete c_delta;
if (result) {
str = rb_str_new(output.data(), output.length());
output.clear();
return str;
} else {
return Qnil;
}
}
|