1 #ifndef STRING_ARRAY_CLASS
2 #define STRING_ARRAY_CLASS
47 for (
int i = 0; i < number; i++) {
62 for (
int i = 0; i <
length(); i++) {
63 to_return += delimiter;
65 to_return += delimiter;
67 to_return += separator;
78 bool equal_to(
const equalizable &to_compare)
const {
82 for (
int i = 0; i <
length(); i++)
83 if (cast->
get(i) !=
get(i))
90 for (
int i = 0; i <
length(); i++) {
93 return basis::common::NOT_FOUND;
100 if (second.length() <
length())
return false;
101 if (!
length())
return false;
102 for (
int i = 0; i <
length(); i++)
103 if ((*
this)[i] != second[i])
return false;
117 int to_return =
sizeof(int) * 2;
118 for (
int i = 0; i <
length(); i++)
Represents a sequential, ordered, contiguous collection of objects.
@ EXPONE
synonym for EXPONENTIAL_GROWTH.
@ FLUSH_INVISIBLE
blanks out allocated but inaccessible elements.
outcome put(int index, const basis::astring &to_put)
Stores an object at the index "index" in the array.
const basis::astring & get(int index) const
Accesses individual objects stored in "this" at the "index" position.
int length() const
Returns the current reported length of the allocated C array.
array(int number=0, const basis::astring *init=NULL_POINTER, int flags=EXPONENTIAL_GROWTH|FLUSH_INVISIBLE)
Constructs an array with room for "number" objects.
int last() const
Returns the last valid element in the array.
Provides a dynamically resizable ASCII character string.
bool equal_to(const char *that) const
returns true if "that" is equal to this.
int length() const
Returns the current length of the string.
A very common template for a dynamic array of bytes.
Base class for object that can tell itself apart from other instances.
A base class for objects that can pack into an array of bytes.
An array of strings with some additional helpful methods.
DEFINE_CLASS_NAME("string_array")
virtual void pack(basis::byte_array &packed_form) const
Packs this string array into the "packed_form" byte array.
bool equal_to(const equalizable &to_compare) const
Compares this string array for equality with "to_compare".
virtual bool unpack(basis::byte_array &packed_form)
Unpacks a string array from the "packed_form" byte array.
int find(const basis::astring &to_find) const
locates string specified and returns its index, or negative if missing.
bool prefix_compare(const string_array &second) const
Returns true if all of the elements in this are the same in "second".
basis::astring text_format(const basis::astring &separator=",", const basis::astring &delimiter="\"") const
Prints out a formatted view of the contained strings and returns it.
virtual int packed_size() const
Returns the number of bytes this string array would consume if packed.
basis::astring text_form() const
A synonym for the text_format() method.
string_array(int number=0, const basis::astring *initial_contents=NULL_POINTER)
Constructs an array of "number" strings.
#define NULL_POINTER
The value representing a pointer to nothing.
The guards collection helps in testing preconditions and reporting errors.
target_type * cast_or_throw(source_type &to_cast, const target_type &ignored)
dynamically converts a type to a target type, or throws an exception if it cannot.
A dynamic container class that holds any kind of object via pointers.
bool unpack_array(basis::byte_array &packed_form, basis::array< contents > &to_unpack)
provides a way to unpack any array that stores packable objects.
void pack_array(basis::byte_array &packed_form, const basis::array< contents > &to_pack)
provides a way to pack any array that stores packable objects.