w32tex
About: TeX Live provides a comprehensive TeX system including all the major TeX-related programs, macro packages, and fonts that are free software. Windows sources.
  Fossies Dox: w32tex-src.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

String Class Reference

A string of characters. More...

#include <string.hh>

Collaboration diagram for String:
[legend]

Public Types

typedef const char * const_iterator
 
typedef const_iterator iterator
 
typedef int(String::* unspecified_bool_type) () const
 

Public Member Functions

 String ()
 Construct an empty String (with length 0). More...
 
 String (const String &x)
 Construct a copy of the String x. More...
 
 String (const char *cstr)
 Construct a String containing the C string cstr. More...
 
 String (const char *s, int len)
 Construct a String containing the first len characters of string s. More...
 
 String (const unsigned char *s, int len)
 
 String (const char *begin, const char *end)
 Construct a String containing the characters from begin to end. More...
 
 String (const unsigned char *begin, const unsigned char *end)
 
 String (bool x)
 Construct a String equal to "true" or "false" depending on the value of x. More...
 
 String (char c)
 Construct a String containing the single character c. More...
 
 String (unsigned char c)
 
 String (int x)
 Construct a base-10 string representation of x. More...
 
 String (unsigned x)
 
 String (long x)
 
 String (unsigned long x)
 
 String (double x)
 
 ~String ()
 Destroy a String, freeing memory if necessary. More...
 
int length () const
 Return the string's length. More...
 
const char * data () const
 Return a pointer to the string's data. More...
 
const unsigned char * udata () const
 Return a pointer to the string's data as unsigned chars. More...
 
const_iterator begin () const
 Return an iterator for the first character in the string. More...
 
const_iterator end () const
 Return an iterator for the end of the string. More...
 
const unsigned char * ubegin () const
 
const unsigned char * uend () const
 
 operator unspecified_bool_type () const
 Return true iff the string is nonempty. More...
 
bool empty () const
 Return true iff the string is empty. More...
 
bool operator! () const
 Return true iff the string is empty. More...
 
char operator[] (int i) const
 Return the i th character in the string. More...
 
char at (int i) const
 Return the i th character in the string. More...
 
char front () const
 Return the first character in the string. More...
 
char back () const
 Return the last character in the string. More...
 
const char * c_str () const
 Null-terminate the string. More...
 
hashcode_t hashcode () const
 Returns a 32-bit hash function of this string's characters. More...
 
bool equals (const char *s, int len) const
 Return true iff this string is equal to the data in s. More...
 
int compare (const String &x) const
 Compare this string with string x. More...
 
int compare (const char *s, int len) const
 Compare this string with the data in s. More...
 
String substring (const char *begin, const char *end) const
 Return a substring of the current string starting at begin and ending before end. More...
 
String substring (const unsigned char *first, const unsigned char *last) const
 
String substring (int pos, int len) const
 Return a substring of this string, consisting of the len characters starting at index pos. More...
 
String substring (int pos) const
 Return the suffix of the current string starting at index pos. More...
 
int find_left (char c, int start=0) const
 Search for a character in a string. More...
 
int find_left (const String &x, int start=0) const
 Search for a substring in a string. More...
 
int find_right (char c, int start=0x7FFFFFFF) const
 Search for a character in a string. More...
 
bool starts_with (const String &x) const
 Return true iff this string begins with prefix x. More...
 
bool starts_with (const char *s, int len) const
 Return true iff this string begins with the data in s. More...
 
String lower () const
 Return a lowercased version of this string. More...
 
String upper () const
 Return an uppercased version of this string. More...
 
String printable (int type=0) const
 Return a "printable" version of this string. More...
 
Stringoperator= (const String &x)
 Assign this string to x. More...
 
Stringoperator= (const char *cstr)
 Assign this string to the C string cstr. More...
 
void append (const char *cstr)
 Append the null-terminated C string cstr to this string. More...
 
void append (const char *s, int len)
 Append the first len characters of s to this string. More...
 
void append (const char *begin, const char *end)
 Appends the data from begin to end to the end of this string. More...
 
void append_fill (int c, int len)
 Append len copies of character c to this string. More...
 
char * append_uninitialized (int len)
 Append len unknown characters to this string. More...
 
Stringoperator+= (const String &x)
 Append a copy of x to the end of this string. More...
 
Stringoperator+= (const char *cstr)
 Append a copy of the C string cstr to the end of this string. More...
 
Stringoperator+= (char c)
 Append the character c to the end of this string. More...
 
bool data_shared () const
 Return true iff the String's data is shared or immutable. More...
 
String compact () const
 Return a compact version of this String. More...
 
char * mutable_data ()
 Ensure the string's data is unshared and return a mutable pointer to it. More...
 
char * mutable_c_str ()
 Null-terminate the string and return a mutable pointer to its data. More...
 
unsigned char * mutable_udata ()
 
void align (int)
 
bool out_of_memory () const
 Return true iff this is an out-of-memory string. More...
 

Static Public Member Functions

static const Stringmake_empty ()
 Return a const reference to an empty String. More...
 
static String make_uninitialized (int len)
 Return a String containing len unknown characters. More...
 
static String make_stable (const char *s, int len=-1)
 Return a String that directly references the first len characters of s. More...
 
static String make_stable (const char *begin, const char *end)
 Return a String that directly references the character data in [begin, end). More...
 
static String make_fill (int c, int n)
 
static hashcode_t hashcode (const char *begin, const char *end)
 Return a 32-bit hash function of the characters in [begin, end). More...
 
static hashcode_t hashcode (const unsigned char *begin, const unsigned char *end)
 
static int compare (const String &a, const String &b)
 Compare two strings. More...
 
static const Stringmake_out_of_memory ()
 Return a const reference to an out-of-memory String. More...
 
static const char * out_of_memory_data ()
 Return the data pointer used for out-of-memory strings. More...
 

Public Attributes

unsigned char * name
 
int num
 
struct StringNextStr
 

Private Member Functions

void assign_memo (const char *data, int length, memo_t *memo) const
 
 String (const char *data, int length, memo_t *memo)
 
void assign (const String &x) const
 
void deref () const
 
void assign (const char *cstr, int len, bool need_deref)
 
void assign_out_of_memory ()
 
void append (const char *s, int len, memo_t *memo)
 

Static Private Member Functions

static memo_t * create_memo (char *space, int dirty, int capacity)
 
static void delete_memo (memo_t *memo)
 
static String make_claim (char *, int, int)
 

Private Attributes

rep_t _r
 

Static Private Attributes

static const char null_data = '\0'
 
static const char oom_data = '\0'
 
static const char bool_data [11] = "true\0false"
 
static const char int_data [20] = "0\0001\0002\0003\0004\0005\0006\0007\0008\0009"
 
static const rep_t null_string_rep
 
static const rep_t oom_string_rep
 

Friends

struct rep_t
 
class StringAccum
 

Related Functions

(Note that these are not member functions.)

bool operator== (const String &a, const String &b)
 Compares two strings for equality. More...
 
bool operator== (const char *a, const String &b)
 
bool operator== (const String &a, const char *b)
 
bool operator!= (const String &a, const String &b)
 Compare two Strings for inequality. More...
 
bool operator!= (const char *a, const String &b)
 
bool operator!= (const String &a, const char *b)
 
bool operator< (const String &a, const String &b)
 Compare two Strings. More...
 
bool operator<= (const String &a, const String &b)
 Compare two Strings. More...
 
bool operator> (const String &a, const String &b)
 Compare two Strings. More...
 
bool operator>= (const String &a, const String &b)
 Compare two Strings. More...
 
String operator+ (String a, const String &b)
 Concatenate the operands and return the result. More...
 
String operator+ (String a, const char *b)
 
String operator+ (const char *a, const String &b)
 
String operator+ (String a, char b)
 Concatenate the operands and return the result. More...
 

Detailed Description

A string of characters.

The String class represents a string of characters. Strings may be constructed from C strings, characters, numbers, and so forth. They may also be added together. The underlying character arrays are dynamically allocated; String operations allocate and free memory as needed. A String and its substrings generally share memory. Accessing a character by index takes O(1) time; so does creating a substring.

Out-of-memory strings

When there is not enough memory to create a particular string, a special "out-of-memory" string is returned instead. Out-of-memory strings are contagious: the result of any concatenation operation involving an out-of-memory string is another out-of-memory string. Thus, the final result of a series of String operations will be an out-of-memory string, even if the out-of-memory condition occurs in the middle.

Out-of-memory strings have zero characters, but they aren't equal to other empty strings. If s is a normal String (even an empty string), and oom is an out-of-memory string, then s < oom.

All out-of-memory strings are equal and share the same data(), which is different from the data() of any other string. See String::out_of_memory_data(). The String::make_out_of_memory() function returns an out-of-memory string.

Definition at line 48 of file t1part.c.

Member Typedef Documentation

◆ const_iterator

typedef const char* String::const_iterator

Definition at line 174 of file string.hh.

◆ iterator

typedef const_iterator String::iterator

Definition at line 175 of file string.hh.

◆ unspecified_bool_type

typedef int(String::* String::unspecified_bool_type) () const

Definition at line 202 of file string.hh.

Constructor & Destructor Documentation

◆ String() [1/16]

String::String ( )
inline

Construct an empty String (with length 0).

Definition at line 14 of file string.hh.

References assign_memo(), and null_data.

Referenced by compact(), make_claim(), make_stable(), and substring().

◆ String() [2/16]

String::String ( const String x)
inline

Construct a copy of the String x.

Definition at line 19 of file string.hh.

References assign(), and cordic::x.

◆ String() [3/16]

String::String ( const char *  cstr)
inline

Construct a String containing the C string cstr.

Parameters
cstra null-terminated C string
Returns
A String containing the characters of cstr, up to but not including the terminating null character.

If cstr equals String::out_of_memory_data(), returns an out-of-memory string.

Definition at line 30 of file string.hh.

References assign().

◆ String() [4/16]

String::String ( const char *  s,
int  len 
)
inline

Construct a String containing the first len characters of string s.

Parameters
sa string
lennumber of characters to take from s. If len < 0, then takes strlen(s) characters.
Returns
A String containing len characters of s.

If s equals String::out_of_memory_data(), returns an out-of-memory string.

Definition at line 43 of file string.hh.

References assign(), len, and s.

◆ String() [5/16]

String::String ( const unsigned char *  s,
int  len 
)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 47 of file string.hh.

References assign(), len, and s.

◆ String() [6/16]

String::String ( const char *  begin,
const char *  end 
)
inline

Construct a String containing the characters from begin to end.

Parameters
beginfirst character in string (begin iterator)
endpointer one past last character in string (end iterator)
Returns
A String containing the characters from begin to end.

Returns a null string if begin >= end. If begin equals String::out_of_memory_data(), returns an out-of-memory string.

Definition at line 59 of file string.hh.

References assign(), begin(), and end().

◆ String() [7/16]

String::String ( const unsigned char *  begin,
const unsigned char *  end 
)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 63 of file string.hh.

References assign(), begin(), and end().

◆ String() [8/16]

String::String ( bool  x)
inlineexplicit

Construct a String equal to "true" or "false" depending on the value of x.

Definition at line 70 of file string.hh.

References assign_memo(), bool_data, and cordic::x.

◆ String() [9/16]

String::String ( char  c)
inlineexplicit

Construct a String containing the single character c.

Definition at line 75 of file string.hh.

References assign(), and c.

◆ String() [10/16]

String::String ( unsigned char  c)
inlineexplicit

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 80 of file string.hh.

References assign(), and c.

◆ String() [11/16]

String::String ( int  x)
explicit

Construct a base-10 string representation of x.

never

Definition at line 200 of file string.cc.

References assign(), assign_memo(), buf, int_data, sprintf, and cordic::x.

◆ String() [12/16]

String::String ( unsigned  x)
explicit

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 212 of file string.cc.

References assign(), assign_memo(), buf, int_data, sprintf, and cordic::x.

◆ String() [13/16]

String::String ( long  x)
explicit

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 224 of file string.cc.

References assign(), assign_memo(), buf, int_data, sprintf, and cordic::x.

◆ String() [14/16]

String::String ( unsigned long  x)
explicit

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 236 of file string.cc.

References assign(), assign_memo(), buf, int_data, sprintf, and cordic::x.

◆ String() [15/16]

String::String ( double  x)
explicit

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 247 of file string.cc.

References assign(), buf, len, sprintf, and cordic::x.

◆ ~String()

String::~String ( )
inline

Destroy a String, freeing memory if necessary.

Definition at line 101 of file string.hh.

References deref().

◆ String() [16/16]

String::String ( const char *  data,
int  length,
memo_t *  memo 
)
inlineprivate

Definition at line 692 of file string.hh.

References assign_memo(), data(), and length().

Member Function Documentation

◆ align()

◆ append() [1/4]

void String::append ( const char *  begin,
const char *  end 
)
inline

Appends the data from begin to end to the end of this string.

Does nothing if begin >= end.

Definition at line 505 of file string.hh.

References append(), begin(), and end().

◆ append() [2/4]

void String::append ( const char *  cstr)
inline

Append the null-terminated C string cstr to this string.

Parameters
cstrdata to append

Definition at line 489 of file string.hh.

Referenced by append(), and operator+=().

◆ append() [3/4]

void String::append ( const char *  s,
int  len 
)
inline

Append the first len characters of s to this string.

Parameters
sdata to append
lenlength of data
Precondition
len >= 0

Definition at line 497 of file string.hh.

References append(), len, and s.

◆ append() [4/4]

void String::append ( const char *  s,
int  len,
memo_t *  memo 
)
private

◆ append_fill()

void String::append_fill ( int  c,
int  len 
)

Append len copies of character c to this string.

Definition at line 420 of file string.cc.

References append_uninitialized(), assert(), c, len, memset(), and space.

◆ append_uninitialized()

char * String::append_uninitialized ( int  len)

Append len unknown characters to this string.

Returns
Modifiable pointer to the appended characters.

The caller may safely modify the returned memory. Null is returned if the string becomes out-of-memory.

Definition at line 335 of file string.cc.

References _r, assert(), assign_out_of_memory(), create_memo(), deref(), dirty, len, memcpy, out_of_memory(), and unlikely.

Referenced by append(), append_fill(), and c_str().

◆ assign() [1/2]

void String::assign ( const char *  cstr,
int  len,
bool  need_deref 
)
private

◆ assign() [2/2]

void String::assign ( const String x) const
inlineprivate

Definition at line 696 of file string.hh.

References assign_memo(), and cordic::x.

Referenced by drvPPTX::get_font_props(), mutable_data(), operator=(), and String().

◆ assign_memo()

void String::assign_memo ( const char *  data,
int  length,
memo_t *  memo 
) const
inlineprivate

Definition at line 685 of file string.hh.

References _r, data(), and length().

Referenced by append(), assign(), and String().

◆ assign_out_of_memory()

void String::assign_out_of_memory ( )
private

Definition at line 279 of file string.cc.

References _r, deref(), and oom_data.

Referenced by append(), append_uninitialized(), and assign().

◆ at()

char String::at ( int  i) const
inline

Return the i th character in the string.

Checks bounds: an assertion will fail if i is less than 0 or not less than length().

See also
String::operator[]

Definition at line 230 of file string.hh.

References _r, assert(), and i.

◆ back()

char String::back ( ) const
inline

Return the last character in the string.

Does not check bounds. Same as (*this)[length() - 1].

Definition at line 245 of file string.hh.

References _r.

Referenced by ContextErrorHandler::decorate(), Filename::Filename(), and Efont::Type1Definition::value_string().

◆ begin()

const_iterator String::begin ( ) const
inline

Return an iterator for the first character in the string.

String iterators are simply pointers into string data, so they are quite efficient.

See also
String::data

Definition at line 181 of file string.hh.

References _r.

Referenced by append(), DvipsEncoding::glyphname_unicode(), hashcode(), make_stable(), DvipsEncoding::parse(), String(), substring(), suffix_font_name(), and Efont::OpenType::Name::version_chaincontext_reverse_backtrack().

◆ c_str()

const char* String::c_str ( ) const
inline

Null-terminate the string.

The terminating null character isn't considered part of the string, so this->length() doesn't change. Returns a corresponding C string pointer. The returned pointer is semi-temporary; it will persist until the string is destroyed or appended to.

Definition at line 256 of file string.hh.

References _r, append_uninitialized(), and cordic::x.

Referenced by adjust_font_definitions(), Efont::MultipleMasterSpace::convert_vector(), do_query_postscript_name(), T1Secondary::dotlessj_font(), getodir(), installed_truetype(), installed_type1_dotlessj(), main(), mutable_c_str(), Efont::MultipleMasterSpace::normalize_vector(), Filename::open_read(), Filename::open_write(), output_pl(), output_tfm(), parse_base_encodings(), Filename::readable(), Efont::Type1Definition::Type1Definition(), update_autofont_map(), and update_odir().

◆ compact()

String String::compact ( ) const
inline

Return a compact version of this String.

The compact version shares no more than 256 bytes of data with any other non-stable String.

Definition at line 573 of file string.hh.

References _r, and String().

◆ compare() [1/3]

int String::compare ( const char *  s,
int  len 
) const

Compare this string with the data in s.

Parameters
sstring data to compare to
lenlength of s

Same as String::compare(*this, String(s, len)). If len < 0, then treats s as a null-terminated C string.

See also
String::compare(const String &a, const String &b)

Definition at line 752 of file string.cc.

References _r, len, memcmp, oom_data, s, strlen(), and v.

◆ compare() [2/3]

static int String::compare ( const String a,
const String b 
)
inlinestatic

Compare two strings.

Parameters
afirst string to compare
bsecond string to compare

Returns 0 if a == b, negative if a < b in lexicographic order, and positive if a > b in lexicographic order. The lexicographic order treats all characters as unsigned.

Definition at line 333 of file string.hh.

References a, and b.

Referenced by GlyphFilter::Pattern::compare(), and compare().

◆ compare() [3/3]

int String::compare ( const String x) const
inline

Compare this string with string x.

Same as String::compare(*this, x).

See also
String::compare(const String &a, const String &b)

Definition at line 341 of file string.hh.

References compare(), and cordic::x.

◆ create_memo()

static memo_t* String::create_memo ( char *  space,
int  dirty,
int  capacity 
)
staticprivate

◆ data()

◆ data_shared()

bool String::data_shared ( ) const
inline

Return true iff the String's data is shared or immutable.

Definition at line 565 of file string.hh.

References _r.

◆ delete_memo()

static void String::delete_memo ( memo_t *  memo)
staticprivate

Referenced by deref().

◆ deref()

void String::deref ( ) const
inlineprivate

Definition at line 700 of file string.hh.

References _r, and delete_memo().

Referenced by append(), append_uninitialized(), assign(), assign_out_of_memory(), mutable_data(), operator=(), and ~String().

◆ empty()

bool String::empty ( void  ) const
inline

Return true iff the string is empty.

Definition at line 209 of file string.hh.

References _r.

Referenced by operator!(), and output_tfm().

◆ end()

const_iterator String::end ( ) const
inline

Return an iterator for the end of the string.

The return value points one character beyond the last character in the string.

Definition at line 189 of file string.hh.

References _r.

Referenced by append(), DvipsEncoding::glyphname_unicode(), hashcode(), make_stable(), DvipsEncoding::parse(), String(), substring(), suffix_font_name(), and Efont::OpenType::Name::version_chaincontext_reverse_backtrack().

◆ equals()

bool String::equals ( const char *  s,
int  len 
) const

Return true iff this string is equal to the data in s.

Parameters
sstring data to compare to
lenlength of s

Same as String::compare(*this, String(s, len)) == 0. If len < 0, then treats s as a null-terminated C string.

See also
String::compare(const String &a, const String &b)

Definition at line 717 of file string.cc.

References _r, len, memcmp, oom_data, s, and strlen().

Referenced by ContextErrorHandler::decorate().

◆ find_left() [1/2]

int String::find_left ( char  c,
int  start = 0 
) const

Search for a character in a string.

Parameters
ccharacter to search for
startinitial search position

Return the index of the leftmost occurence of c, starting at index start and working up to the end of the string. Returns -1 if c is not found.

Definition at line 495 of file string.cc.

References _r, c, i, and start.

Referenced by Efont::Type1SubrGroupItem::gen(), installed_truetype(), installed_type1(), installed_type1_dotlessj(), installed_type42(), main(), update_odir(), and write_encoding_file().

◆ find_left() [2/2]

int String::find_left ( const String x,
int  start = 0 
) const

Search for a substring in a string.

Parameters
xsubstring to search for
startinitial search position

Return the index of the leftmost occurence of the substring str, starting at index start and working up to the end of the string. Returns -1 if str is not found.

Definition at line 506 of file string.cc.

References _r, i, length(), memcmp, start, and str.

◆ find_right()

int String::find_right ( char  c,
int  start = 0x7FFFFFFF 
) const

Search for a character in a string.

Parameters
ccharacter to search for
startinitial search position

Return the index of the rightmost occurence of the character c, starting at index start and working back to the beginning of the string. Returns -1 if c is not found. start may start beyond the end of the string.

Definition at line 518 of file string.cc.

References _r, c, i, and start.

Referenced by do_file(), Filename::extension(), and Filename::Filename().

◆ front()

char String::front ( ) const
inline

Return the first character in the string.

Does not check bounds. Same as (*this)[0].

Definition at line 238 of file string.hh.

References _r.

◆ hashcode() [1/3]

hashcode_t String::hashcode ( ) const
inline

Returns a 32-bit hash function of this string's characters.

Equivalent to String::hashcode(begin(), end()). Uses Paul Hsieh's "SuperFastHash."

Invariant
If s1 == s2, then s1.hashcode() == s2.hashcode().

Definition at line 303 of file string.hh.

References begin(), end(), and length().

Referenced by hashcode().

◆ hashcode() [2/3]

hashcode_t String::hashcode ( const char *  begin,
const char *  end 
)
static

Return a 32-bit hash function of the characters in [begin, end).

Uses Paul Hsieh's "SuperFastHash" algorithm, described at http://www.azillionmonkeys.com/qed/hash.html This hash function uses all characters in the string.

Invariant
If end1 - begin1 == end2 - begin2 and memcmp(begin1, begin2, end1 - begin1) == 0, then hashcode(begin1, end1) == hashcode(begin2, end2).

Definition at line 617 of file string.cc.

References begin(), end(), get16, and hash.

◆ hashcode() [3/3]

static hashcode_t String::hashcode ( const unsigned char *  begin,
const unsigned char *  end 
)
inlinestatic

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 291 of file string.hh.

References begin(), end(), and hashcode().

◆ length()

int String::length ( ) const
inline

Return the string's length.

Definition at line 153 of file string.hh.

References _r.

Referenced by assign_memo(), Efont::Type1Charstring::assign_substring(), Filename::base(), Efont::OpenType::Coverage::check(), Efont::OpenType::ClassDef::check(), Efont::OpenType::Font::check_checksums(), Efont::OpenType::ScriptList::check_header(), Efont::OpenType::FeatureList::check_header(), Efont::OpenType::ScriptList::check_script(), Efont::OpenType::ClassDef::class_iterator::class_iterator(), Efont::OpenType::Coverage::iterator::coverage_index(), Efont::Type1Charstring::decrypt(), do_file(), Efont::OpenType::ClassDef::end(), Efont::OpenType::ScriptList::features(), Efont::OpenType::FeatureList::filter(), Efont::OpenType::FeatureList::find(), find_left(), Efont::OpenType::Coverage::iterator::forward_to(), drvPPTX::get_font_props(), getodir(), DvipsEncoding::glyphname_unicode(), Efont::OpenType::Coverage::has_fast_covers(), hashcode(), Efont::OpenType::ClassDef::class_iterator::increment_class0(), Efont::OpenType::Coverage::iterator::iterator(), Efont::OpenType::Font::length(), Efont::OpenType::Data::length(), Efont::Type1Charstring::length(), Efont::Type2Charstring::length(), Efont::Type1CopyItem::length(), Efont::OpenType::ClassDef::lookup(), Efont::OpenType::FeatureList::lookups(), main(), Efont::OpenType::Name::name(), Efont::OpenType::Data::offset_subtable(), Efont::OpenType::ScriptList::ok(), Efont::OpenType::FeatureList::ok(), Efont::OpenType::Coverage::iterator::ok(), Efont::OpenType::ClassDef::ok(), Efont::OpenType::ClassDef::class_iterator::ok(), Efont::OpenType::Coverage::ok(), Efont::CharstringContext::operator String::unspecified_bool_type(), operator unspecified_bool_type(), Efont::OpenType::Coverage::iterator::operator++(), Efont::OpenType::ClassDef::class_iterator::operator++(), Efont::OpenType::Data::operator[](), Efont::OpenType::FeatureList::params(), DvipsEncoding::parse(), Efont::OpenType::Cmap::parse_header(), Efont::OpenType::Name::parse_header(), Efont::Type1Charstring::process(), Efont::Type2Charstring::process(), Efont::OpenType::Data::s16(), Efont::OpenType::Data::s32(), Efont::OpenType::ScriptList::script_offset(), Efont::OpenType::Coverage::size(), String(), Efont::OpenType::Data::subtable(), Efont::OpenType::FeatureList::tag(), Efont::OpenType::Data::u16(), Efont::OpenType::Data::u32(), MakeType1CharstringInterp::Subr::unify(), Efont::OpenType::ClassDef::unparse(), update_odir(), Efont::OpenType::Name::utf8_name(), Efont::Type1Definition::value_name(), Efont::Type1Definition::value_string(), and write_encoding_file().

◆ lower()

String String::lower ( ) const

Return a lowercased version of this string.

Translates the ASCII characters 'A' through 'Z' into their lowercase equivalents.

Definition at line 544 of file string.cc.

References _r, hard_lower(), i, and out_of_memory().

◆ make_claim()

String String::make_claim ( char *  str,
int  len,
int  capacity 
)
staticprivate

Definition at line 255 of file string.cc.

References assert(), capacity, create_memo(), len, str, and String().

Referenced by StringAccum::take_string().

◆ make_empty()

static const String& String::make_empty ( )
inlinestatic

Return a const reference to an empty String.

May be quicker than String::String().

Definition at line 109 of file string.hh.

References null_string_rep.

Referenced by Efont::PsresDatabase::unescaped_value(), and Efont::PsresDatabase::value().

◆ make_fill()

String String::make_fill ( int  c,
int  n 
)
static

Definition at line 271 of file string.cc.

References c, len, and s.

Referenced by Efont::Type1CharstringGenInterp::act_hintmask(), and Efont::Type1Font::read().

◆ make_out_of_memory()

static const String& String::make_out_of_memory ( )
inlinestatic

Return a const reference to an out-of-memory String.

Definition at line 603 of file string.hh.

References oom_string_rep.

Referenced by StringAccum::take_string().

◆ make_stable() [1/2]

static String String::make_stable ( const char *  begin,
const char *  end 
)
inlinestatic

Return a String that directly references the character data in [begin, end).

Parameters
beginpointer to the first character in the character data
endpointer one beyond the last character in the character data (but see the warning)

This function is suitable for static constant strings whose data is known to stay around forever, such as C string constants. Returns an empty string if begin >= end.

Warning
The String implementation may access *end, which should remain constant even though it's not part of the String.

Definition at line 143 of file string.hh.

References begin(), end(), make_stable(), and String().

◆ make_stable() [2/2]

String String::make_stable ( const char *  s,
int  len = -1 
)
static

Return a String that directly references the first len characters of s.

This function is suitable for static constant strings whose data is known to stay around forever, such as C string constants. If len < 0, treats s as a null-terminated C string.

Warning
The String implementation may access s[len], which should remain constant even though it's not part of the String.

Definition at line 263 of file string.cc.

References len, s, String(), and strlen().

Referenced by ContextErrorHandler::ContextErrorHandler(), ErrorHandler::debug(), Efont::default_dict(), ErrorHandler::error(), ErrorHandler::fatal(), Efont::Type1Font::fill_in_subrs(), landmark(), ErrorHandler::ldebug(), ErrorHandler::lerror(), ErrorHandler::lfatal(), ErrorHandler::lmessage(), ErrorHandler::lwarning(), main(), make_stable(), ErrorHandler::message(), printable_filename(), shell_quote(), Efont::Type1Font::skeleton_common_subrs(), ErrorHandler::vxformat(), and ErrorHandler::warning().

◆ make_uninitialized()

static String String::make_uninitialized ( int  len)
inlinestatic

Return a String containing len unknown characters.

Definition at line 114 of file string.hh.

References len, and s.

Referenced by Efont::OpenType::Coverage::Coverage(), and Efont::AfmParser::vis().

◆ mutable_c_str()

char * String::mutable_c_str ( )

Null-terminate the string and return a mutable pointer to its data.

See also
String::c_str

Definition at line 448 of file string.cc.

References _r, c_str(), mutable_data(), and void.

◆ mutable_data()

char * String::mutable_data ( )

Ensure the string's data is unshared and return a mutable pointer to it.

Definition at line 430 of file string.cc.

References _r, assert(), assign(), and deref().

Referenced by Efont::Type1Charstring::assign_substring(), Efont::Type1Charstring::decrypt(), mutable_c_str(), and mutable_udata().

◆ mutable_udata()

unsigned char* String::mutable_udata ( )
inline

Definition at line 590 of file string.hh.

References mutable_data().

◆ operator unspecified_bool_type()

String::operator unspecified_bool_type ( ) const
inline

Return true iff the string is nonempty.

Definition at line 204 of file string.hh.

References _r, and length().

◆ operator!()

bool String::operator! ( ) const
inline

Return true iff the string is empty.

Definition at line 214 of file string.hh.

References empty().

◆ operator+=() [1/3]

String& String::operator+= ( char  c)
inline

Append the character c to the end of this string.

Returns the result.

Definition at line 540 of file string.hh.

References append(), and c.

◆ operator+=() [2/3]

String& String::operator+= ( const char *  cstr)
inline

Append a copy of the C string cstr to the end of this string.

Returns the result.

Definition at line 532 of file string.hh.

References append().

◆ operator+=() [3/3]

String& String::operator+= ( const String x)
inline

Append a copy of x to the end of this string.

Returns the result.

Definition at line 524 of file string.hh.

References append(), and cordic::x.

◆ operator=() [1/2]

String& String::operator= ( const char *  cstr)
inline

Assign this string to the C string cstr.

Definition at line 474 of file string.hh.

References assign().

◆ operator=() [2/2]

String& String::operator= ( const String x)
inline

Assign this string to x.

Definition at line 465 of file string.hh.

References assign(), deref(), and cordic::x.

◆ operator[]()

char String::operator[] ( int  i) const
inline

Return the i th character in the string.

Does not check bounds.

See also
String::at

Definition at line 222 of file string.hh.

References _r, and i.

◆ out_of_memory()

bool String::out_of_memory ( ) const
inline

Return true iff this is an out-of-memory string.

Definition at line 598 of file string.hh.

References _r, and oom_data.

Referenced by append(), append_uninitialized(), lower(), and printable().

◆ out_of_memory_data()

static const char* String::out_of_memory_data ( )
inlinestatic

Return the data pointer used for out-of-memory strings.

The returned value may be dereferenced; it points to a null character.

Definition at line 611 of file string.hh.

References oom_data.

Referenced by StringAccum::assign_out_of_memory().

◆ printable()

String String::printable ( int  type = 0) const

Return a "printable" version of this string.

Parameters
typequoting type

The default quoting type (0) translates control characters 0-31 into "control" sequences, such as "^@" for the null character, and characters 127-255 into octal escape sequences, such as "\377" for 255. Quoting type 1 translates all characters outside of 32-126 into octal escape sequences.

Definition at line 606 of file string.cc.

References _r, hard_printable(), i, out_of_memory(), and type.

◆ starts_with() [1/2]

bool String::starts_with ( const char *  s,
int  len 
) const

Return true iff this string begins with the data in s.

Parameters
sstring data to compare to
lenlength of s

If len < 0, then treats s as a null-terminated C string.

See also
String::compare(const String &a, const String &b)

Definition at line 736 of file string.cc.

References _r, len, memcmp, oom_data, s, and strlen().

◆ starts_with() [2/2]

bool String::starts_with ( const String x) const
inline

Return true iff this string begins with prefix x.

Same as String::starts_with(x.data(), x.length()).

Definition at line 446 of file string.hh.

References cordic::x.

◆ substring() [1/4]

String String::substring ( const char *  begin,
const char *  end 
) const
inline

Return a substring of the current string starting at begin and ending before end.

Parameters
beginpointer to the first substring character
endpointer one beyond the last substring character

Returns an empty string if begin >= end. Also returns an empty string if begin or end is out of range (i.e., either less than this->begin() or greater than this->end()), but this should be considered a programming error; a future version may generate a warning for this case.

Definition at line 371 of file string.hh.

References _r, begin(), end(), and String().

Referenced by Efont::Type1Charstring::assign_substring(), Filename::base(), Efont::OpenType::Coverage::check(), Efont::OpenType::ClassDef::check(), Efont::OpenType::Font::check_checksums(), Efont::OpenType::ClassDef::class_iterator::class_iterator(), do_file(), Filename::extension(), Filename::Filename(), Efont::Type1SubrGroupItem::gen(), getodir(), DvipsEncoding::glyphname_unicode(), Efont::Cff::gsubr(), Efont::OpenType::Coverage::iterator::iterator(), main(), Efont::OpenType::Name::name(), Efont::OpenType::Data::offset_subtable(), Efont::OpenType::FeatureList::params(), Efont::OpenType::Font::parse_header(), MakeType1CharstringInterp::run(), substring(), Efont::Type1Charstring::substring(), Efont::OpenType::Data::subtable(), suffix_font_name(), Efont::OpenType::Font::table(), Efont::OpenType::Name::utf8_name(), ErrorHandler::vxformat(), and write_encoding_file().

◆ substring() [2/4]

String String::substring ( const unsigned char *  first,
const unsigned char *  last 
) const
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 379 of file string.hh.

References first, last, and substring().

◆ substring() [3/4]

String String::substring ( int  pos) const
inline

Return the suffix of the current string starting at index pos.

If pos is negative, starts that far from the end of the string. If pos is so negative that the suffix starts outside the string, then the entire string is returned. If the substring is beyond the end of the string (pos > length()), returns an empty string (but this should be considered a programming error; a future version may generate a warning for this case).

Note
String::substring() is intended to behave like Perl's substr().

Definition at line 410 of file string.hh.

References _r, pos, and substring().

◆ substring() [4/4]

String String::substring ( int  pos,
int  len 
) const

Return a substring of this string, consisting of the len characters starting at index pos.

Parameters
possubstring's first position relative to the string
lenlength of substring

If pos is negative, starts that far from the end of the string. If len is negative, leaves that many characters off the end of the string. If pos and len specify a substring that is partly outside the string, only the part within the string is returned. If the substring is beyond either end of the string, returns an empty string (but this should be considered a programming error; a future version may generate a warning for this case).

Note
String::substring() is intended to behave like Perl's substr().

Definition at line 470 of file string.cc.

References _r, len, pos, and String().

◆ ubegin()

const unsigned char* String::ubegin ( ) const
inline

Definition at line 193 of file string.hh.

References _r.

◆ udata()

const unsigned char* String::udata ( ) const
inline

Return a pointer to the string's data as unsigned chars.

Only the first length() characters are valid, and the string data might not be null-terminated.

See also
data()

Definition at line 169 of file string.hh.

References _r.

Referenced by Efont::Type1CharstringGenInterp::act_hintmask(), Efont::OpenType::Name::begin(), Efont::OpenType::Coverage::check(), Efont::OpenType::ClassDef::check(), Efont::OpenType::Font::check_checksums(), Efont::OpenType::ScriptList::check_header(), Efont::OpenType::FeatureList::check_header(), Efont::OpenType::ScriptList::check_script(), Efont::OpenType::ClassDef::class_iterator::class_iterator(), Efont::OpenType::Coverage::iterator::coverage_index(), Efont::OpenType::Font::data(), Efont::OpenType::Name::end(), Efont::OpenType::ScriptList::features(), Efont::OpenType::FeatureList::filter(), Efont::OpenType::FeatureList::find(), Efont::OpenType::Cmap::first_table(), Efont::OpenType::Coverage::iterator::forward_to(), Efont::OpenType::ClassDef::class_iterator::increment_class0(), Efont::OpenType::Coverage::iterator::iterator(), Efont::OpenType::ScriptList::langsys_offset(), Efont::OpenType::ScriptList::language_systems(), Efont::OpenType::ClassDef::lookup(), Efont::OpenType::FeatureList::lookups(), Efont::OpenType::Name::name(), Efont::OpenType::Coverage::iterator::operator++(), Efont::OpenType::ClassDef::class_iterator::operator++(), Efont::OpenType::FeatureList::params(), Efont::OpenType::Cmap::parse_header(), Efont::OpenType::Name::parse_header(), Efont::OpenType::Data::s16(), Efont::OpenType::Data::s32(), Efont::OpenType::ScriptList::script_offset(), Efont::OpenType::Coverage::size(), Efont::OpenType::Cmap::table_data(), Efont::OpenType::FeatureList::tag(), Efont::OpenType::Data::u16(), Efont::OpenType::Data::u32(), Efont::OpenType::Data::udata(), Efont::OpenType::ClassDef::unparse(), and Efont::OpenType::Name::utf8_name().

◆ uend()

const unsigned char* String::uend ( ) const
inline

Definition at line 197 of file string.hh.

References _r.

Referenced by Efont::OpenType::Cmap::check_table().

◆ upper()

String String::upper ( ) const

Return an uppercased version of this string.

Translates the ASCII characters 'a' through 'z' into their uppercase equivalents.

Definition at line 570 of file string.cc.

References _r, hard_upper(), and i.

Friends And Related Function Documentation

◆ operator!=() [1/3]

bool operator!= ( const char *  a,
const String b 
)
related

Definition at line 763 of file string.hh.

References a, and b.

◆ operator!=() [2/3]

bool operator!= ( const String a,
const char *  b 
)
related

Definition at line 768 of file string.hh.

References a, and b.

◆ operator!=() [3/3]

bool operator!= ( const String a,
const String b 
)
related

Compare two Strings for inequality.

Returns true iff !(a == b). At most one of the operands can be a null-terminated C string.

Definition at line 758 of file string.hh.

References a, and b.

◆ operator+() [1/4]

String operator+ ( const char *  a,
const String b 
)
related

Definition at line 828 of file string.hh.

References a, b, and s1.

◆ operator+() [2/4]

String operator+ ( String  a,
char  b 
)
related

Concatenate the operands and return the result.

The second operand is a single character.

Definition at line 838 of file string.hh.

References a, and b.

◆ operator+() [3/4]

String operator+ ( String  a,
const char *  b 
)
related

Definition at line 822 of file string.hh.

References a, and b.

◆ operator+() [4/4]

String operator+ ( String  a,
const String b 
)
related

Concatenate the operands and return the result.

At most one of the two operands can be a null-terminated C string.

Definition at line 816 of file string.hh.

References a, and b.

◆ operator<()

bool operator< ( const String a,
const String b 
)
related

Compare two Strings.

Returns true iff a < b in lexicographic order.

See also
String::compare

Definition at line 778 of file string.hh.

References a, and b.

◆ operator<=()

bool operator<= ( const String a,
const String b 
)
related

Compare two Strings.

Returns true iff a <= b in lexicographic order.

See also
String::compare

Definition at line 788 of file string.hh.

References a, and b.

◆ operator==() [1/3]

bool operator== ( const char *  a,
const String b 
)
related

Definition at line 744 of file string.hh.

References a, and b.

◆ operator==() [2/3]

bool operator== ( const String a,
const char *  b 
)
related

Definition at line 749 of file string.hh.

References a, and b.

◆ operator==() [3/3]

bool operator== ( const String a,
const String b 
)
related

Compares two strings for equality.

Returns true iff the two operands have the same lengths and the same characters in the same order. At most one of the operands can be a null-terminated C string.

See also
String::compare

Definition at line 739 of file string.hh.

References a, and b.

Referenced by CollationIterator::operator!=(), and CharString::operator!=().

◆ operator>()

bool operator> ( const String a,
const String b 
)
related

Compare two Strings.

Returns true iff a > b in lexicographic order.

See also
String::compare

Definition at line 798 of file string.hh.

References a, and b.

◆ operator>=()

bool operator>= ( const String a,
const String b 
)
related

Compare two Strings.

Returns true iff a >= b in lexicographic order.

See also
String::compare

Definition at line 808 of file string.hh.

References a, and b.

◆ rep_t

friend struct rep_t
friend

Definition at line 725 of file string.hh.

◆ StringAccum

friend class StringAccum
friend

Definition at line 726 of file string.hh.

Member Data Documentation

◆ _r

◆ bool_data

const char String::bool_data = "true\0false"
staticprivate

Definition at line 718 of file string.hh.

Referenced by String().

◆ int_data

const char String::int_data = "0\0001\0002\0003\0004\0005\0006\0007\0008\0009"
staticprivate

Definition at line 719 of file string.hh.

Referenced by String().

◆ name

◆ NextStr

struct String* String::NextStr

Definition at line 52 of file t1part.c.

Referenced by AddStr(), OutStr(), Reeverse(), and UnDefineStr().

◆ null_data

const char String::null_data = '\0'
staticprivate

Definition at line 716 of file string.hh.

Referenced by assign(), and String().

◆ null_string_rep

const String::rep_t String::null_string_rep
staticprivate
Initial value:
= {
&null_data, 0, 0
}
static const char null_data
Definition: string.hh:716

Definition at line 720 of file string.hh.

Referenced by make_empty().

◆ num

int String::num

Definition at line 51 of file t1part.c.

Referenced by AddStr(), and Reeverse().

◆ oom_data

const char String::oom_data = '\0'
staticprivate

◆ oom_string_rep

const String::rep_t String::oom_string_rep
staticprivate
Initial value:
= {
&oom_data, 0, 0
}
static const char oom_data
Definition: string.hh:717

Definition at line 721 of file string.hh.

Referenced by make_out_of_memory().


The documentation for this class was generated from the following files: