Qore Programming Language 0.8.8

- Main Page
- Related Pages
- Modules
- Classes
- Files

- File List
- File Members

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 DLLEXPORT void concatDecodeUrl(const char* url);
154
156 DLLEXPORT void concatEscape(const QoreString* str, char c, char esc_char, ExceptionSink* xsink);
157
159 DLLEXPORT void concatEscape(const char* str, char c, char esc_char = '\\');
160
162 DLLEXPORT void concatAndHTMLEncode(const QoreString* , ExceptionSink* xsink);
163
165 DLLEXPORT void concat(const QoreString* str, ExceptionSink* xsink);
166
168
174 DLLEXPORT int concat(const QoreString& str, qore_offset_t pos, ExceptionSink* xsink);
175
177
184 DLLEXPORT int concat(const QoreString& str, qore_offset_t pos, qore_offset_t len, ExceptionSink* xsink);
185
187
192 DLLEXPORT void concat(const QoreString* str, qore_size_t size, ExceptionSink* xsink);
193
195 DLLEXPORT void concatBase64(const char* buf, qore_size_t size);
196
198 DLLEXPORT void concatBase64(const BinaryNode* bin);
199
201 DLLEXPORT void concatBase64(const QoreString* str);
202
204 DLLEXPORT void concatBase64(const char* buf, qore_size_t size, qore_size_t maxlinelen);
205
207 DLLEXPORT void concatBase64(const BinaryNode* bin, qore_size_t maxlinelen);
208
210 DLLEXPORT void concatBase64(const QoreString* str, qore_size_t maxlinelen);
211
213
217 DLLEXPORT BinaryNode* parseBase64(ExceptionSink* xsink) const;
218
220
224 DLLEXPORT QoreString* parseBase64ToString(ExceptionSink* xsink) const;
225
227
232 DLLEXPORT QoreString* parseBase64ToString(const QoreEncoding* enc, ExceptionSink* xsink) const;
233
235 DLLEXPORT void concatHex(const char* buf, qore_size_t size);
236
238 DLLEXPORT void concatHex(const BinaryNode* bin);
239
241 DLLEXPORT void concatHex(const QoreString* str);
242
244
248 DLLEXPORT BinaryNode* parseHex(ExceptionSink* xsink) const;
249
251 DLLEXPORT void concat(const DateTime* d);
252
254 DLLEXPORT void concatISO8601DateTime(const DateTime* d);
255
257 DLLEXPORT void concat(const char* str);
258
260 DLLEXPORT void concat(const std::string& str);
261
263 DLLEXPORT void concat(const char* str, qore_size_t size);
264
266 DLLEXPORT void concat(const char c);
267
269
274 DLLEXPORT int compareSoft(const QoreString* str, ExceptionSink* xsink) const;
275
277
281 DLLEXPORT int compare(const QoreString* str) const;
282
284
288 DLLEXPORT int compare(const char* str) const;
289
291
293 DLLEXPORT bool equal(const QoreString& str) const;
294
296
298 DLLEXPORT bool equal(const char* str) const;
299
301
307 DLLEXPORT bool equalSoft(const QoreString& str, ExceptionSink* xsink) const;
308
310
312 DLLEXPORT bool equalPartial(const QoreString& str) const;
313
315
317 DLLEXPORT bool equalPartial(const char* str) const;
318
320
326 DLLEXPORT bool equalPartialSoft(const QoreString& str, ExceptionSink* xsink) const;
327
329
335 DLLEXPORT bool equalPartialPath(const QoreString& str, ExceptionSink* xsink) const;
336
338 DLLEXPORT void terminate(qore_size_t size);
339
341
343 DLLEXPORT void reserve(qore_size_t size);
344
346
348 DLLEXPORT int sprintf(const char* fmt, ...);
349
351
353 DLLEXPORT int vsprintf(const char* fmt, va_list args);
354
356
358 DLLEXPORT void take(char* str);
359
361 DLLEXPORT void take(char* str, const QoreEncoding* enc);
363
364 DLLEXPORT void take(char* str, qore_size_t size);
365
367 DLLEXPORT void take(char* str, qore_size_t size, const QoreEncoding* enc);
368
370 DLLEXPORT void takeAndTerminate(char* str, qore_size_t size);
371
373 DLLEXPORT void takeAndTerminate(char* str, qore_size_t size, const QoreEncoding* enc);
374
376
381 DLLEXPORT QoreString* convertEncoding(const QoreEncoding* nccs, ExceptionSink* xsink) const;
382
384
387 DLLEXPORT char* giveBuffer();
388
390 DLLEXPORT void clear();
391
393
395 DLLEXPORT void reset();
396
398
400 DLLEXPORT void replaceAll(const char* old_str, const char* new_str);
401
403
405 DLLEXPORT void replace(qore_size_t offset, qore_size_t len, const char* str);
406
408
413 DLLEXPORT void replace(qore_size_t offset, qore_size_t len, const QoreString* str);
414
416
418 DLLEXPORT void replace(qore_size_t offset, qore_size_t len, const QoreString* str, ExceptionSink* xsink);
419
421
423 DLLEXPORT void replaceChar(qore_size_t offset, char c);
424
426
430 DLLEXPORT void splice(qore_offset_t offset, ExceptionSink* xsink);
431
433
438 DLLEXPORT void splice(qore_offset_t offset, qore_offset_t length, ExceptionSink* xsink);
439
441
447 DLLEXPORT void splice(qore_offset_t offset, qore_offset_t length, const AbstractQoreNode* strn, ExceptionSink* xsink);
448
450
456 DLLEXPORT void splice(qore_offset_t offset, qore_offset_t length, const QoreString& str, ExceptionSink* xsink);
457
459
464 DLLEXPORT QoreString* extract(qore_offset_t offset, ExceptionSink* xsink);
465
467
473 DLLEXPORT QoreString* extract(qore_offset_t offset, qore_offset_t length, ExceptionSink* xsink);
474
476
483 DLLEXPORT QoreString* extract(qore_offset_t offset, qore_offset_t length, const AbstractQoreNode* strn, ExceptionSink* xsink);
484
486
491 DLLEXPORT QoreString* substr(qore_offset_t offset, ExceptionSink* xsink) const;
492
494
500 DLLEXPORT QoreString* substr(qore_offset_t offset, qore_offset_t length, ExceptionSink* xsink) const;
501
503 DLLEXPORT qore_size_t chomp();
504
506 DLLEXPORT const QoreEncoding* getEncoding() const;
507
509 DLLEXPORT QoreString* copy() const;
510
512
514 DLLEXPORT void tolwr();
515
517
519 DLLEXPORT void toupr();
520
522 DLLEXPORT qore_size_t strlen() const;
523
525 DLLEXPORT qore_size_t size() const;
526
528 DLLEXPORT qore_size_t capacity() const;
529
531 DLLEXPORT const char* getBuffer() const;
532
534
536 DLLEXPORT void allocate(unsigned requested_size);
537
539
545 DLLEXPORT int insertch(char c, qore_size_t pos, unsigned times);
546
548
553 DLLEXPORT int insert(const char* str, qore_size_t pos);
554
556 DLLEXPORT void addch(char c, unsigned times);
557
559
565 DLLEXPORT void concatUTF8FromUnicode(unsigned code);
566
568
572 DLLEXPORT int concatUnicode(unsigned code, ExceptionSink* xsink);
573
575
579 DLLEXPORT int concatUnicode(unsigned code);
580
582
585 DLLEXPORT QoreString* reverse() const;
586
588 DLLEXPORT void trim_trailing(const char* chars = 0);
589
591 DLLEXPORT void trim_leading(const char* chars = 0);
592
594 DLLEXPORT void trim(const char* chars = 0);
595
597 DLLEXPORT void trim_trailing(char c);
598
600 DLLEXPORT void trim_single_trailing(char c);
601
603 DLLEXPORT void trim_leading(char c);
604
606 DLLEXPORT void trim_single_leading(char c);
607
609 DLLEXPORT void trim(char c);
610
612
616 DLLEXPORT unsigned int getUnicodePointFromUTF8(qore_offset_t offset = 0) const;
617
619
626 DLLEXPORT unsigned int getUnicodePoint(qore_offset_t offset, ExceptionSink* xsink) const;
627
629
636 DLLEXPORT unsigned int getUnicodePointFromBytePos(qore_size_t offset, unsigned& len, ExceptionSink* xsink) const;
637
639 DLLEXPORT void prepend(const char* str);
640
642 DLLEXPORT void prepend(const char* str, qore_size_t size);
643
645 DLLEXPORT QoreString& operator=(const QoreString& other);
646
648 DLLEXPORT QoreString& operator=(const char* other);
649
651 DLLEXPORT QoreString& operator=(const std::string& other);
652
654 DLLEXPORT bool operator==(const QoreString& other) const;
655
657 DLLEXPORT bool operator==(const std::string& other) const;
658
660 DLLEXPORT bool operator==(const char* other) const;
661
663
668 DLLEXPORT char operator[](qore_offset_t pos) const;
669
671 DLLEXPORT QoreString& operator+=(const char* str);
672
674 DLLEXPORT QoreString& operator+=(const std::string& str);
675
677 DLLEXPORT bool empty() const;
678
680 DLLEXPORT qore_offset_t index(const QoreString& needle, qore_offset_t pos, ExceptionSink* xsink) const;
681
683 DLLEXPORT qore_offset_t bindex(const QoreString& needle, qore_offset_t pos) const;
684
686 DLLEXPORT qore_offset_t bindex(const char* needle, qore_offset_t pos) const;
687
689 DLLEXPORT qore_offset_t bindex(const std::string& needle, qore_offset_t pos) const;
690
692
698 DLLEXPORT qore_offset_t rindex(const QoreString& needle, qore_offset_t pos, ExceptionSink* xsink) const;
699
701 DLLEXPORT qore_offset_t brindex(const QoreString& needle, qore_offset_t pos) const;
702
704 DLLEXPORT qore_offset_t brindex(const char* needle, qore_offset_t pos) const;
705
707 DLLEXPORT qore_offset_t brindex(const std::string& needle, qore_offset_t pos) const;
708
710 DLLEXPORT qore_offset_t find(char c, qore_offset_t pos = 0) const;
711
713 DLLEXPORT qore_offset_t rfind(char c, qore_offset_t pos = -1) const;
714
716
718 DLLEXPORT bool isDataPrintableAscii() const;
719
721
723 DLLEXPORT bool isDataAscii() const;
724
726 DLLEXPORT int64 toBigInt() const;
727
729
734 DLLEXPORT qore_offset_t getByteOffset(qore_size_t i, ExceptionSink* xsink) const;
735
736 // concatenates a qorestring without converting encodings - internal only
737 DLLLOCAL void concat(const QoreString* str);
738
739 // private constructor
740 DLLLOCAL QoreString(struct qore_string_private* p);
741 };
742
743 DLLEXPORT QoreString* checkEncoding(const QoreString* str, const QoreEncoding* enc, ExceptionSink* xsink);
744
745 class QoreStringMaker : public QoreString {
746 private:
748 DLLLOCAL QoreStringMaker(const QoreStringMaker& str);
749
751 DLLLOCAL QoreStringMaker& operator=(const QoreStringMaker&);
752
753 public:
755
757 DLLEXPORT QoreStringMaker(const char* fmt, ...);
758
760
762 DLLEXPORT QoreStringMaker(const QoreEncoding* enc, const char* fmt, ...);
763 };
764
766
775 class TempString {
776 private:
777 QoreString* str;
778
780 TempString(const TempString& );
781
783 TempString& operator=(const TempString& );
784
786 void* operator new(size_t);
787
788 public:
790 DLLLOCAL TempString() : str(new QoreString) {
791 }
792
794 DLLLOCAL TempString(const QoreEncoding* enc) : str(new QoreString(enc)) {
795 }
796
798 DLLLOCAL TempString(QoreString* s) {
799 str = s;
800 }
801
803 DLLLOCAL ~TempString() {
804 delete str;
805 }
806
808 DLLLOCAL QoreString* operator->(){ return str; };
809
811 DLLLOCAL QoreString* operator*() { return str; };
812
814 DLLLOCAL operator bool() const { return str != 0; }
815
817 DLLLOCAL QoreString* release() { QoreString* rv = str; str = 0; return rv; }
818 };
819
821
833 class TempEncodingHelper {
834 private:
835 QoreString* str;
836 bool temp;
837
839 DLLLOCAL TempEncodingHelper(const TempEncodingHelper& );
840
842 DLLLOCAL TempEncodingHelper& operator=(const TempEncodingHelper& );
843
845 DLLLOCAL void* operator new(size_t);
846
848 DLLLOCAL void discard_intern() {
849 if (temp && str)
850 delete str;
851 }
852
854
859 DLLLOCAL void set_intern(const QoreString* s, const QoreEncoding* qe, ExceptionSink* xsink) {
860 if (s->getEncoding() != qe) {
861 str = s->convertEncoding(qe, xsink);
862 temp = true;
863 }
864 else {
865 str = const_cast<QoreString* >(s);
866 temp = false;
867 }
868 }
869
870 public:
872
877 DLLLOCAL TempEncodingHelper(const QoreString& s, const QoreEncoding* qe, ExceptionSink* xsink) {
878 set_intern(&s, qe, xsink);
879 }
880
882
887 DLLLOCAL TempEncodingHelper(const QoreString* s, const QoreEncoding* qe, ExceptionSink* xsink) {
888 set_intern(s, qe, xsink);
889 }
890
892 DLLLOCAL TempEncodingHelper() : str(0), temp(false) {
893 }
894
896 DLLLOCAL ~TempEncodingHelper() {
897 discard_intern();
898 }
899
901
910 DLLLOCAL int set(const QoreString* s, const QoreEncoding* qe, ExceptionSink* xsink) {
911 discard_intern();
912
913 set_intern(s, qe, xsink);
914 return str != 0;
915 }
916
918 DLLLOCAL bool is_temp() const {
919 return temp;
920 }
921
923 DLLLOCAL const QoreString* operator->(){ return str; };
924
926 DLLLOCAL const QoreString* operator*() { return str; };
927
929
932 DLLLOCAL operator bool() const { return str != 0; }
933
935
938 DLLLOCAL char* giveBuffer() {
939 if (!str)
940 return 0;
941 if (temp)
942 return str->giveBuffer();
943 return strdup(str->getBuffer());
944 }
945 };
946
947 #endif
948
QoreString::operator[]
DLLEXPORT char operator[](qore_offset_t pos) const
returns the byte (not character) at the given location; if the location is invalid, returns 0
QoreString::trim_trailing
DLLEXPORT void trim_trailing(const char *chars=0)
remove trailing whitespace or other characters
QoreString::isDataPrintableAscii
DLLEXPORT bool isDataPrintableAscii() const
returns true if the string is empty or only contains printable non-control ASCII characters (ie all c...
QoreString::equalSoft
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...
QoreString::QoreString
DLLEXPORT QoreString()
creates an empty string and assigns the default encoding QCS_DEFAULT
QoreString::parseHex
DLLEXPORT BinaryNode * parseHex(ExceptionSink *xsink) const
parses the current string data as hexadecimal-encoded data and returns it as a BinaryNode pointer (ca...
QoreString::equalPartialSoft
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...
QoreString::setEncoding
DLLEXPORT void setEncoding(const QoreEncoding *new_encoding)
changes the tagged encoding to the given encoding; does not affect the actual string buffer...
QoreString::priv
struct qore_string_private * priv
the private implementation of QoreString
Definition: QoreString.h:45
QoreEncoding
defines string encoding functions in Qore
Definition: QoreEncoding.h:72
QoreString::find
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 ...
QoreString::toBigInt
DLLEXPORT int64 toBigInt() const
returns the value of the string as an int64
QoreString::concatDecodeUrl
DLLEXPORT void concatDecodeUrl(const char *url)
concatenates a URL-decoded version of the c-string passed
QoreString::replaceAll
DLLEXPORT void replaceAll(const char *old_str, const char *new_str)
replaces all occurences of the first string with the second string
QCS_DEFAULT
DLLEXPORT const QoreEncoding * QCS_DEFAULT
the default encoding for the Qore library
QoreString::getByteOffset
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 ...
QoreString::concatEscape
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) ...
QoreString::set
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
QoreString::trim_single_trailing
DLLEXPORT void trim_single_trailing(char c)
remove a single trailing character if present
QoreString::equalPartialPath
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...
QoreString::equalPartial
DLLEXPORT bool equalPartial(const QoreString &str) const
returns true if the beginning of the current string matches the argument string, false if not...
QoreString::getUnicodePointFromUTF8
DLLEXPORT unsigned int getUnicodePointFromUTF8(qore_offset_t offset=0) const
return Unicode code point for character offset, string must be UTF-8
QoreString::rfind
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 ...
QoreString::reserve
DLLEXPORT void reserve(qore_size_t size)
ensures that at least the given size is available in the string; the string&#39;s contents are not affect...
QoreString::equal
DLLEXPORT bool equal(const QoreString &str) const
returns true if the strings are equal, false if not, if the character encodings are different...
QoreString::concatHex
DLLEXPORT void concatHex(const char *buf, qore_size_t size)
concatenates hexidecimal digits corresponding to the binary data passed up to byte &quot;len&quot; ...
QoreString::parseBase64ToString
DLLEXPORT QoreString * parseBase64ToString(ExceptionSink *xsink) const
parses the current string data as base64-encoded data and returns it as a QoreString pointer owned by...
TempEncodingHelper::is_temp
DLLLOCAL bool is_temp() const
returns true if a temporary string is being managed
Definition: QoreString.h:918
DateTime
Holds absolute and relative date/time values in Qore with precision to the microsecond.
Definition: DateTime.h:85
QoreString::giveBuffer
DLLEXPORT char * giveBuffer()
returns the character buffer and leaves the QoreString empty, the caller owns the memory returned (mu...
QoreString::sprintf
DLLEXPORT int sprintf(const char *fmt,...)
this will concatentate a formatted string to the existing string according to the format string and t...
AbstractQoreNode
The base class for all value and parse types in Qore expression trees.
Definition: AbstractQoreNode.h:47
QoreString::concatISO8601DateTime
DLLEXPORT void concatISO8601DateTime(const DateTime *d)
concatenates a DateTime value to a string in the format YYYYMMDDTHH:mm:SS &lt;- where the &quot;T&quot; is a liter...
QoreString::capacity
DLLEXPORT qore_size_t capacity() const
returns number of bytes allocated for the string&#39;s buffer, capacity is always &gt;= size ...
qore_size_t
size_t qore_size_t
used for sizes (same range as a pointer)
Definition: common.h:61
qore_offset_t
long qore_offset_t
used for offsets that could be negative
Definition: common.h:64
QoreString::parseBase64
DLLEXPORT BinaryNode * parseBase64(ExceptionSink *xsink) const
parses the current string data as base64-encoded data and returns it as a BinaryNode pointer (caller ...
QoreString::tolwr
DLLEXPORT void tolwr()
converts the string to lower-case in place
QoreString::prepend
DLLEXPORT void prepend(const char *str)
prepends the string given to the string, assumes character encoding is the same as the string&#39;s ...
QoreString::splice
DLLEXPORT void splice(qore_offset_t offset, ExceptionSink *xsink)
removes characters from the string starting at position &quot;offset&quot;
QoreString::concatUTF8FromUnicode
DLLEXPORT void concatUTF8FromUnicode(unsigned code)
append a UTF-8 character sequence from a unicode code point, assumes the string is tagged with QCS_UT...
QoreString::getUnicodePoint
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...
QoreString
Qore&#39;s string type supported by the QoreEncoding class.
Definition: QoreString.h:42
QoreString::replace
DLLEXPORT void replace(qore_size_t offset, qore_size_t len, const char *str)
replaces bytes with the string passed
TempString
class used to hold a possibly temporary QoreString pointer, stack only, cannot be dynamically allocat...
Definition: QoreString.h:775
QoreString::insertch
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
QoreString::concat
DLLEXPORT void concat(const QoreString *str, ExceptionSink *xsink)
concatenates a string and converts encodings if necessary
QoreString::compare
DLLEXPORT int compare(const QoreString *str) const
compares two strings without converting encodings (if the encodings do not match then &quot;this&quot; is deeme...
QoreString::rindex
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...
QoreString::index
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 ...
QoreString::convertEncoding
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...
QoreString::toupr
DLLEXPORT void toupr()
converts the string to upper-case in place
QoreString::length
DLLEXPORT qore_size_t length() const
returns the number of characters (not bytes) in the string
TempString::release
DLLLOCAL QoreString * release()
releases the QoreString pointer being managed and sets the internal pointer to 0
Definition: QoreString.h:817
QoreString::isDataAscii
DLLEXPORT bool isDataAscii() const
returns true if the string is empty or has no characters with the high bit set (ie all characters &lt; 1...
QoreString::concatBase64
DLLEXPORT void concatBase64(const char *buf, qore_size_t size)
concatenates the base64-encoded version of the binary data passed
QoreString::reverse
DLLEXPORT QoreString * reverse() const
return a Qorestring with the characters reversed
TempEncodingHelper
use this class to manage strings where the character encoding must be specified and may be different ...
Definition: QoreString.h:833
QoreString::getEncoding
DLLEXPORT const QoreEncoding * getEncoding() const
returns the encoding for the string
QoreString::getUnicodePointFromBytePos
DLLEXPORT unsigned int getUnicodePointFromBytePos(qore_size_t offset, unsigned &len, ExceptionSink *xsink) const
return Unicode code point for the given byte offset
QoreString::insert
DLLEXPORT int insert(const char *str, qore_size_t pos)
inserts a character string at a certain position in the string
QoreString::concatAndHTMLEncode
DLLEXPORT void concatAndHTMLEncode(const char *str)
concatenates HTML-encoded version of the c-string passed
QoreString::copy
DLLEXPORT QoreString * copy() const
returns an exact copy of the string
ExceptionSink
container for holding Qore-language exception information and also for registering a &quot;thread_exit&quot; ca...
Definition: ExceptionSink.h:35
QoreString::empty
DLLEXPORT bool empty() const
returns true if the string is empty, false if not
TempEncodingHelper::operator*
DLLLOCAL const QoreString * operator*()
returns the string being managed
Definition: QoreString.h:926
TempString::~TempString
DLLLOCAL ~TempString()
deletes the QoreString pointer being managed
Definition: QoreString.h:803
TempEncodingHelper::TempEncodingHelper
DLLLOCAL TempEncodingHelper(const QoreString &s, const QoreEncoding *qe, ExceptionSink *xsink)
converts the given string to the required encoding if necessary
Definition: QoreString.h:877
QoreString::operator==
DLLEXPORT bool operator==(const QoreString &other) const
returns true if the other string is equal to this string (encodings also must be equal) ...
QoreString::bindex
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
QoreString::trim_leading
DLLEXPORT void trim_leading(const char *chars=0)
remove leading whitespace or other characters
QoreString::replaceChar
DLLEXPORT void replaceChar(qore_size_t offset, char c)
replaces a byte with the byte passed
QoreString::addch
DLLEXPORT void addch(char c, unsigned times)
append a character to the string a number of times
TempString::TempString
DLLLOCAL TempString(QoreString *s)
populates the object with the QoreString pointer to be managed
Definition: QoreString.h:798
QoreString::terminate
DLLEXPORT void terminate(qore_size_t size)
terminates the string at byte position &quot;size&quot;, the string is reallocated if necessary ...
TempEncodingHelper::TempEncodingHelper
DLLLOCAL TempEncodingHelper()
creates an empty TempEncodingHelperObject that may be initialized with TempEncodingHelper::set() late...
Definition: QoreString.h:892
TempEncodingHelper::~TempEncodingHelper
DLLLOCAL ~TempEncodingHelper()
deletes any temporary string being managed by the object
Definition: QoreString.h:896
QoreString::trim
DLLEXPORT void trim(const char *chars=0)
remove leading and trailing whitespace or other characters
TempString::operator->
DLLLOCAL QoreString * operator->()
returns the QoreString pointer being managed
Definition: QoreString.h:808
QoreString::strlen
DLLEXPORT qore_size_t strlen() const
returns number of bytes in the string (not including the null pointer)
QoreString::concatUnicode
DLLEXPORT int concatUnicode(unsigned code, ExceptionSink *xsink)
append a character sequence from a unicode code point (returns 0 for OK, -1 for exception) ...
QoreString::operator+=
DLLEXPORT QoreString & operator+=(const char *str)
concatenates the characters to the string; assumes the string to be concatenated is already in the ch...
TempEncodingHelper::TempEncodingHelper
DLLLOCAL TempEncodingHelper(const QoreString *s, const QoreEncoding *qe, ExceptionSink *xsink)
converts the given string to the required encoding if necessary
Definition: QoreString.h:887
QoreString::chomp
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 ...
QoreString::~QoreString
DLLEXPORT ~QoreString()
frees any memory allocated by the string
QoreString::takeAndTerminate
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...
TempString::TempString
DLLLOCAL TempString(const QoreEncoding *enc)
populates the object with a new QoreString in a specific encoding that this object will manage ...
Definition: QoreString.h:794
QoreString::brindex
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...
QoreString::extract
DLLEXPORT QoreString * extract(qore_offset_t offset, ExceptionSink *xsink)
removes characters from the string starting at position &quot;offset&quot; and returns a string of the characte...
QoreString::allocate
DLLEXPORT void allocate(unsigned requested_size)
Ensure the internal buffer has at least expected size in bytes.
TempEncodingHelper::giveBuffer
DLLLOCAL char * giveBuffer()
returns a char pointer of the string, the caller owns the pointer returned (it must be manually freed...
Definition: QoreString.h:938
QoreString::reset
DLLEXPORT void reset()
reset string to zero length; memory is deallocated; string encoding is reset to QCS_DEFAULT ...
QoreString::clear
DLLEXPORT void clear()
reset string to zero length; memory is not deallocated; string encoding does not change ...
TempString::operator*
DLLLOCAL QoreString * operator*()
returns the QoreString pointer being managed
Definition: QoreString.h:811
QoreString::concatAndHTMLDecode
DLLEXPORT void concatAndHTMLDecode(const QoreString *str)
concatenates HTML-decoded version of the c-string passed
QoreString::trim_single_leading
DLLEXPORT void trim_single_leading(char c)
remove a single leading character if present
TempEncodingHelper::set
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:910
QoreString::vsprintf
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...
QoreString::substr
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...
TempEncodingHelper::operator->
DLLLOCAL const QoreString * operator->()
returns the string being managed
Definition: QoreString.h:923
QoreString::size
DLLEXPORT qore_size_t size() const
returns number of bytes in the string (not including the null pointer)
QoreString::take
DLLEXPORT void take(char *str)
takes ownership of the character pointer passed and assigns it to the string (frees memory previously...
TempString::TempString
DLLLOCAL TempString()
populates the object with a new QoreString that this object will manage
Definition: QoreString.h:790
QoreString::operator=
DLLEXPORT QoreString & operator=(const QoreString &other)
assigns the value of one string to another
BinaryNode
holds arbitrary binary data
Definition: BinaryNode.h:33
QoreString::compareSoft
DLLEXPORT int compareSoft(const QoreString *str, ExceptionSink *xsink) const
compares the string with another string, performing character set encoding conversion if necessary ...
QoreString::getBuffer
DLLEXPORT const char * getBuffer() const
returns the string&#39;s buffer; this data should not be changed