foobar2000 SDK  2015-08-03
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Types
pfc::string8_t< t_alloc >

#include <string_base.h>

+ Inheritance diagram for pfc::string8_t< t_alloc >:

Public Member Functions

 string8_t ()
 
 string8_t (const char *p_string)
 
 string8_t (const char *p_string, t_size p_length)
 
 string8_t (const t_self &p_string)
 
 string8_t (const string_base &p_string)
 
 string8_t (string_part_ref ref)
 
void add_string (const char *p_string, t_size p_length=~0)
 
void add_string (string_part_ref ref)
 
void add_string_ (const char *str)
 
void add_string_nc (const char *ptr, t_size len)
 
void fix_filename_chars (char def= '_', char leave=0)
 
void force_reset ()
 
t_size get_length () const throw ()
 
const char * get_ptr () const throw ()
 
void insert_chars (t_size first, const char *src, t_size count)
 
void insert_chars (t_size first, const char *src)
 
char * lock_buffer (t_size n)
 
 operator const char * () const throw ()
 
const t_selfoperator+= (const char *src)
 
const t_selfoperator+= (const string_base &src)
 
const t_selfoperator+= (const t_self &src)
 
const t_selfoperator+= (string_part_ref src)
 
const t_selfoperator= (const char *src)
 
const t_selfoperator= (const string_base &src)
 
const t_selfoperator= (const t_self &src)
 
const t_selfoperator= (string_part_ref src)
 
void prealloc (t_size p_size)
 
void remove_chars (t_size first, t_size count)
 
t_size replace_byte (char c1, char c2, t_size start=0)
 
t_size replace_char (unsigned c1, unsigned c2, t_size start=0)
 
t_size replace_nontext_chars (char p_replace= '_')
 
void set_char (unsigned offset, char c)
 
void set_string (const char *p_string, t_size p_length=~0)
 
void set_string (string_part_ref ref)
 
void set_string_ (const char *str)
 
void set_string_nc (const char *ptr, t_size len)
 
void truncate (t_size len)
 
void unlock_buffer ()
 
- Public Member Functions inherited from pfc::string_base
string_base_formatter () const
 
void add_filename (const char *fn)
 
const char * c_str () const
 
void convert_to_lower_ascii (const char *src, char replace= '?')
 
void delimit (const char *c)
 
void end_with (char c)
 
void end_with_slash ()
 
bool ends_with (char c) const
 
t_size find_first (char p_char, t_size p_start=0) const
 
t_size find_first (const char *p_string, t_size p_start=0) const
 
t_size find_last (char p_char, t_size p_start=~0) const
 
t_size find_last (const char *p_string, t_size p_start=~0) const
 
void fix_dir_separator (char c= '\\')
 
bool fix_eol (const char *append=" (...)", t_size start=0)
 
bool has_prefix (const char *prefix) const
 
bool has_prefix_i (const char *prefix) const
 
bool has_suffix (const char *suffix) const
 
bool has_suffix_i (const char *suffix) const
 
bool is_empty () const
 
bool is_valid_utf8 () const
 
char last_char () const
 
t_size length () const
 
bool limit_length (t_size length_in_chars, const char *append=" (...)")
 
 operator const char * () const
 
bool operator!= (const string_base &p_other) const
 
const string_baseoperator+= (const char *src)
 
const string_baseoperator+= (const string_base &src)
 
bool operator< (const string_base &p_other) const
 
bool operator<= (const string_base &p_other) const
 
const string_baseoperator= (const char *src)
 
const string_baseoperator= (const string_base &src)
 
bool operator== (const string_base &p_other) const
 
bool operator> (const string_base &p_other) const
 
bool operator>= (const string_base &p_other) const
 
t_size replace_string (const char *replace, const char *replaceWith, t_size start=0)
 
void reset ()
 
t_size scan_filename () const
 
void set_string_ (const char *str)
 
void skip_trailing_char (unsigned c= ' ')
 
const char * toString () const
 
bool truncate_eol (t_size start=0)
 
void truncate_filename ()
 
void truncate_last_char ()
 
void truncate_number_suffix ()
 
void truncate_to_parent_path ()
 
- Public Member Functions inherited from pfc::string_receiver
void add_byte (char c)
 
void add_char (t_uint32 c)
 
void add_chars (t_uint32 p_char, t_size p_count)
 
void add_string_ (const char *str)
 

Static Public Member Functions

static void g_swap (t_self &p_item1, t_self &p_item2)
 

Protected Member Functions

const char * _get_ptr () const throw ()
 
void makespace (t_size s)
 
- Protected Member Functions inherited from pfc::string_base
 string_base ()
 
 ~string_base ()
 
- Protected Member Functions inherited from pfc::string_receiver
 string_receiver ()
 
 ~string_receiver ()
 

Protected Attributes

pfc::array_t< char, t_alloc > m_data
 
t_size used
 

Private Types

typedef string8_t< t_alloc > t_self
 

Detailed Description

template<template< typename > class t_alloc>
class pfc::string8_t< t_alloc >

Definition at line 321 of file string_base.h.

Member Typedef Documentation

template<template< typename > class t_alloc>
typedef string8_t<t_alloc> pfc::string8_t< t_alloc >::t_self
private

Definition at line 323 of file string_base.h.

Constructor & Destructor Documentation

template<template< typename > class t_alloc>
pfc::string8_t< t_alloc >::string8_t ( )
inline

Definition at line 373 of file string_base.h.

373 : used(0) {}
template<template< typename > class t_alloc>
pfc::string8_t< t_alloc >::string8_t ( const char *  p_string)
inline

Definition at line 374 of file string_base.h.

374 : used(0) {set_string_(p_string);}
void set_string_(const char *str)
Definition: string_base.h:343
template<template< typename > class t_alloc>
pfc::string8_t< t_alloc >::string8_t ( const char *  p_string,
t_size  p_length 
)
inline

Definition at line 375 of file string_base.h.

375 : used(0) {set_string(p_string,p_length);}
void set_string(const char *p_string, t_size p_length=~0)
Definition: string8_impl.h:15
template<template< typename > class t_alloc>
pfc::string8_t< t_alloc >::string8_t ( const t_self p_string)
inline

Definition at line 376 of file string_base.h.

376 : used(0) {set_string(p_string);}
void set_string(const char *p_string, t_size p_length=~0)
Definition: string8_impl.h:15
template<template< typename > class t_alloc>
pfc::string8_t< t_alloc >::string8_t ( const string_base p_string)
inline

Definition at line 377 of file string_base.h.

377 : used(0) {set_string(p_string);}
void set_string(const char *p_string, t_size p_length=~0)
Definition: string8_impl.h:15
template<template< typename > class t_alloc>
pfc::string8_t< t_alloc >::string8_t ( string_part_ref  ref)
inline

Definition at line 378 of file string_base.h.

378 : used(0) {set_string(ref);}
void set_string(const char *p_string, t_size p_length=~0)
Definition: string8_impl.h:15

Member Function Documentation

template<template< typename > class t_alloc>
const char* pfc::string8_t< t_alloc >::_get_ptr ( ) const
throw (
)
inlineprotected

Definition at line 340 of file string_base.h.

340 {return used > 0 ? m_data.get_ptr() : "";}
const t_item * get_ptr() const
Definition: array.h:213
pfc::array_t< char, t_alloc > m_data
Definition: string_base.h:325
template<template< typename > class t_alloc>
void pfc::string8_t< t_alloc >::add_string ( const char *  p_string,
t_size  p_length = ~0 
)
virtual

Implements pfc::string_base.

Definition at line 4 of file string8_impl.h.

5 {
6  if (m_data.is_owned(ptr)) {
7  add_string(string8(ptr,len));
8  } else {
9  len = strlen_max(ptr,len);
10  add_string_nc(ptr, len);
11  }
12 }
pfc::array_t< char, t_alloc > m_data
Definition: string_base.h:325
void add_string_nc(const char *ptr, t_size len)
Definition: string_base.h:353
string8_t< pfc::alloc_standard > string8
Definition: string_base.h:432
void add_string(const char *p_string, t_size p_length=~0)
Definition: string8_impl.h:4
t_size strlen_max(const char *ptr, t_size max)
Definition: string_base.h:91
bool is_owned(const t_source &p_item)
Definition: array.h:230
template<template< typename > class t_alloc>
void pfc::string8_t< t_alloc >::add_string ( string_part_ref  ref)
inline

Definition at line 388 of file string_base.h.

388 {add_string_nc(ref.m_ptr, ref.m_len);}
void add_string_nc(const char *ptr, t_size len)
Definition: string_base.h:353
template<template< typename > class t_alloc>
void pfc::string8_t< t_alloc >::add_string_ ( const char *  str)
inline

Definition at line 344 of file string_base.h.

344 {add_string_nc(str, strlen(str));}
void add_string_nc(const char *ptr, t_size len)
Definition: string_base.h:353
template<template< typename > class t_alloc>
void pfc::string8_t< t_alloc >::add_string_nc ( const char *  ptr,
t_size  len 
)
inline

Definition at line 353 of file string_base.h.

353  {
354  PFC_ASSERT(! m_data.is_owned(ptr) );
355  PFC_ASSERT( strlen_max(ptr, len) == len );
356  makespace(used+len+1);
357  pfc::memcpy_t(m_data.get_ptr() + used,ptr,len);
358  used+=len;
359  m_data[used]=0;
360  }
const t_item * get_ptr() const
Definition: array.h:213
pfc::array_t< char, t_alloc > m_data
Definition: string_base.h:325
void makespace(t_size s)
Definition: string_base.h:328
t_size strlen_max(const char *ptr, t_size max)
Definition: string_base.h:91
void memcpy_t(t_dst *p_dst, const t_src *p_src, t_size p_count)
Definition: primitives.h:611
bool is_owned(const t_source &p_item)
Definition: array.h:230
template<template< typename > class t_alloc>
void pfc::string8_t< t_alloc >::fix_filename_chars ( char  def = '_',
char  leave = 0 
)

Definition at line 32 of file string8_impl.h.

33 {
34  t_size n;
35  for(n=0;n<used;n++)
36  if (m_data[n]!=leave && pfc::is_path_bad_char(m_data[n])) m_data[n]=def;
37 }
pfc::array_t< char, t_alloc > m_data
Definition: string_base.h:325
size_t t_size
Definition: int_types.h:48
bool is_path_bad_char(unsigned c)
Definition: string_base.cpp:64
template<template< typename > class t_alloc>
void pfc::string8_t< t_alloc >::force_reset ( )
inline

Definition at line 424 of file string_base.h.

424 {used=0;m_data.force_reset();}
pfc::array_t< char, t_alloc > m_data
Definition: string_base.h:325
void force_reset()
Definition: array.h:132
template<template< typename > class t_alloc>
static void pfc::string8_t< t_alloc >::g_swap ( t_self p_item1,
t_self p_item2 
)
inlinestatic

Definition at line 426 of file string_base.h.

426  {
427  pfc::swap_t(p_item1.m_data,p_item2.m_data);
428  pfc::swap_t(p_item1.used,p_item2.used);
429  }
void swap_t(T &p_item1, T &p_item2)
Definition: primitives.h:285
template<template< typename > class t_alloc>
t_size pfc::string8_t< t_alloc >::get_length ( ) const
throw (
)
inlinevirtual

Reimplemented from pfc::string_base.

Definition at line 395 of file string_base.h.

395 {return used;}
template<template< typename > class t_alloc>
const char* pfc::string8_t< t_alloc >::get_ptr ( ) const
throw (
)
inlinevirtual

Implements pfc::string_base.

Definition at line 382 of file string_base.h.

382 {return _get_ptr();}
const char * _get_ptr() const
Definition: string_base.h:340
template<template< typename > class t_alloc>
void pfc::string8_t< t_alloc >::insert_chars ( t_size  first,
const char *  src,
t_size  count 
)

Definition at line 55 of file string8_impl.h.

56 {
57  if (first > used) first = used;
58 
59  makespace(used+count+1);
60  t_size n;
61  for(n=used;(int)n>=(int)first;n--)
62  m_data[n+count] = m_data[n];
63  for(n=0;n<count;n++)
64  m_data[first+n] = src[n];
65 
66  used+=count;
67 }
pfc::array_t< char, t_alloc > m_data
Definition: string_base.h:325
void makespace(t_size s)
Definition: string_base.h:328
size_t t_size
Definition: int_types.h:48
template<template< typename > class t_alloc>
void pfc::string8_t< t_alloc >::insert_chars ( t_size  first,
const char *  src 
)

Definition at line 70 of file string8_impl.h.

70 {insert_chars(first,src,strlen(src));}
void insert_chars(t_size first, const char *src, t_size count)
Definition: string8_impl.h:55
template<template< typename > class t_alloc>
char* pfc::string8_t< t_alloc >::lock_buffer ( t_size  n)
inlinevirtual

Implements pfc::string_base.

Definition at line 409 of file string_base.h.

410  {
411  if (n + 1 == 0) throw exception_overflow();
412  makespace(n+1);
413  pfc::memset_t(m_data,(char)0);
414  return m_data.get_ptr();;
415  }
const t_item * get_ptr() const
Definition: array.h:213
pfc::array_t< char, t_alloc > m_data
Definition: string_base.h:325
void makespace(t_size s)
Definition: string_base.h:328
void memset_t(T *p_buffer, const t_val &p_val, t_size p_count)
Definition: primitives.h:627
template<template< typename > class t_alloc>
void pfc::string8_t< t_alloc >::makespace ( t_size  s)
inlineprotected

Definition at line 328 of file string_base.h.

328  {
329  if (t_alloc<char>::alloc_prioritizes_speed) {
330  m_data.set_size(s);
331  } else {
332  const t_size old_size = m_data.get_size();
333  if (old_size < s)
334  m_data.set_size(s + 16);
335  else if (old_size > s + 32)
336  m_data.set_size(s);
337  }
338  }
pfc::array_t< char, t_alloc > m_data
Definition: string_base.h:325
size_t t_size
Definition: int_types.h:48
void set_size(t_size p_size)
Definition: array.h:104
t_size get_size() const
Definition: array.h:130
template<template< typename > class t_alloc>
pfc::string8_t< t_alloc >::operator const char * ( ) const
throw (
)
inline

Definition at line 371 of file string_base.h.

371 {return _get_ptr();}
const char * _get_ptr() const
Definition: string_base.h:340
template<template< typename > class t_alloc>
const t_self& pfc::string8_t< t_alloc >::operator+= ( const char *  src)
inline

Definition at line 362 of file string_base.h.

362 {add_string_(src);return *this;}
void add_string_(const char *str)
Definition: string_base.h:344
template<template< typename > class t_alloc>
const t_self& pfc::string8_t< t_alloc >::operator+= ( const string_base src)
inline

Definition at line 364 of file string_base.h.

364 {add_string(src);return *this;}
void add_string(const char *p_string, t_size p_length=~0)
Definition: string8_impl.h:4
template<template< typename > class t_alloc>
const t_self& pfc::string8_t< t_alloc >::operator+= ( const t_self src)
inline

Definition at line 366 of file string_base.h.

366 {add_string(src);return *this;}
void add_string(const char *p_string, t_size p_length=~0)
Definition: string8_impl.h:4
template<template< typename > class t_alloc>
const t_self& pfc::string8_t< t_alloc >::operator+= ( string_part_ref  src)
inline

Definition at line 369 of file string_base.h.

369 {add_string(src);return *this;}
void add_string(const char *p_string, t_size p_length=~0)
Definition: string8_impl.h:4
template<template< typename > class t_alloc>
const t_self& pfc::string8_t< t_alloc >::operator= ( const char *  src)
inline

Definition at line 361 of file string_base.h.

361 {set_string_(src);return *this;}
void set_string_(const char *str)
Definition: string_base.h:343
template<template< typename > class t_alloc>
const t_self& pfc::string8_t< t_alloc >::operator= ( const string_base src)
inline

Definition at line 363 of file string_base.h.

363 {set_string(src);return *this;}
void set_string(const char *p_string, t_size p_length=~0)
Definition: string8_impl.h:15
template<template< typename > class t_alloc>
const t_self& pfc::string8_t< t_alloc >::operator= ( const t_self src)
inline

Definition at line 365 of file string_base.h.

365 {set_string(src);return *this;}
void set_string(const char *p_string, t_size p_length=~0)
Definition: string8_impl.h:15
template<template< typename > class t_alloc>
const t_self& pfc::string8_t< t_alloc >::operator= ( string_part_ref  src)
inline

Definition at line 368 of file string_base.h.

368 {set_string(src);return *this;}
void set_string(const char *p_string, t_size p_length=~0)
Definition: string8_impl.h:15
template<template< typename > class t_alloc>
void pfc::string8_t< t_alloc >::prealloc ( t_size  p_size)
inline

Definition at line 380 of file string_base.h.

380 {m_data.prealloc(p_size+1);}
pfc::array_t< char, t_alloc > m_data
Definition: string_base.h:325
void prealloc(t_size p_size)
Definition: array.h:216
template<template< typename > class t_alloc>
void pfc::string8_t< t_alloc >::remove_chars ( t_size  first,
t_size  count 
)

Definition at line 40 of file string8_impl.h.

41 {
42  if (first>used) first = used;
43  if (first+count>used) count = used-first;
44  if (count>0)
45  {
46  t_size n;
47  for(n=first+count;n<=used;n++)
48  m_data[n-count]=m_data[n];
49  used -= count;
50  makespace(used+1);
51  }
52 }
pfc::array_t< char, t_alloc > m_data
Definition: string_base.h:325
void makespace(t_size s)
Definition: string_base.h:328
size_t t_size
Definition: int_types.h:48
template<template< typename > class t_alloc>
t_size pfc::string8_t< t_alloc >::replace_byte ( char  c1,
char  c2,
t_size  start = 0 
)

Definition at line 85 of file string8_impl.h.

86 {
87  PFC_ASSERT(c1 != 0); PFC_ASSERT(c2 != 0);
88  t_size n, ret = 0;
89  for(n=start;n<used;n++)
90  {
91  if (m_data[n] == c1) {m_data[n] = c2; ret++;}
92  }
93  return ret;
94 }
pfc::array_t< char, t_alloc > m_data
Definition: string_base.h:325
size_t t_size
Definition: int_types.h:48
template<template< typename > class t_alloc>
t_size pfc::string8_t< t_alloc >::replace_char ( unsigned  c1,
unsigned  c2,
t_size  start = 0 
)

Definition at line 97 of file string8_impl.h.

98 {
99  if (c1 < 128 && c2 < 128) return replace_byte((char)c1,(char)c2,start);
100 
101  string8 temp(get_ptr()+start);
102  truncate(start);
103  const char * ptr = temp;
104  t_size rv = 0;
105  while(*ptr)
106  {
107  unsigned test;
108  t_size delta = utf8_decode_char(ptr,test);
109  if (delta==0 || test==0) break;
110  if (test == c1) {test = c2;rv++;}
111  add_char(test);
112  ptr += delta;
113  }
114  return rv;
115 }
void truncate(t_size len)
Definition: string_base.h:390
Decoder Validator v1 readme Usage Select a single file handled by the decoder you want to test
Definition: readme.txt:4
string8_t< pfc::alloc_standard > string8
Definition: string_base.h:432
const char * get_ptr() const
Definition: string_base.h:382
size_t t_size
Definition: int_types.h:48
t_size utf8_decode_char(const char *src, unsigned &out, t_size src_bytes)
Definition: utf8.cpp:64
void add_char(t_uint32 c)
Definition: string_base.cpp:5
t_size replace_byte(char c1, char c2, t_size start=0)
Definition: string8_impl.h:85
template<template< typename > class t_alloc>
t_size pfc::string8_t< t_alloc >::replace_nontext_chars ( char  p_replace = '_')

Definition at line 74 of file string8_impl.h.

75 {
76  t_size ret = 0;
77  for(t_size n=0;n<used;n++)
78  {
79  if ((unsigned char)m_data[n] < 32) {m_data[n] = p_replace; ret++; }
80  }
81  return ret;
82 }
pfc::array_t< char, t_alloc > m_data
Definition: string_base.h:325
size_t t_size
Definition: int_types.h:48
template<template< typename > class t_alloc>
void pfc::string8_t< t_alloc >::set_char ( unsigned  offset,
char  c 
)

Definition at line 25 of file string8_impl.h.

26 {
27  if (!c) truncate(offset);
28  else if (offset<used) m_data[offset]=c;
29 }
void truncate(t_size len)
Definition: string_base.h:390
pfc::array_t< char, t_alloc > m_data
Definition: string_base.h:325
template<template< typename > class t_alloc>
void pfc::string8_t< t_alloc >::set_string ( const char *  p_string,
t_size  p_length = ~0 
)
virtual

Reimplemented from pfc::string_base.

Definition at line 15 of file string8_impl.h.

15  {
16  if (m_data.is_owned(ptr)) {
17  set_string_(string8(ptr,len));
18  } else {
19  len = strlen_max(ptr,len);
20  set_string_nc(ptr, len);
21  }
22 }
void set_string_nc(const char *ptr, t_size len)
Definition: string_base.h:345
pfc::array_t< char, t_alloc > m_data
Definition: string_base.h:325
string8_t< pfc::alloc_standard > string8
Definition: string_base.h:432
t_size strlen_max(const char *ptr, t_size max)
Definition: string_base.h:91
void set_string_(const char *str)
Definition: string_base.h:343
bool is_owned(const t_source &p_item)
Definition: array.h:230
template<template< typename > class t_alloc>
void pfc::string8_t< t_alloc >::set_string ( string_part_ref  ref)
inline

Definition at line 387 of file string_base.h.

387 {set_string_nc(ref.m_ptr, ref.m_len);}
void set_string_nc(const char *ptr, t_size len)
Definition: string_base.h:345
template<template< typename > class t_alloc>
void pfc::string8_t< t_alloc >::set_string_ ( const char *  str)
inline

Definition at line 343 of file string_base.h.

343 {set_string_nc(str, strlen(str));}
void set_string_nc(const char *ptr, t_size len)
Definition: string_base.h:345
template<template< typename > class t_alloc>
void pfc::string8_t< t_alloc >::set_string_nc ( const char *  ptr,
t_size  len 
)
inline

Definition at line 345 of file string_base.h.

345  {
346  PFC_ASSERT(! m_data.is_owned(ptr) );
347  PFC_ASSERT( strlen_max(ptr, len) == len );
348  makespace(len+1);
349  pfc::memcpy_t(m_data.get_ptr(),ptr,len);
350  used=len;
351  m_data[used]=0;
352  }
const t_item * get_ptr() const
Definition: array.h:213
pfc::array_t< char, t_alloc > m_data
Definition: string_base.h:325
void makespace(t_size s)
Definition: string_base.h:328
t_size strlen_max(const char *ptr, t_size max)
Definition: string_base.h:91
void memcpy_t(t_dst *p_dst, const t_src *p_src, t_size p_count)
Definition: primitives.h:611
bool is_owned(const t_source &p_item)
Definition: array.h:230
template<template< typename > class t_alloc>
void pfc::string8_t< t_alloc >::truncate ( t_size  len)
inlinevirtual

Implements pfc::string_base.

Definition at line 390 of file string_base.h.

391  {
392  if (used>len) {used=len;m_data[len]=0;makespace(used+1);}
393  }
pfc::array_t< char, t_alloc > m_data
Definition: string_base.h:325
void makespace(t_size s)
Definition: string_base.h:328
template<template< typename > class t_alloc>
void pfc::string8_t< t_alloc >::unlock_buffer ( )
inlinevirtual

Implements pfc::string_base.

Definition at line 417 of file string_base.h.

417  {
418  if (m_data.get_size() > 0) {
419  used=strlen(m_data.get_ptr());
420  makespace(used+1);
421  }
422  }
const t_item * get_ptr() const
Definition: array.h:213
pfc::array_t< char, t_alloc > m_data
Definition: string_base.h:325
void makespace(t_size s)
Definition: string_base.h:328
t_size get_size() const
Definition: array.h:130

Field Documentation

template<template< typename > class t_alloc>
pfc::array_t<char,t_alloc> pfc::string8_t< t_alloc >::m_data
protected

Definition at line 325 of file string_base.h.

template<template< typename > class t_alloc>
t_size pfc::string8_t< t_alloc >::used
protected

Definition at line 326 of file string_base.h.


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