Class: MemoryIO::Types::Clang::CStr Private
- Defined in:
- lib/memory_io/types/clang/c_str.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
A null-terminated string.
Constant Summary
Constants inherited from Type
Class Method Summary collapse
-
.read(stream) ⇒ String
private
String without null byte.
- .write(stream, val) ⇒ Object private
Methods inherited from Type
find, keep_pos, read_size_t, register, write_size_t
Class Method Details
.read(stream) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns String without null byte.
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/memory_io/types/clang/c_str.rb', line 19 def self.read(stream) ret = +'' loop do c = stream.read(1) break if c.nil? || c == '' || c == "\x00" ret << c end ret end |
.write(stream, val) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
34 35 36 37 38 |
# File 'lib/memory_io/types/clang/c_str.rb', line 34 def self.write(stream, val) val = val.to_s val += "\x00" unless val.end_with?("\x00") stream.write(val) end |