2 * Simulator of microcontrollers (charscl.h)
4 * Copyright (C) 1997 Drotos Daniel
6 * To contact author send email to dr.dkdb@gmail.com
10 /* This file is part of microcontroller simulator: ucsim.
12 UCSIM is free software; you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation; either version 2 of the License, or
15 (at your option) any later version.
17 UCSIM is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
22 You should have received a copy of the GNU General Public License
23 along with UCSIM; see the file COPYING. If not, write to the Free
24 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
28 #ifndef CHARSCL_HEADER
29 #define CHARSCL_HEADER
35 char *chars_string
; // stores the value
36 int chars_length
; // track of string length
43 chars(const chars
&cs
);
44 chars(const char *, const char *fmt
, ...);
47 void allocate_string(const char *s
);
48 void deallocate_string(void);
51 const char *c_str(void) const { return chars_string
; }
52 const char *cstr(void) const { return chars_string
; }
53 char *str(void) { return chars_string
; }
55 chars
&append(const char *s
);
56 chars
&append(char c
);
57 chars
&appendf(const char *format
, ...);
58 chars
&appendn(const char *src
, int n
);
59 chars
&format(const char *format
, ...);
60 bool empty() const { return chars_length
== 0; }
61 bool nempty() const { return !empty(); }
62 bool is_null()const { return !chars_string
; }
63 chars
&uppercase(void);
64 chars
&subst(const char *what
, char with
);
65 chars
&substr(int start
, int maxlen
);
66 int len() const { return chars_length
; }
67 int length() const { return chars_length
; }
68 void start_parse(void) const { start_parse(0); }
69 void start_parse(int at
) const { pars_pos
= at
; }
70 chars
token(const char *delims
) const;
71 unsigned int htoi(void);
72 unsigned long long int htoll(void);
75 void trim() { ltrim(); rtrim(); }
76 void lrip(const char *cset
);
77 void rrip(const char *cset
);
78 void rrip(int nuof_chars
);
79 void rip(const char *cset
) { lrip(cset
); rrip(cset
); }
81 bool starts_with(const char *x
) const;
82 int first_pos(char c
);
84 long int lint(int base
);
89 operator const char*(void) const { return(chars_string
); };
91 chars
&operator=(const char *s
);
92 chars
&operator=(const chars
&cs
);
94 chars
operator+(char c
) const;
95 chars
operator+(const char *s
) const;
96 chars
&operator+=(char c
) { return(append(c
)); }
97 chars
&operator+=(const char *s
) { return(append(s
)); }
99 bool equal(const char *) const;
100 bool operator==(const char *s
) const;
101 bool operator!=(const char *s
) const;
104 extern chars
operator+(char s
, const chars
&cs
);
109 /* End of utils.src/charscl.h */