Class: VCDiff::Encoder

Inherits:
Object
  • Object
show all
Defined in:
ext/vcdiff_wrap.cxx

Instance Method Summary collapse

Constructor Details

#initialize(arg) ⇒ Object



56
57
58
59
60
61
62
63
64
# File 'ext/vcdiff_wrap.cxx', line 56

static VALUE _wrap_new_VCDiffEncoder(VALUE self, VALUE arg) {
  open_vcdiff::VCDiffEncoder *result = 0 ;
  VALUE str;

  str = StringValue(arg);
  result = new open_vcdiff::VCDiffEncoder((char const *)RSTRING_PTR(str),RSTRING_LEN(str));
  DATA_PTR(self) = result;
  return self;
}

Instance Method Details

#encode(data) ⇒ String?

Performs encoding of the data, returning str, or nil if the encoder fails.

Returns:

  • (String, nil)


113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# File 'ext/vcdiff_wrap.cxx', line 113

static VALUE _wrap_VCDiffEncoder_Encode(VALUE self, VALUE arg) {
  	open_vcdiff::VCDiffEncoder *encoder = NULL;
  	bool result;
  	VALUE str;
  	string output;

	Data_Get_Struct(self, open_vcdiff::VCDiffEncoder, encoder);
  	str = StringValue(arg);

  	result = encoder->Encode((char const *)RSTRING_PTR(str),RSTRING_LEN(str), &output);

  	if (result) {
		str = rb_str_new(output.data(), output.length());
		output.clear();
		return str;
  	} else {
		return Qnil;
  	}
}

#format_flags=(Fixnum) ⇒ nil

By default, VCDiffEncoder uses standard VCDIFF format. This function

can be used before calling encode(), to specify that interleaved format
and/or checksum format should be used.

Returns:

  • (nil)


73
74
75
76
77
78
79
# File 'ext/vcdiff_wrap.cxx', line 73

static VALUE _wrap_VCDiffEncoder_SetFormatFlags(VALUE self, VALUE arg) {
	open_vcdiff::VCDiffEncoder *encoder = NULL;
	Data_Get_Struct(self, open_vcdiff::VCDiffEncoder, encoder);

  	encoder->SetFormatFlags(FIX2INT(arg));
  	return Qnil;
}

#target_matching=(bool) ⇒ nil

By default, VCDiffEncoder looks for matches in the dictionary and also in the previously encoded target data. This function can be used before calling encode(), to specify whether or not target matching should be enabled.

Returns:

  • (nil)


90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'ext/vcdiff_wrap.cxx', line 90

static VALUE _wrap_VCDiffEncoder_SetTargetMatching(VALUE self, VALUE arg) {
  	open_vcdiff::VCDiffEncoder *encoder = NULL;
	Data_Get_Struct(self, open_vcdiff::VCDiffEncoder, encoder);

	if ( arg == Qtrue ) {
  		encoder->SetTargetMatching(true);
	}
	else if ( arg == Qfalse || arg == Qnil ) {
		encoder->SetTargetMatching(false);
	}
	else {
		rb_raise(rb_eArgError, "boolean expected");
	}
  	return Qnil;
}