Qore Programming Language  0.8.11
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
QoreString.h
1 /* -*- mode: c++; indent-tabs-mode: nil -*- */
2 /*
3  QoreString.h
4 
5  QoreString Class Definition
6 
7  Qore Programming Language
8 
9  Copyright 2003 - 2013 David Nichols
10 
11  This library is free software; you can redistribute it and/or
12  modify it under the terms of the GNU Lesser General Public
13  License as published by the Free Software Foundation; either
14  version 2.1 of the License, or (at your option) any later version.
15 
16  This library is distributed in the hope that it will be useful,
17  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  Lesser General Public License for more details.
20 
21  You should have received a copy of the GNU Lesser General Public
22  License along with this library; if not, write to the Free Software
23  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 */
25 
26 #ifndef _QORE_QORESTRING_H
27 
28 #define _QORE_QORESTRING_H
29 
30 #include <stdarg.h>
31 
32 #include <string>
33 
34 class DateTime;
35 class BinaryNode;
36 
38 
42 class QoreString {
43 protected:
45  struct qore_string_private* priv;
46 
47  DLLLOCAL void splice_simple(qore_size_t offset, qore_size_t length, QoreString* extract = 0);
48  DLLLOCAL void splice_simple(qore_size_t offset, qore_size_t length, const char* str, qore_size_t str_len, QoreString* extract = 0);
49  DLLLOCAL void splice_complex(qore_offset_t offset, ExceptionSink* xsink, QoreString* extract = 0);
50  DLLLOCAL void splice_complex(qore_offset_t offset, qore_offset_t length, ExceptionSink* xsink, QoreString* extract = 0);
51  DLLLOCAL void splice_complex(qore_offset_t offset, qore_offset_t length, const QoreString* str, ExceptionSink* xsink, QoreString* extract = 0);
52  DLLLOCAL int substr_simple(QoreString* str, qore_offset_t offset) const;
53  DLLLOCAL int substr_simple(QoreString* str, qore_offset_t offset, qore_offset_t length) const;
54  DLLLOCAL int substr_complex(QoreString* str, qore_offset_t offset, ExceptionSink* xsink) const;
55  DLLLOCAL int substr_complex(QoreString* str, qore_offset_t offset, qore_offset_t length, ExceptionSink* xsink) const;
56 
57  // writes a new QoreString with the characters reversed of the "this" QoreString
58  // assumes the encoding is the same and the length is 0
59  DLLLOCAL void concat_reverse(QoreString* targ) const;
60 
61  DLLLOCAL int snprintf(size_t size, const char* fmt, ...);
62  DLLLOCAL int vsnprintf(size_t size, const char* fmt, va_list args);
63  DLLLOCAL static int convert_encoding_intern(const char* src, qore_size_t src_len, const QoreEncoding* from, QoreString& targ, const QoreEncoding* to, ExceptionSink* xsink);
64 
65 public:
67  DLLEXPORT QoreString();
68 
70  DLLEXPORT QoreString(bool b);
71 
73  DLLEXPORT QoreString(const char* str);
74 
76  DLLEXPORT QoreString(const char* str, const QoreEncoding* new_qorecharset);
77 
79  DLLEXPORT QoreString(const QoreEncoding* new_qorecharset);
80 
82  DLLEXPORT QoreString(const char* str, qore_size_t len, const QoreEncoding* new_qorecharset = QCS_DEFAULT);
83 
85  DLLEXPORT QoreString(const std::string& str, const QoreEncoding* new_encoding = QCS_DEFAULT);
86 
88  DLLEXPORT QoreString(char c);
89 
91  DLLEXPORT QoreString(const QoreString& str);
92 
94  DLLEXPORT QoreString(const QoreString* str);
95 
97  DLLEXPORT QoreString(const QoreString* str, qore_size_t len);
98 
100  DLLEXPORT QoreString(int64 i);
101 
103  DLLEXPORT QoreString(double f);
104 
106  DLLEXPORT QoreString(const DateTime* date);
107 
109  DLLEXPORT QoreString(const BinaryNode* bin);
110 
112  DLLEXPORT QoreString(const BinaryNode* bin, qore_size_t maxlinelen);
113 
115  DLLEXPORT QoreString(char* nbuf, qore_size_t nlen, qore_size_t nallocated, const QoreEncoding* enc);
116 
118  DLLEXPORT ~QoreString();
119 
121 
123  DLLEXPORT qore_size_t length() const;
124 
126  DLLEXPORT void set(const char* str, const QoreEncoding* new_qorecharset = QCS_DEFAULT);
127 
129  DLLEXPORT void set(const std::string& str, const QoreEncoding* new_qorecharset = QCS_DEFAULT);
130 
132  DLLEXPORT void set(const QoreString* str);
133 
135  DLLEXPORT void set(const QoreString& str);
136 
138  DLLEXPORT void setEncoding(const QoreEncoding* new_encoding);
139 
141  DLLEXPORT void concatAndHTMLEncode(const char* str);
142 
144  DLLEXPORT void concatAndHTMLDecode(const QoreString* str);
145 
147  DLLEXPORT void concatAndHTMLDecode(const char* str, size_t slen);
148 
150  DLLEXPORT void concatAndHTMLDecode(const char* str);
151 
153 
155  DLLEXPORT void concatDecodeUrl(const char* url);
156 
158  DLLEXPORT int concatDecodeUrl(const QoreString& url, ExceptionSink* xsink);
159 
161 
165  DLLEXPORT int concatEncodeUrl(ExceptionSink* xsink, const QoreString& url, bool encode_all = false);
166 
168  DLLEXPORT void concatEscape(const QoreString* str, char c, char esc_char, ExceptionSink* xsink);
169 
171  DLLEXPORT void concatEscape(const char* str, char c, char esc_char = '\\');
172 
174  DLLEXPORT void concatAndHTMLEncode(const QoreString* , ExceptionSink* xsink);
175 
177  DLLEXPORT void concat(const QoreString* str, ExceptionSink* xsink);
178 
180 
186  DLLEXPORT int concat(const QoreString& str, qore_offset_t pos, ExceptionSink* xsink);
187 
189 
196  DLLEXPORT int concat(const QoreString& str, qore_offset_t pos, qore_offset_t len, ExceptionSink* xsink);
197 
199 
204  DLLEXPORT void concat(const QoreString* str, qore_size_t size, ExceptionSink* xsink);
205 
207  DLLEXPORT void concatBase64(const char* buf, qore_size_t size);
208 
210  DLLEXPORT void concatBase64(const BinaryNode* bin);
211 
213  DLLEXPORT void concatBase64(const QoreString* str);
214 
216  DLLEXPORT void concatBase64(const char* buf, qore_size_t size, qore_size_t maxlinelen);
217 
219  DLLEXPORT void concatBase64(const BinaryNode* bin, qore_size_t maxlinelen);
220 
222  DLLEXPORT void concatBase64(const QoreString* str, qore_size_t maxlinelen);
223 
225 
229  DLLEXPORT BinaryNode* parseBase64(ExceptionSink* xsink) const;
230 
232 
236  DLLEXPORT QoreString* parseBase64ToString(ExceptionSink* xsink) const;
237 
239 
244  DLLEXPORT QoreString* parseBase64ToString(const QoreEncoding* enc, ExceptionSink* xsink) const;
245 
247  DLLEXPORT void concatHex(const char* buf, qore_size_t size);
248 
250  DLLEXPORT void concatHex(const BinaryNode* bin);
251 
253  DLLEXPORT void concatHex(const QoreString* str);
254 
256 
260  DLLEXPORT BinaryNode* parseHex(ExceptionSink* xsink) const;
261 
263  DLLEXPORT void concat(const DateTime* d);
264 
266  DLLEXPORT void concatISO8601DateTime(const DateTime* d);
267 
269  DLLEXPORT void concat(const char* str);
270 
272  DLLEXPORT void concat(const std::string& str);
273 
275  DLLEXPORT void concat(const char* str, qore_size_t size);
276 
278  DLLEXPORT void concat(const char c);
279 
281 
286  DLLEXPORT int compareSoft(const QoreString* str, ExceptionSink* xsink) const;
287 
289 
293  DLLEXPORT int compare(const QoreString* str) const;
294 
296 
300  DLLEXPORT int compare(const char* str) const;
301 
303 
305  DLLEXPORT bool equal(const QoreString& str) const;
306 
308 
310  DLLEXPORT bool equal(const char* str) const;
311 
313 
319  DLLEXPORT bool equalSoft(const QoreString& str, ExceptionSink* xsink) const;
320 
322 
324  DLLEXPORT bool equalPartial(const QoreString& str) const;
325 
327 
329  DLLEXPORT bool equalPartial(const char* str) const;
330 
332 
338  DLLEXPORT bool equalPartialSoft(const QoreString& str, ExceptionSink* xsink) const;
339 
341 
347  DLLEXPORT bool equalPartialPath(const QoreString& str, ExceptionSink* xsink) const;
348 
350  DLLEXPORT void terminate(qore_size_t size);
351 
353 
355  DLLEXPORT void reserve(qore_size_t size);
356 
358 
360  DLLEXPORT int sprintf(const char* fmt, ...);
361 
363 
365  DLLEXPORT int vsprintf(const char* fmt, va_list args);
366 
368 
370  DLLEXPORT void take(char* str);
371 
373  DLLEXPORT void take(char* str, const QoreEncoding* enc);
375 
376  DLLEXPORT void take(char* str, qore_size_t size);
377 
379  DLLEXPORT void take(char* str, qore_size_t size, const QoreEncoding* enc);
380 
382  DLLEXPORT void takeAndTerminate(char* str, qore_size_t size);
383 
385  DLLEXPORT void takeAndTerminate(char* str, qore_size_t size, const QoreEncoding* enc);
386 
388 
393  DLLEXPORT QoreString* convertEncoding(const QoreEncoding* nccs, ExceptionSink* xsink) const;
394 
396 
399  DLLEXPORT char* giveBuffer();
400 
402  DLLEXPORT void clear();
403 
405 
407  DLLEXPORT void reset();
408 
410 
412  DLLEXPORT void replaceAll(const char* old_str, const char* new_str);
413 
415 
417  DLLEXPORT void replace(qore_size_t offset, qore_size_t len, const char* str);
418 
420 
425  DLLEXPORT void replace(qore_size_t offset, qore_size_t len, const QoreString* str);
426 
428 
430  DLLEXPORT void replace(qore_size_t offset, qore_size_t len, const QoreString* str, ExceptionSink* xsink);
431 
433 
435  DLLEXPORT void replaceChar(qore_size_t offset, char c);
436 
438 
442  DLLEXPORT void splice(qore_offset_t offset, ExceptionSink* xsink);
443 
445 
450  DLLEXPORT void splice(qore_offset_t offset, qore_offset_t length, ExceptionSink* xsink);
451 
453 
459  DLLEXPORT void splice(qore_offset_t offset, qore_offset_t length, const AbstractQoreNode* strn, ExceptionSink* xsink);
460 
462 
468  DLLEXPORT void splice(qore_offset_t offset, qore_offset_t length, const QoreString& str, ExceptionSink* xsink);
469 
471 
476  DLLEXPORT QoreString* extract(qore_offset_t offset, ExceptionSink* xsink);
477 
479 
486 
488 
495  DLLEXPORT QoreString* extract(qore_offset_t offset, qore_offset_t length, const AbstractQoreNode* strn, ExceptionSink* xsink);
496 
498 
503  DLLEXPORT QoreString* substr(qore_offset_t offset, ExceptionSink* xsink) const;
504 
506 
512  DLLEXPORT QoreString* substr(qore_offset_t offset, qore_offset_t length, ExceptionSink* xsink) const;
513 
515  DLLEXPORT qore_size_t chomp();
516 
518  DLLEXPORT const QoreEncoding* getEncoding() const;
519 
521  DLLEXPORT QoreString* copy() const;
522 
524 
526  DLLEXPORT void tolwr();
527 
529 
531  DLLEXPORT void toupr();
532 
534  DLLEXPORT qore_size_t strlen() const;
535 
537  DLLEXPORT qore_size_t size() const;
538 
540  DLLEXPORT qore_size_t capacity() const;
541 
543  DLLEXPORT const char* getBuffer() const;
544 
546 
548  DLLEXPORT void allocate(unsigned requested_size);
549 
551 
557  DLLEXPORT int insertch(char c, qore_size_t pos, unsigned times);
558 
560 
565  DLLEXPORT int insert(const char* str, qore_size_t pos);
566 
568  DLLEXPORT void addch(char c, unsigned times);
569 
571 
577  DLLEXPORT void concatUTF8FromUnicode(unsigned code);
578 
580 
584  DLLEXPORT int concatUnicode(unsigned code, ExceptionSink* xsink);
585 
587 
591  DLLEXPORT int concatUnicode(unsigned code);
592 
594 
597  DLLEXPORT QoreString* reverse() const;
598 
600  DLLEXPORT void trim_trailing(const char* chars = 0);
601 
603  DLLEXPORT void trim_leading(const char* chars = 0);
604 
606  DLLEXPORT void trim(const char* chars = 0);
607 
609  DLLEXPORT void trim_trailing(char c);
610 
612  DLLEXPORT void trim_single_trailing(char c);
613 
615  DLLEXPORT void trim_leading(char c);
616 
618  DLLEXPORT void trim_single_leading(char c);
619 
621  DLLEXPORT void trim(char c);
622 
624 
628  DLLEXPORT unsigned int getUnicodePointFromUTF8(qore_offset_t offset = 0) const;
629 
631 
638  DLLEXPORT unsigned int getUnicodePoint(qore_offset_t offset, ExceptionSink* xsink) const;
639 
641 
648  DLLEXPORT unsigned int getUnicodePointFromBytePos(qore_size_t offset, unsigned& len, ExceptionSink* xsink) const;
649 
651  DLLEXPORT void prepend(const char* str);
652 
654  DLLEXPORT void prepend(const char* str, qore_size_t size);
655 
657  DLLEXPORT QoreString& operator=(const QoreString& other);
658 
660  DLLEXPORT QoreString& operator=(const char* other);
661 
663  DLLEXPORT QoreString& operator=(const std::string& other);
664 
666  DLLEXPORT bool operator==(const QoreString& other) const;
667 
669  DLLEXPORT bool operator==(const std::string& other) const;
670 
672  DLLEXPORT bool operator==(const char* other) const;
673 
675 
680  DLLEXPORT char operator[](qore_offset_t pos) const;
681 
683  DLLEXPORT QoreString& operator+=(const char* str);
684 
686  DLLEXPORT QoreString& operator+=(const std::string& str);
687 
689  DLLEXPORT bool empty() const;
690 
692  DLLEXPORT qore_offset_t index(const QoreString& needle, qore_offset_t pos, ExceptionSink* xsink) const;
693 
695  DLLEXPORT qore_offset_t bindex(const QoreString& needle, qore_offset_t pos) const;
696 
698  DLLEXPORT qore_offset_t bindex(const char* needle, qore_offset_t pos) const;
699 
701  DLLEXPORT qore_offset_t bindex(const std::string& needle, qore_offset_t pos) const;
702 
704 
710  DLLEXPORT qore_offset_t rindex(const QoreString& needle, qore_offset_t pos, ExceptionSink* xsink) const;
711 
713  DLLEXPORT qore_offset_t brindex(const QoreString& needle, qore_offset_t pos) const;
714 
716  DLLEXPORT qore_offset_t brindex(const char* needle, qore_offset_t pos) const;
717 
719  DLLEXPORT qore_offset_t brindex(const std::string& needle, qore_offset_t pos) const;
720 
722  DLLEXPORT qore_offset_t find(char c, qore_offset_t pos = 0) const;
723 
725  DLLEXPORT qore_offset_t rfind(char c, qore_offset_t pos = -1) const;
726 
728 
730  DLLEXPORT bool isDataPrintableAscii() const;
731 
733 
735  DLLEXPORT bool isDataAscii() const;
736 
738  DLLEXPORT int64 toBigInt() const;
739 
741 
746  DLLEXPORT qore_offset_t getByteOffset(qore_size_t i, ExceptionSink* xsink) const;
747 
748  // concatenates a qorestring without converting encodings - internal only
749  DLLLOCAL void concat(const QoreString* str);
750 
751  // private constructor
752  DLLLOCAL QoreString(struct qore_string_private* p);
753 };
754 
755 DLLEXPORT QoreString* checkEncoding(const QoreString* str, const QoreEncoding* enc, ExceptionSink* xsink);
756 
757 class QoreStringMaker : public QoreString {
758 private:
760  DLLLOCAL QoreStringMaker(const QoreStringMaker& str);
761 
763  DLLLOCAL QoreStringMaker& operator=(const QoreStringMaker&);
764 
765 public:
767 
769  DLLEXPORT QoreStringMaker(const char* fmt, ...);
770 
772 
774  DLLEXPORT QoreStringMaker(const QoreEncoding* enc, const char* fmt, ...);
775 };
776 
778 
787 class TempString {
788 private:
789  QoreString* str;
790 
792  TempString(const TempString& );
793 
795  TempString& operator=(const TempString& );
796 
798  void* operator new(size_t);
799 
800 public:
802  DLLLOCAL TempString() : str(new QoreString) {
803  }
804 
806  DLLLOCAL TempString(const QoreEncoding* enc) : str(new QoreString(enc)) {
807  }
808 
810  DLLLOCAL TempString(QoreString* s) {
811  str = s;
812  }
813 
815  DLLLOCAL ~TempString() {
816  delete str;
817  }
818 
820  DLLLOCAL QoreString* operator->(){ return str; };
821 
823  DLLLOCAL QoreString* operator*() { return str; };
824 
826  DLLLOCAL operator bool() const { return str != 0; }
827 
829  DLLLOCAL QoreString* release() { QoreString* rv = str; str = 0; return rv; }
830 };
831 
833 
846 private:
847  QoreString* str;
848  bool temp;
849 
851  DLLLOCAL TempEncodingHelper(const TempEncodingHelper& );
852 
854  DLLLOCAL TempEncodingHelper& operator=(const TempEncodingHelper& );
855 
857  DLLLOCAL void* operator new(size_t);
858 
860  DLLLOCAL void discard_intern() {
861  if (temp && str)
862  delete str;
863  }
864 
866 
871  DLLLOCAL void set_intern(const QoreString* s, const QoreEncoding* qe, ExceptionSink* xsink) {
872  if (s->getEncoding() != qe) {
873  str = s->convertEncoding(qe, xsink);
874  temp = true;
875  }
876  else {
877  str = const_cast<QoreString* >(s);
878  temp = false;
879  }
880  }
881 
882 public:
884 
889  DLLLOCAL TempEncodingHelper(const QoreString& s, const QoreEncoding* qe, ExceptionSink* xsink) {
890  set_intern(&s, qe, xsink);
891  }
892 
894 
899  DLLLOCAL TempEncodingHelper(const QoreString* s, const QoreEncoding* qe, ExceptionSink* xsink) {
900  set_intern(s, qe, xsink);
901  }
902 
904  DLLLOCAL TempEncodingHelper() : str(0), temp(false) {
905  }
906 
908  DLLLOCAL ~TempEncodingHelper() {
909  discard_intern();
910  }
911 
913 
922  DLLLOCAL int set(const QoreString* s, const QoreEncoding* qe, ExceptionSink* xsink) {
923  discard_intern();
924 
925  set_intern(s, qe, xsink);
926  return str != 0;
927  }
928 
930  DLLLOCAL bool is_temp() const {
931  return temp;
932  }
933 
935  DLLLOCAL void makeTemp() {
936  if (!temp && str) {
937  str = new QoreString(*str);
938  temp = true;
939  }
940  }
941 
943  DLLLOCAL const QoreString* operator->(){ return str; };
944 
946  DLLLOCAL const QoreString* operator*() { return str; };
947 
949 
952  DLLLOCAL operator bool() const { return str != 0; }
953 
955 
958  DLLLOCAL char* giveBuffer() {
959  if (!str)
960  return 0;
961  if (temp)
962  return str->giveBuffer();
963  return strdup(str->getBuffer());
964  }
965 };
966 
967 #endif
968 
DLLEXPORT char operator[](qore_offset_t pos) const
returns the byte (not character) at the given location; if the location is invalid, returns 0
DLLEXPORT void trim_trailing(const char *chars=0)
remove trailing whitespace or other characters
DLLEXPORT bool isDataPrintableAscii() const
returns true if the string is empty or only contains printable non-control ASCII characters (ie all c...
DLLEXPORT bool equalSoft(const QoreString &str, ExceptionSink *xsink) const
returns true if the strings are equal, false if not, if the character encodings are different...
DLLEXPORT QoreString()
creates an empty string and assigns the default encoding QCS_DEFAULT
DLLEXPORT BinaryNode * parseHex(ExceptionSink *xsink) const
parses the current string data as hexadecimal-encoded data and returns it as a BinaryNode pointer (ca...
DLLEXPORT bool equalPartialSoft(const QoreString &str, ExceptionSink *xsink) const
returns true if the beginning of the current string matches the argument string, false if not...
DLLEXPORT void setEncoding(const QoreEncoding *new_encoding)
changes the tagged encoding to the given encoding; does not affect the actual string buffer...
struct qore_string_private * priv
the private implementation of QoreString
Definition: QoreString.h:45
defines string encoding functions in Qore
Definition: QoreEncoding.h:72
DLLEXPORT qore_offset_t find(char c, qore_offset_t pos=0) const
returns the byte position of a character (byte) within the string or -1 if not found ...
DLLEXPORT int64 toBigInt() const
returns the value of the string as an int64
DLLEXPORT void concatDecodeUrl(const char *url)
concatenates a URL-decoded version of the c-string passed
DLLEXPORT void replaceAll(const char *old_str, const char *new_str)
replaces all occurences of the first string with the second string
DLLEXPORT const QoreEncoding * QCS_DEFAULT
the default encoding for the Qore library
DLLEXPORT qore_offset_t getByteOffset(qore_size_t i, ExceptionSink *xsink) const
returns the byte position of the given character position in the string or -1 if the string does not ...
DLLEXPORT void concatEscape(const QoreString *str, char c, char esc_char, ExceptionSink *xsink)
concatenates a string and escapes character c with esc_char (converts encodings if necessary) ...
DLLEXPORT void set(const char *str, const QoreEncoding *new_qorecharset=QCS_DEFAULT)
copies the c-string passed and sets the value of the string and its encoding
DLLEXPORT void trim_single_trailing(char c)
remove a single trailing character if present
DLLEXPORT bool equalPartialPath(const QoreString &str, ExceptionSink *xsink) const
returns true if the begining of the current string matches the argument string where either both stri...
DLLEXPORT bool equalPartial(const QoreString &str) const
returns true if the beginning of the current string matches the argument string, false if not...
DLLEXPORT unsigned int getUnicodePointFromUTF8(qore_offset_t offset=0) const
return Unicode code point for character offset, string must be UTF-8
DLLEXPORT qore_offset_t rfind(char c, qore_offset_t pos=-1) const
returns the last byte position of a character (byte) within the string or -1 if not found ...
DLLEXPORT void reserve(qore_size_t size)
ensures that at least the given size is available in the string; the string's contents are not affect...
DLLEXPORT bool equal(const QoreString &str) const
returns true if the strings are equal, false if not, if the character encodings are different...
DLLEXPORT void concatHex(const char *buf, qore_size_t size)
concatenates hexidecimal digits corresponding to the binary data passed up to byte "len" ...
DLLEXPORT QoreString * parseBase64ToString(ExceptionSink *xsink) const
parses the current string data as base64-encoded data and returns it as a QoreString pointer owned by...
DLLLOCAL bool is_temp() const
returns true if a temporary string is being managed
Definition: QoreString.h:930
Holds absolute and relative date/time values in Qore with precision to the microsecond.
Definition: DateTime.h:85
DLLEXPORT char * giveBuffer()
returns the character buffer and leaves the QoreString empty, the caller owns the memory returned (mu...
DLLEXPORT int sprintf(const char *fmt,...)
this will concatentate a formatted string to the existing string according to the format string and t...
The base class for all value and parse types in Qore expression trees.
Definition: AbstractQoreNode.h:47
DLLEXPORT void concatISO8601DateTime(const DateTime *d)
concatenates a DateTime value to a string in the format YYYYMMDDTHH:mm:SS <- where the "T" is a liter...
DLLEXPORT qore_size_t capacity() const
returns number of bytes allocated for the string's buffer, capacity is always >= size ...
size_t qore_size_t
used for sizes (same range as a pointer)
Definition: common.h:62
long qore_offset_t
used for offsets that could be negative
Definition: common.h:65
DLLEXPORT BinaryNode * parseBase64(ExceptionSink *xsink) const
parses the current string data as base64-encoded data and returns it as a BinaryNode pointer (caller ...
DLLEXPORT void tolwr()
converts the string to lower-case in place
DLLEXPORT void prepend(const char *str)
prepends the string given to the string, assumes character encoding is the same as the string's ...
DLLEXPORT void splice(qore_offset_t offset, ExceptionSink *xsink)
removes characters from the string starting at position "offset"
DLLEXPORT void concatUTF8FromUnicode(unsigned code)
append a UTF-8 character sequence from a unicode code point, assumes the string is tagged with QCS_UT...
DLLEXPORT unsigned int getUnicodePoint(qore_offset_t offset, ExceptionSink *xsink) const
return Unicode code point for the single character at the given character (not byte) offset in the st...
Qore's string type supported by the QoreEncoding class.
Definition: QoreString.h:42
DLLEXPORT void replace(qore_size_t offset, qore_size_t len, const char *str)
replaces bytes with the string passed
class used to hold a possibly temporary QoreString pointer, stack only, cannot be dynamically allocat...
Definition: QoreString.h:787
DLLEXPORT int insertch(char c, qore_size_t pos, unsigned times)
insert a character at a certain position in the string a number of times
DLLEXPORT void concat(const QoreString *str, ExceptionSink *xsink)
concatenates a string and converts encodings if necessary
DLLEXPORT int compare(const QoreString *str) const
compares two strings without converting encodings (if the encodings do not match then "this" is deeme...
DLLEXPORT qore_offset_t rindex(const QoreString &needle, qore_offset_t pos, ExceptionSink *xsink) const
returns the character position of a substring searching in reverse from a given position or -1 if not...
DLLEXPORT qore_offset_t index(const QoreString &needle, qore_offset_t pos, ExceptionSink *xsink) const
returns the character position of a substring within the string or -1 if not found ...
DLLEXPORT QoreString * convertEncoding(const QoreEncoding *nccs, ExceptionSink *xsink) const
converts the encoding of the string to the specified encoding, returns 0 if an error occurs...
DLLEXPORT void toupr()
converts the string to upper-case in place
DLLEXPORT qore_size_t length() const
returns the number of characters (not bytes) in the string
DLLLOCAL QoreString * release()
releases the QoreString pointer being managed and sets the internal pointer to 0
Definition: QoreString.h:829
DLLEXPORT bool isDataAscii() const
returns true if the string is empty or has no characters with the high bit set (ie all characters < 1...
DLLEXPORT void concatBase64(const char *buf, qore_size_t size)
concatenates the base64-encoded version of the binary data passed
DLLEXPORT QoreString * reverse() const
return a Qorestring with the characters reversed
use this class to manage strings where the character encoding must be specified and may be different ...
Definition: QoreString.h:845
DLLEXPORT const QoreEncoding * getEncoding() const
returns the encoding for the string
DLLEXPORT unsigned int getUnicodePointFromBytePos(qore_size_t offset, unsigned &len, ExceptionSink *xsink) const
return Unicode code point for the given byte offset
DLLEXPORT int insert(const char *str, qore_size_t pos)
inserts a character string at a certain position in the string
DLLEXPORT void concatAndHTMLEncode(const char *str)
concatenates HTML-encoded version of the c-string passed
DLLEXPORT QoreString * copy() const
returns an exact copy of the string
container for holding Qore-language exception information and also for registering a "thread_exit" ca...
Definition: ExceptionSink.h:35
DLLEXPORT bool empty() const
returns true if the string is empty, false if not
DLLLOCAL const QoreString * operator*()
returns the string being managed
Definition: QoreString.h:946
DLLLOCAL ~TempString()
deletes the QoreString pointer being managed
Definition: QoreString.h:815
DLLLOCAL TempEncodingHelper(const QoreString &s, const QoreEncoding *qe, ExceptionSink *xsink)
converts the given string to the required encoding if necessary
Definition: QoreString.h:889
DLLEXPORT bool operator==(const QoreString &other) const
returns true if the other string is equal to this string (encodings also must be equal) ...
DLLEXPORT qore_offset_t bindex(const QoreString &needle, qore_offset_t pos) const
returns the byte position of a substring within the string or -1 if not found
DLLEXPORT int concatEncodeUrl(ExceptionSink *xsink, const QoreString &url, bool encode_all=false)
concatenates a URL-encoded version of the c-string passed
DLLEXPORT void trim_leading(const char *chars=0)
remove leading whitespace or other characters
DLLEXPORT void replaceChar(qore_size_t offset, char c)
replaces a byte with the byte passed
DLLEXPORT void addch(char c, unsigned times)
append a character to the string a number of times
DLLLOCAL TempString(QoreString *s)
populates the object with the QoreString pointer to be managed
Definition: QoreString.h:810
DLLLOCAL void makeTemp()
ensures that the object is holding a temporary value
Definition: QoreString.h:935
DLLEXPORT void terminate(qore_size_t size)
terminates the string at byte position "size", the string is reallocated if necessary ...
DLLLOCAL TempEncodingHelper()
creates an empty TempEncodingHelperObject that may be initialized with TempEncodingHelper::set() late...
Definition: QoreString.h:904
DLLLOCAL ~TempEncodingHelper()
deletes any temporary string being managed by the object
Definition: QoreString.h:908
DLLEXPORT void trim(const char *chars=0)
remove leading and trailing whitespace or other characters
DLLLOCAL QoreString * operator->()
returns the QoreString pointer being managed
Definition: QoreString.h:820
DLLEXPORT qore_size_t strlen() const
returns number of bytes in the string (not including the null pointer)
DLLEXPORT int concatUnicode(unsigned code, ExceptionSink *xsink)
append a character sequence from a unicode code point (returns 0 for OK, -1 for exception) ...
DLLEXPORT QoreString & operator+=(const char *str)
concatenates the characters to the string; assumes the string to be concatenated is already in the ch...
DLLLOCAL TempEncodingHelper(const QoreString *s, const QoreEncoding *qe, ExceptionSink *xsink)
converts the given string to the required encoding if necessary
Definition: QoreString.h:899
DLLEXPORT qore_size_t chomp()
removes a single \n\r or \n from the end of the string and returns the number of characters removed ...
DLLEXPORT ~QoreString()
frees any memory allocated by the string
DLLEXPORT void takeAndTerminate(char *str, qore_size_t size)
takes ownership of the character pointer passed and assigns it to the string (frees memory previously...
DLLLOCAL TempString(const QoreEncoding *enc)
populates the object with a new QoreString in a specific encoding that this object will manage ...
Definition: QoreString.h:806
DLLEXPORT qore_offset_t brindex(const QoreString &needle, qore_offset_t pos) const
returns the byte position of a substring within the string searching in reverse from a given position...
DLLEXPORT QoreString * extract(qore_offset_t offset, ExceptionSink *xsink)
removes characters from the string starting at position "offset" and returns a string of the characte...
DLLEXPORT void allocate(unsigned requested_size)
Ensure the internal buffer has at least expected size in bytes.
DLLLOCAL char * giveBuffer()
returns a char pointer of the string, the caller owns the pointer returned (it must be manually freed...
Definition: QoreString.h:958
DLLEXPORT void reset()
reset string to zero length; memory is deallocated; string encoding is reset to QCS_DEFAULT ...
DLLEXPORT void clear()
reset string to zero length; memory is not deallocated; string encoding does not change ...
DLLLOCAL QoreString * operator*()
returns the QoreString pointer being managed
Definition: QoreString.h:823
DLLEXPORT void concatAndHTMLDecode(const QoreString *str)
concatenates HTML-decoded version of the c-string passed
DLLEXPORT void trim_single_leading(char c)
remove a single leading character if present
DLLLOCAL int set(const QoreString *s, const QoreEncoding *qe, ExceptionSink *xsink)
discards any current state and sets and converts (if necessary) a new string to the desired encoding ...
Definition: QoreString.h:922
DLLEXPORT int vsprintf(const char *fmt, va_list args)
this will concatentate a formatted string to the existing string according to the format string and t...
DLLEXPORT QoreString * substr(qore_offset_t offset, ExceptionSink *xsink) const
returns a new string consisting of all the characters from the current string starting with character...
DLLLOCAL const QoreString * operator->()
returns the string being managed
Definition: QoreString.h:943
DLLEXPORT qore_size_t size() const
returns number of bytes in the string (not including the null pointer)
DLLEXPORT void take(char *str)
takes ownership of the character pointer passed and assigns it to the string (frees memory previously...
DLLLOCAL TempString()
populates the object with a new QoreString that this object will manage
Definition: QoreString.h:802
DLLEXPORT QoreString & operator=(const QoreString &other)
assigns the value of one string to another
holds arbitrary binary data
Definition: BinaryNode.h:33
DLLEXPORT int compareSoft(const QoreString *str, ExceptionSink *xsink) const
compares the string with another string, performing character set encoding conversion if necessary ...
DLLEXPORT const char * getBuffer() const
returns the string's buffer; this data should not be changed