Lolly 1.4.28
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | Friends | List of all members
lolly::data::string_u16_rep Class Reference

#include <string_u16.hpp>

Inheritance diagram for lolly::data::string_u16_rep:
Inheritance graph
[legend]
Collaboration diagram for lolly::data::string_u16_rep:
Collaboration graph
[legend]

Public Member Functions

 string_u16_rep ()
 
 string_u16_rep (int n)
 
 ~string_u16_rep ()
 
int expand_or_shrink_by (int delta)
 expand (or shrink) string by delta, but do not release memory when string is shrinked.
 
void resize (int n)
 expand (or shrink) string to given length n, and try to release memory when string is shrinked.
 
void reserve (int n)
 reserve memory space to contain at least n word in the whole string. Do not affect length of string, and do not release memory when n is smaller than current space.
 

Private Attributes

int n
 
int a_N
 
char16_ta
 
- Private Attributes inherited from concrete_struct
int ref_count
 The reference count for the concrete object.
 

Friends

class string_u16
 
int N (string_u16 a)
 

Additional Inherited Members

- Private Member Functions inherited from concrete_struct
 concrete_struct ()
 Default constructor for the concrete object. Increments the reference count.
 
virtual ~concrete_struct ()
 Virtual destructor for the concrete object. Decrements the reference count.
 

Detailed Description

Definition at line 23 of file string_u16.hpp.

Constructor & Destructor Documentation

◆ string_u16_rep() [1/2]

lolly::data::string_u16_rep::string_u16_rep ( )
inline

Definition at line 29 of file string_u16.hpp.

29: n (0), a_N (0), a (NULL) {}
The list class represents a linked list.
Definition list.hpp:48

◆ string_u16_rep() [2/2]

lolly::data::string_u16_rep::string_u16_rep ( int n)

Definition at line 26 of file string_u16.cpp.

27 : n (n2), a_N (round_length (n)),
28 a ((n == 0) ? ((char16_t*) NULL) : tm_new_array<char16_t> (a_N)) {}
C * tm_new_array(int n)
static constexpr int round_length(int n)

◆ ~string_u16_rep()

lolly::data::string_u16_rep::~string_u16_rep ( )
inline

Definition at line 31 of file string_u16.hpp.

31 {
32 if (n != 0) tm_delete_array (a);
33 }
void tm_delete_array(C *Ptr)

Member Function Documentation

◆ expand_or_shrink_by()

int lolly::data::string_u16_rep::expand_or_shrink_by ( int delta)

expand (or shrink) string by delta, but do not release memory when string is shrinked.

Returns
string length before expansion

Definition at line 55 of file string_u16.cpp.

55 {
56 int old_n= n;
57 n+= delta;
58 reserve (n);
59 return old_n;
60}
void reserve(int n)
reserve memory space to contain at least n word in the whole string. Do not affect length of string,...
url delta(url base, url u)
Definition url.cpp:469

◆ resize()

void lolly::data::string_u16_rep::resize ( int n)

expand (or shrink) string to given length n, and try to release memory when string is shrinked.

Note
expand_or_shrink_by may be faster if memory space is reserved

Definition at line 31 of file string_u16.cpp.

31 {
32 int nn= round_length (n);
33 int mm= round_length (m);
34 if (mm != nn) {
35 if (mm != 0) {
36 if (nn != 0) {
37 a_N= mm;
39 }
40 else {
41 a_N= mm;
43 }
44 }
45 else if (nn != 0) {
47 a_N= 0;
48 a = NULL;
49 };
50 }
51 n= m;
52}

◆ reserve()

void lolly::data::string_u16_rep::reserve ( int n)

reserve memory space to contain at least n word in the whole string. Do not affect length of string, and do not release memory when n is smaller than current space.

Definition at line 63 of file string_u16.cpp.

63 {
64 int old_size= a_N;
65 if (new_n != 0) {
66 if (old_size == 0) {
69 }
70 else if (old_size < new_n) {
73 }
74 }
75 else {
76 if (old_size != 0) {
78 a = NULL;
79 a_N= 0;
80 };
81 }
82}

Friends And Related Symbol Documentation

◆ string_u16

Definition at line 57 of file string_u16.hpp.

◆ N

int N ( string_u16 a)
friend

Definition at line 98 of file string_u16.hpp.

98 {
99 return a->n;
100}

Member Data Documentation

◆ n

int lolly::data::string_u16_rep::n
private

Definition at line 24 of file string_u16.hpp.

◆ a_N

int lolly::data::string_u16_rep::a_N
private

Definition at line 25 of file string_u16.hpp.

◆ a

char16_t* lolly::data::string_u16_rep::a
private

Definition at line 26 of file string_u16.hpp.


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