indexing
description: "[
To easily manage allocation and release of allocated C memory, and
to perform insertion of basic elements. Byte order is by default
platform specific.
Although memory allocation routines do not accept a zero sized pointer
MANAGED_POINTER does by allocating in fact a 1 byte sized pointer for
this particular case.
]"
legal: "See notice at end of class."
status: "See notice at end of class."
date: "$Date: 2006-04-19 15:21:41 -0700 (Wed, 19 Apr 2006) $"
revision: "$Revision: 58308 $"
class interface
MANAGED_POINTER
create
make (n: INTEGER_32)
item`n'
require
n_non_negative: n >= 0
ensure
item_set: item /= default_pointer
count_set: count = n
is_shared_set: not is_shared
make_from_array (data: ARRAY [NATURAL_8])
item`data.count'
`data'item
require
data_not_void: data /= Void
ensure
item_set: item /= default_pointer
count_set: count = data.count
is_shared_set: not is_shared
make_from_pointer (a_ptr: POINTER; n: INTEGER_32)
`a_count'`a_ptr'
require
a_ptr_not_null: a_ptr /= default_pointer
n_non_negative: n >= 0
ensure
item_set: item /= default_pointer
count_set: count = n
is_shared_set: not is_shared
share_from_pointer (a_ptr: POINTER; n: INTEGER_32)
`a_ptr'`n'
require
a_ptr_valid: a_ptr = default_pointer implies n = 0
n_non_negative: n >= 0
ensure
item_set: item = a_ptr
count_set: count = n
is_shared_set: is_shared
feature
count: INTEGER_32
generating_type: STRING_8
ANY
generator: STRING_8
ANY
is_shared: BOOLEAN
item
item: POINTER
feature
frozen deep_equal (some: ANY; other: like arg #1): BOOLEAN
`some'`other'
ANY
ensure ANY
shallow_implies_deep: standard_equal (some, other) implies Result
both_or_none_void: (some = Void) implies (Result = (other = Void))
same_type: (Result and (some /= Void)) implies some.same_type (other)
symmetric: Result implies deep_equal (other, some)
frozen equal (some: ANY; other: like arg #1): BOOLEAN
`some'`other'
ANY
ensure ANY
definition: Result = (some = Void and other = Void) or else ((some /= Void and other /= Void) and then some.is_equal (other))
is_equal (other: like Current): BOOLEAN
`other'
require ANY
other_not_void: other /= Void
ensure ANY
symmetric: Result implies other.is_equal (Current)
consistent: standard_is_equal (other) implies Result
frozen standard_equal (some: ANY; other: like arg #1): BOOLEAN
`some'`other'
ANY
ensure ANY
definition: Result = (some = Void and other = Void) or else ((some /= Void and other /= Void) and then some.standard_is_equal (other))
frozen standard_is_equal (other: like Current): BOOLEAN
`other'
ANY
require ANY
other_not_void: other /= Void
ensure ANY
same_type: Result implies same_type (other)
symmetric: Result implies other.standard_is_equal (Current)
feature
conforms_to (other: ANY): BOOLEAN
`other'
ANY
require ANY
other_not_void: other /= Void
same_type (other: ANY): BOOLEAN
`other'
ANY
require ANY
other_not_void: other /= Void
ensure ANY
definition: Result = (conforms_to (other) and other.conforms_to (Current))
feature
resize (n: INTEGER_32)
item`n'
`n'count
require
n_non_negative: n >= 0
not_shared: not is_shared
feature
copy (other: like Current)
`other'is_shared
`other'
is_shared`False'
require ANY
other_not_void: other /= Void
type_identity: same_type (other)
ensure ANY
is_equal: is_equal (other)
ensure then
sharing_status_not_preserved: (old is_shared and not is_shared) implies (other.count > old count)
frozen deep_copy (other: like Current)
copy`other'deep_twin
ANY
require ANY
other_not_void: other /= Void
ensure ANY
deep_equal: deep_equal (Current, other)
frozen deep_twin: like Current
ANY
ensure ANY
deep_equal: deep_equal (Current, Result)
frozen standard_copy (other: like Current)
`other'
ANY
require ANY
other_not_void: other /= Void
type_identity: same_type (other)
ensure ANY
is_standard_equal: standard_is_equal (other)
frozen standard_twin: like Current
`other'
ANY
ensure ANY
standard_twin_not_void: Result /= Void
equal: standard_equal (Result, Current)
frozen twin: like Current
`Current'
twincopycopy
ANY
ensure ANY
twin_not_void: Result /= Void
is_equal: Result.is_equal (Current)
feature
frozen default: like Current
ANY
frozen default_pointer: POINTER
`POINTER'
`p'default
`p'`POINTER'
ANY
default_rescue
ANY
frozen do_nothing
ANY
feature
boolean_bits: INTEGER_32
`BOOLEAN'
PLATFORM
character_bits: INTEGER_32
`CHARACTER'
PLATFORM
double_bits: INTEGER_32
`DOUBLE'
PLATFORMreal_64_bits
PLATFORM
integer_16_bits: INTEGER_32
PLATFORM
integer_32_bits: INTEGER_32
`INTEGER'
PLATFORMinteger_bits
PLATFORM
integer_64_bits: INTEGER_32
PLATFORM
integer_8_bits: INTEGER_32
PLATFORM
integer_bits: INTEGER_32
`INTEGER'
PLATFORMinteger_32_bits
PLATFORM
natural_16_bits: INTEGER_32
PLATFORM
natural_32_bits: INTEGER_32
`INTEGER'
PLATFORM
natural_64_bits: INTEGER_32
PLATFORM
natural_8_bits: INTEGER_32
PLATFORM
pointer_bits: INTEGER_32
`POINTER'
PLATFORM
real_32_bits: INTEGER_32
`REAL'
PLATFORMreal_bits
PLATFORM
real_64_bits: INTEGER_32
`DOUBLE'
PLATFORMdouble_bits
PLATFORM
real_bits: INTEGER_32
`REAL'
PLATFORMreal_32_bits
PLATFORM
feature
boolean_bytes: INTEGER_32
`BOOLEAN'
PLATFORM
character_bytes: INTEGER_32
`CHARACTER'
PLATFORM
double_bytes: INTEGER_32
`DOUBLE'
PLATFORMreal_64_bytes
PLATFORM
integer_16_bytes: INTEGER_32
`INTEGER_16'
PLATFORM
integer_32_bytes: INTEGER_32
`INTEGER'
PLATFORMinteger_bytes
PLATFORM
integer_64_bytes: INTEGER_32
`INTEGER_64'
PLATFORM
integer_8_bytes: INTEGER_32
`INTEGER_8'
PLATFORM
integer_bytes: INTEGER_32
`INTEGER'
PLATFORMinteger_32_bytes
PLATFORM
natural_16_bytes: INTEGER_32
`INTEGER_16'
PLATFORM
natural_32_bytes: INTEGER_32
`INTEGER'
PLATFORM
natural_64_bytes: INTEGER_32
`INTEGER_64'
PLATFORM
natural_8_bytes: INTEGER_32
`INTEGER_8'
PLATFORM
pointer_bytes: INTEGER_32
`POINTER'
PLATFORM
real_32_bytes: INTEGER_32
`REAL'
PLATFORMreal_bytes
PLATFORM
real_64_bytes: INTEGER_32
`DOUBLE'
PLATFORMdouble_bytes
PLATFORM
real_bytes: INTEGER_32
`REAL'
PLATFORMreal_32_bytes
PLATFORM
wide_character_bytes: INTEGER_32
`WIDE_CHARACTER'
PLATFORM
feature
maximum_character_code: INTEGER_32
PLATFORM
ensure PLATFORM
meaningful: Result >= 127
maximum_integer: INTEGER_32
PLATFORM
ensure PLATFORM
meaningful: Result >= 0
minimum_character_code: INTEGER_32
PLATFORM
ensure PLATFORM
meaningful: Result <= 0
minimum_integer: INTEGER_32
PLATFORM
ensure PLATFORM
meaningful: Result <= 0
feature
read_integer_16_be (pos: INTEGER_32): INTEGER_16
`pos'
require
pos_nonnegative: pos >= 0
valid_position: (pos + integer_16_bytes) <= count
read_integer_32_be (pos: INTEGER_32): INTEGER_32
`pos'
require
pos_nonnegative: pos >= 0
valid_position: (pos + integer_32_bytes) <= count
read_integer_64_be (pos: INTEGER_32): INTEGER_64
`pos'
require
pos_nonnegative: pos >= 0
valid_position: (pos + integer_64_bytes) <= count
read_integer_8_be (pos: INTEGER_32): INTEGER_8
`pos'
require
pos_nonnegative: pos >= 0
valid_position: (pos + integer_8_bytes) <= count
read_natural_16_be (pos: INTEGER_32): NATURAL_16
`pos'
require
pos_nonnegative: pos >= 0
valid_position: (pos + natural_16_bytes) <= count
read_natural_32_be (pos: INTEGER_32): NATURAL_32
`pos'
require
pos_nonnegative: pos >= 0
valid_position: (pos + natural_32_bytes) <= count
read_natural_64_be (pos: INTEGER_32): NATURAL_64
`pos'
require
pos_nonnegative: pos >= 0
valid_position: (pos + natural_64_bytes) <= count
read_natural_8_be (pos: INTEGER_32): NATURAL_8
`pos'
require
pos_nonnegative: pos >= 0
valid_position: (pos + natural_8_bytes) <= count
feature
read_integer_16_le (pos: INTEGER_32): INTEGER_16
`pos'
require
pos_nonnegative: pos >= 0
valid_position: (pos + integer_16_bytes) <= count
read_integer_32_le (pos: INTEGER_32): INTEGER_32
`pos'
require
pos_nonnegative: pos >= 0
valid_position: (pos + integer_32_bytes) <= count
read_integer_64_le (pos: INTEGER_32): INTEGER_64
`pos'
require
pos_nonnegative: pos >= 0
valid_position: (pos + integer_64_bytes) <= count
read_integer_8_le (pos: INTEGER_32): INTEGER_8
`pos'
require
pos_nonnegative: pos >= 0
valid_position: (pos + integer_8_bytes) <= count
read_natural_16_le (pos: INTEGER_32): NATURAL_16
`pos'
require
pos_nonnegative: pos >= 0
valid_position: (pos + natural_16_bytes) <= count
read_natural_32_le (pos: INTEGER_32): NATURAL_32
`pos'
require
pos_nonnegative: pos >= 0
valid_position: (pos + natural_32_bytes) <= count
read_natural_64_le (pos: INTEGER_32): NATURAL_64
`pos'
require
pos_nonnegative: pos >= 0
valid_position: (pos + natural_64_bytes) <= count
read_natural_8_le (pos: INTEGER_32): NATURAL_8
`pos'
require
pos_nonnegative: pos >= 0
valid_position: (pos + natural_8_bytes) <= count
feature
read_array (pos, a_count: INTEGER_32): ARRAY [NATURAL_8]
count`pos'
require
pos_nonnegative: pos >= 0
count_positive: a_count > 0
valid_position: (pos + a_count) <= count
ensure
read_array_not_void: Result /= Void
read_array_valid_count: Result.count = a_count
read_boolean (pos: INTEGER_32): BOOLEAN
`pos'
require
pos_nonnegative: pos >= 0
valid_position: (pos + boolean_bytes) <= count
read_character (pos: INTEGER_32): CHARACTER_8
`pos'
require
pos_nonnegative: pos >= 0
valid_position: (pos + character_bytes) <= count
read_integer_16 (pos: INTEGER_32): INTEGER_16
`pos'
require
pos_nonnegative: pos >= 0
valid_position: (pos + integer_16_bytes) <= count
read_integer_32 (pos: INTEGER_32): INTEGER_32
`pos'
require
pos_nonnegative: pos >= 0
valid_position: (pos + integer_32_bytes) <= count
read_integer_64 (pos: INTEGER_32): INTEGER_64
`pos'
require
pos_nonnegative: pos >= 0
valid_position: (pos + integer_64_bytes) <= count
read_integer_8 (pos: INTEGER_32): INTEGER_8
`pos'
require
pos_nonnegative: pos >= 0
valid_position: (pos + integer_8_bytes) <= count
read_natural_16 (pos: INTEGER_32): NATURAL_16
`pos'
require
pos_nonnegative: pos >= 0
valid_position: (pos + natural_16_bytes) <= count
read_natural_32 (pos: INTEGER_32): NATURAL_32
`pos'
require
pos_nonnegative: pos >= 0
valid_position: (pos + natural_32_bytes) <= count
read_natural_64 (pos: INTEGER_32): NATURAL_64
`pos'
require
pos_nonnegative: pos >= 0
valid_position: (pos + natural_64_bytes) <= count
read_natural_8 (pos: INTEGER_32): NATURAL_8
`pos'
require
pos_nonnegative: pos >= 0
valid_position: (pos + natural_8_bytes) <= count
read_pointer (pos: INTEGER_32): POINTER
`pos'
require
pos_nonnegative: pos >= 0
valid_position: (pos + pointer_bytes) <= count
read_real_32 (pos: INTEGER_32): REAL_32
`pos'
require
pos_nonnegative: pos >= 0
valid_position: (pos + real_bytes) <= count
read_real_64 (pos: INTEGER_32): REAL_64
`pos'
require
pos_nonnegative: pos >= 0
valid_position: (pos + double_bytes) <= count
feature
append (other: like Current)
`other'
require
not_shared: not is_shared
other_not_void: other /= Void
feature
put_integer_16_be (i: INTEGER_16; pos: INTEGER_32)
`i'`pos'
require
pos_nonnegative: pos >= 0
valid_position: (pos + integer_16_bytes) <= count
ensure
inserted: i = read_integer_16_be (pos)
put_integer_32_be (i: INTEGER_32; pos: INTEGER_32)
`i'`pos'
require
pos_nonnegative: pos >= 0
valid_position: (pos + integer_32_bytes) <= count
ensure
inserted: i = read_integer_32_be (pos)
put_integer_64_be (i: INTEGER_64; pos: INTEGER_32)
`i'`pos'
require
pos_nonnegative: pos >= 0
valid_position: (pos + integer_64_bytes) <= count
ensure
inserted: i = read_integer_64_be (pos)
put_integer_8_be (i: INTEGER_8; pos: INTEGER_32)
`i'`pos'
require
pos_nonnegative: pos >= 0
valid_position: (pos + integer_8_bytes) <= count
ensure
inserted: i = read_integer_8_be (pos)
put_natural_16_be (i: NATURAL_16; pos: INTEGER_32)
`i'`pos'
require
pos_nonnegative: pos >= 0
valid_position: (pos + natural_16_bytes) <= count
ensure
inserted: i = read_natural_16_be (pos)
put_natural_32_be (i: NATURAL_32; pos: INTEGER_32)
`i'`pos'
require
pos_nonnegative: pos >= 0
valid_position: (pos + natural_32_bytes) <= count
ensure
inserted: i = read_natural_32_be (pos)
put_natural_64_be (i: NATURAL_64; pos: INTEGER_32)
`i'`pos'
require
pos_nonnegative: pos >= 0
valid_position: (pos + natural_64_bytes) <= count
ensure
inserted: i = read_natural_64_be (pos)
put_natural_8_be (i: NATURAL_8; pos: INTEGER_32)
`i'`pos'
require
pos_nonnegative: pos >= 0
valid_position: (pos + natural_8_bytes) <= count
ensure
inserted: i = read_natural_8_be (pos)
feature
put_integer_16_le (i: INTEGER_16; pos: INTEGER_32)
`i'`pos'
require
pos_nonnegative: pos >= 0
valid_position: (pos + integer_16_bytes) <= count
ensure
inserted: i = read_integer_16_le (pos)
put_integer_32_le (i: INTEGER_32; pos: INTEGER_32)
`i'`pos'
require
pos_nonnegative: pos >= 0
valid_position: (pos + integer_32_bytes) <= count
ensure
inserted: i = read_integer_32_le (pos)
put_integer_64_le (i: INTEGER_64; pos: INTEGER_32)
`i'`pos'
require
pos_nonnegative: pos >= 0
valid_position: (pos + integer_64_bytes) <= count
ensure
inserted: i = read_integer_64_le (pos)
put_integer_8_le (i: INTEGER_8; pos: INTEGER_32)
`i'`pos'
require
pos_nonnegative: pos >= 0
valid_position: (pos + integer_8_bytes) <= count
ensure
inserted: i = read_integer_8_le (pos)
put_natural_16_le (i: NATURAL_16; pos: INTEGER_32)
`i'`pos'
require
pos_nonnegative: pos >= 0
valid_position: (pos + natural_16_bytes) <= count
ensure
inserted: i = read_natural_16_le (pos)
put_natural_32_le (i: NATURAL_32; pos: INTEGER_32)
`i'`pos'
require
pos_nonnegative: pos >= 0
valid_position: (pos + natural_32_bytes) <= count
ensure
inserted: i = read_natural_32_le (pos)
put_natural_64_le (i: NATURAL_64; pos: INTEGER_32)
`i'`pos'
require
pos_nonnegative: pos >= 0
valid_position: (pos + natural_64_bytes) <= count
ensure
inserted: i = read_natural_64_le (pos)
put_natural_8_le (i: NATURAL_8; pos: INTEGER_32)
`i'`pos'
require
pos_nonnegative: pos >= 0
valid_position: (pos + natural_8_bytes) <= count
ensure
inserted: i = read_natural_8_le (pos)
feature
put_array (data: ARRAY [NATURAL_8]; pos: INTEGER_32)
`data'item`pos'
require
data_not_void: data /= Void
pos_nonnegative: pos >= 0
valid_position: (pos + data.count) <= count
ensure
inserted: data.is_equal (read_array (pos, data.count))
put_boolean (b: BOOLEAN; pos: INTEGER_32)
`b'`pos'
require
pos_nonnegative: pos >= 0
valid_position: (pos + boolean_bytes) <= count
ensure
inserted: b = read_boolean (pos)
put_character (c: CHARACTER_8; pos: INTEGER_32)
`'`pos'
require
pos_nonnegative: pos >= 0
valid_position: (pos + character_bytes) <= count
ensure
inserted: c = read_character (pos)
put_integer_16 (i: INTEGER_16; pos: INTEGER_32)
`i'`pos'
require
pos_nonnegative: pos >= 0
valid_position: (pos + integer_16_bytes) <= count
ensure
inserted: i = read_integer_16 (pos)
put_integer_32 (i: INTEGER_32; pos: INTEGER_32)
`i'`pos'
require
pos_nonnegative: pos >= 0
valid_position: (pos + integer_32_bytes) <= count
ensure
inserted: i = read_integer_32 (pos)
put_integer_64 (i: INTEGER_64; pos: INTEGER_32)
`i'`pos'
require
pos_nonnegative: pos >= 0
valid_position: (pos + integer_64_bytes) <= count
ensure
inserted: i = read_integer_64 (pos)
put_integer_8 (i: INTEGER_8; pos: INTEGER_32)
`i'`pos'
require
pos_nonnegative: pos >= 0
valid_position: (pos + integer_8_bytes) <= count
ensure
inserted: i = read_integer_8 (pos)
put_natural_16 (i: NATURAL_16; pos: INTEGER_32)
`i'`pos'
require
pos_nonnegative: pos >= 0
valid_position: (pos + natural_16_bytes) <= count
ensure
inserted: i = read_natural_16 (pos)
put_natural_32 (i: NATURAL_32; pos: INTEGER_32)
`i'`pos'
require
pos_nonnegative: pos >= 0
valid_position: (pos + natural_32_bytes) <= count
ensure
inserted: i = read_natural_32 (pos)
put_natural_64 (i: NATURAL_64; pos: INTEGER_32)
`i'`pos'
require
pos_nonnegative: pos >= 0
valid_position: (pos + natural_64_bytes) <= count
ensure
inserted: i = read_natural_64 (pos)
put_natural_8 (i: NATURAL_8; pos: INTEGER_32)
`i'`pos'
require
pos_nonnegative: pos >= 0
valid_position: (pos + natural_8_bytes) <= count
ensure
inserted: i = read_natural_8 (pos)
put_pointer (p: POINTER; pos: INTEGER_32)
`p'`pos'
require
pos_nonnegative: pos >= 0
valid_position: (pos + pointer_bytes) <= count
ensure
inserted: p = read_pointer (pos)
put_real_32 (r: REAL_32; pos: INTEGER_32)
`r'`pos'
require
pos_nonnegative: pos >= 0
valid_position: (pos + real_bytes) <= count
ensure
inserted: r = read_real_32 (pos)
put_real_64 (d: REAL_64; pos: INTEGER_32)
`d'`pos'
require
pos_nonnegative: pos >= 0
valid_position: (pos + double_bytes) <= count
ensure
inserted: d = read_real_64 (pos)
feature
io: STD_FILES
ANY
out: STRING_8
ANYtagged_out
ANY
print (some: ANY)
`some'
ANY
frozen tagged_out: STRING_8
ANYout
ANY
feature
is_dotnet: BOOLEAN is False
PLATFORM
is_little_endian: BOOLEAN
PLATFORM
frozen is_thread_capable: BOOLEAN
PLATFORM
is_unix: BOOLEAN
PLATFORM
is_vms: BOOLEAN
PLATFORM
frozen is_windows: BOOLEAN
PLATFORM
operating_environment: OPERATING_ENVIRONMENT
ANY
feature
set_from_pointer (a_ptr: POINTER; n: INTEGER_32)
`a_ptr'`n'
require
is_shared: is_shared
a_ptr_not_null: a_ptr = default_pointer implies n = 0
n_non_negative: n >= 0
ensure
item_set: item = a_ptr
count_set: count = n
is_shared_unchanged: is_shared
invariant
item_not_null: item = default_pointer implies (count = 0 and is_shared)
valid_count: count >= 0
ANY
reflexive_equality: standard_is_equal (Current)
reflexive_conformance: conforms_to (Current)
indexing
library: "EiffelBase: Library of reusable components for Eiffel."
copyright: "Copyright (c) 1984-2006, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
source: "[
Eiffel Software
356 Storke Road, Goleta, CA 93117 USA
Telephone 805-685-1006, Fax 805-685-6869
Website http://www.eiffel.com
Customer support http://support.eiffel.com
]"
end MANAGED_POINTER