📄 str.ps
字号:
(Left, left) 108 133 T(Leftmost substring) 216 133 T(Len) 108 116 T(Length of the string) 216 116 T(Length, length) 108 99 T(Length of the string) 216 99 T(match) 108 82 T(Match a regular expression) 216 82 TFMENDPAGE%%EndPage: "2" 2%%Page: "3" 3612 792 0 FMBEGINPAGE[0 0 0 1 0 0 0][ 0 1 1 0 1 0 0][ 1 0 1 0 0 1 0][ 1 1 0 0 0 0 1][ 1 0 0 0 0 1 1][ 0 1 0 0 1 0 1][ 0 0 1 0 1 1 0] 7 FrameSetSepColorsFrameNoSep0 0 0 1 0 0 0 K0 0 0 1 0 0 0 K0 0 0 1 0 0 0 K0 0 0 1 0 0 0 K72 746 540 756 R7 X0 0 0 1 0 0 0 KV72 18 540 45 RV72 34.99 540 45 C0 0 0 1 0 0 0 K0 0 0 1 0 0 0 K72 34.99 540 45 R7 X0 0 0 1 0 0 0 KV72 43.99 541.01 43.99 2 LV1 H2 Z0 XN0 0 612 792 C0 12 Q0 X0 0 0 1 0 0 0 K(String++ Version 3.1) 255.07 28.33 T(3) 534 28.33 T72 72 540 720 R7 XV0 X(Mid, mid) 108 712 T(Middle substring) 216 712 T(Minimize) 108 695 T(Minimize the buffer space) 216 695 T(ptr) 108 678 T(Return the char* of a string) 216 678 T(Replace) 108 661 T(Replace a substring) 216 661 T(Right) 108 644 T(Rightmost substring) 216 644 T(SetCaseSensitivity) 108 627 T(Set the case sensitivity for comparisons) 216 627 T(SetCompare) 108 610 T(Set the comparison function pointer) 216 610 T(SetFloatFormat) 108 593 T(Set the floating point format specifier) 216 593 T(SetIncLength) 108 576 T(Set the buffer increment length) 216 576 T(SetMinLength) 108 559 T(Set the buffer minimum length) 216 559 T(SetSize) 108 542 T(Set the buffer size) 216 542 T(SetToLower) 108 525 T(Set the toLower function pointer) 216 525 T(SetToUpper) 108 508 T(Set the toUpper function pointer) 216 508 T(Split, split) 108 491 T(Split a string on a field separator) 216 491 T(Sub, sub) 108 474 T(Leftmost substitution) 216 474 T(SubStr, substr) 108 457 T(Random substring) 216 457 T(toLower, tolower) 108 440 T(Case conversion) 216 440 T(toUpper, toupper) 108 423 T(Case conversion) 216 423 T(Trim, trim) 108 406 T(Remove outer whitespace) 216 406 T(Value) 108 389 T(Numeric value of a numeric string) 216 389 T1 14 Q(String Buffers) 72 355.67 T0 12 Q0.09 (The contents of a string is stored in a character array. Although the size of the array could) 108 336 P-0.01 (be just large enough to hold the string, the array would have to be reallocated if a single character) 72 319 P0.65 (is added to the string. To improve speed, this class utilizes a minimum string buffer size and an) 72 302 P(incremental size.) 72 285 T0.05 (The minimum buffer size is the minimum amount of memory that is initially allocated for) 108 266 P-0.13 (the character array. The default size is 16 characters. Each newly created string will automatically) 72 249 P-0.44 (have a buffer size equal to this minimum size, plus one extra byte for the NULL terminator. There-) 72 232 P(fore,) 72 215 T(String s1;) 108 196 T(String s2 = "Hello";) 108 179 T0.32 (will both have 17 bytes of memory allocated even though not all 17 bytes are used. If the strings) 72 160 P-0.52 (are appended to then the memory does not have to be reallocated provided that the new length does) 72 143 P(not exceed 17 bytes:) 72 126 T(s1 = s2;) 108 107 T(s2 += ", World";) 108 90 TFMENDPAGE%%EndPage: "3" 3%%Page: "4" 4612 792 0 FMBEGINPAGE[0 0 0 1 0 0 0][ 0 1 1 0 1 0 0][ 1 0 1 0 0 1 0][ 1 1 0 0 0 0 1][ 1 0 0 0 0 1 1][ 0 1 0 0 1 0 1][ 0 0 1 0 1 1 0] 7 FrameSetSepColorsFrameNoSep0 0 0 1 0 0 0 K0 0 0 1 0 0 0 K0 0 0 1 0 0 0 K0 0 0 1 0 0 0 K72 746 540 756 R7 X0 0 0 1 0 0 0 KV72 18 540 45 RV72 34.99 540 45 C0 0 0 1 0 0 0 K0 0 0 1 0 0 0 K72 34.99 540 45 R7 X0 0 0 1 0 0 0 KV72 43.99 541.01 43.99 2 LV1 H2 Z0 XN0 0 612 792 C0 12 Q0 X0 0 0 1 0 0 0 K(String++ Version 3.1) 255.07 28.33 T(4) 534 28.33 T72 72 540 720 R7 XV0 X0.27 (The minimum buffer length is stored in the private variable) 72 712 P1 F0.27 (strMinLength) 362.7 712 P0 F0.27 (. You can set this to a) 434.7 712 P(new value with the) 72 695 T1 F(SetMinLength\050\051) 165.98 695 T0 F( function:) 247.98 695 T(String::SetMinLength\05024\051;) 108 676 T1.23 (This example sets the minimum buffer length to 24 bytes \050plus 1\051 for all subsequently created) 72 657 P0.31 (strings. Note that the String class is used in calling this function even though any String instance) 72 640 P(could be used.) 72 623 T-0.71 (A second variable is used in determining how a string buffer will grow. The private variable) 108 604 P1 F0.29 (strIncLength) 72 587 P0 F0.29 ( specifies the minimum number of bytes that is added to the buffer when the string) 139.33 587 P0.52 (exceeds the current buffer size. The default value is 8 bytes. Whenever a string needs additional) 72 570 P0.45 (space, it receives it in multiples of 8 bytes. In the example above, s2 contains "Hello, World". If) 72 553 P(we add some more:) 72 536 T(s2 += ", How are you?";) 108 517 T-0.07 (then s2 will exceed 17 bytes and additional memory must be allocated. In this case, s2 will need a) 72 498 P0.71 (total of 27 bytes \050including the NULL terminator\051. The original 17 bytes plus the incremental 8) 72 481 P-0.25 (bytes is not enough, so another incremental 8 bytes is added for a total of 33 bytes. This procedure) 72 464 P(also works for newly created strings that exceed strMinLength:) 72 447 T(String s3 = "This is a very long string.";) 108 428 T0.09 (s3 requires 28 bytes, so again it will receive 33 bytes \05017+8+8\051. strIncLength can be set using the) 72 409 P1 F(SetIncLength\050\051) 72 392 T0 F( function:) 149.33 392 T(String::SetIncLength\05016\051;) 108 373 T-0.42 (The reason for using minimum and incremental lengths is to reduce the number of memory) 108 354 P-0.46 (allocations, which are time consuming. The drawback is that each string will waste a small amount) 72 337 P-0.05 (of memory; for a moderate size string this will typically be strIncLength/2. Making strMinLength) 72 320 P0.76 (and strIncLength larger will waste more memory but require fewer memory allocations. Setting) 72 303 P-0.16 (them equal to 1 will waste no memory but each appendage operation will need to reallocate mem-) 72 286 P(ory. This is how older versions of this class worked \0502.12 and prior\051.) 72 269 T1 14 Q(T) 72 245.67 T(emporary Strings) 80.05 245.67 T0 12 Q0.01 (When using strings, you should be aware that temporary string objects are sometimes cre-) 108 221 P(ated and destroyed, and that they can degrade program performance. For example,) 72 204 T(s1 = s2 + "World";) 108 185 T-0.46 (creates a temporary string that is the combination of s2 and "World". It is this temporary string that) 72 166 P-0.65 (is assigned to s1 via the = operator. The reason for this is because the + operator is defined to accept) 72 149 P-0.35 (two const objects \050in this case a String and a char*\051 and returns a newly created string. The = oper-) 72 132 P-0.41 (ator is defined to accept a String&, which in this case is the string that results from the + operation.) 72 115 P-0.06 (The compiler knows that this string is temporary and will automatically delete it when the assign-) 72 98 P(ment to s1 is done.) 72 81 TFMENDPAGE%%EndPage: "4" 4%%Page: "5" 5612 792 0 FMBEGINPAGE[0 0 0 1 0 0 0][ 0 1 1 0 1 0 0][ 1 0 1 0 0 1 0][ 1 1 0 0 0 0 1][ 1 0 0 0 0 1 1][ 0 1 0 0 1 0 1][ 0 0 1 0 1 1 0] 7 FrameSetSepColorsFrameNoSep0 0 0 1 0 0 0 K0 0 0 1 0 0 0 K0 0 0 1 0 0 0 K0 0 0 1 0 0 0 K72 746 540 756 R7 X0 0 0 1 0 0 0 KV72 18 540 45 RV72 34.99 540 45 C0 0 0 1 0 0 0 K0 0 0 1 0 0 0 K72 34.99 540 45 R7 X0 0 0 1 0 0 0 KV72 43.99 541.01 43.99 2 LV1 H2 Z0 XN0 0 612 792 C0 12 Q0 X0 0 0 1 0 0 0 K(String++ Version 3.1) 255.07 28.33 T(5) 534 28.33 T72 72 540 720 R7 XV0 X0.42 (Functions that accept String objects as arguments can also accept char and char* objects,) 108 712 P-0.29 (as well as other data types that are supported by String constructors. For example, even though the) 72 695 P(index\050\051 function is defined to accept two String arguments, this is legal:) 72 678 T(i = index\050s1, "a"\051;) 108 659 T-0.61 (The "a" argument will be converted to a String object by the compiler because there is a String con-) 72 640 P-0.11 (structor that is defined for char*. Like the operator example above, this String object is temporary) 72 623 P(and is destroyed when the function returns.) 72 606 T0.98 (Based on the above example, is it necessary for the String class to overload the various) 108 587 P-0.43 (operators to accept data types that are already supported by constructors? The answer is no, but the) 72 570 P0.75 (overloaded operators will reduce the number of temporary strings that are created and therefore) 72 553 P1 (improve performance. In the example above, if the + operator were only defined to accept two) 72 536 P-0.4 (strings, then the "World" argument would cause the creation of a second temporary string. Most of) 72 519 P0.26 (the string functions are not overloaded because they typically do not see the kind of repeated use) 72 502 P-0.31 (the operators get. If there is a string function that will get heavy repeated use with non-string argu-) 72 485 P2.58 (ments \050such as the index example above\051 then you might see some speed improvement by) 72 468 P(overloading the function.) 72 451 T1 14 Q(Regular Expr) 72 417.67 T(essions) 153.8 417.67 T0 12 Q0.56 (Regular expressions are text patterns that are used for string matching. Normally, strings) 108 398 P0.47 (are compared to other strings \050or substrings\051 and we look for an absolute match. However, there) 72 381 P0.27 (are times when we want to test a string in a more general way. For example, suppose we want to) 72 364 P0.14 (see if a string contains any digits. Using absolute string matching, we would have to run 10 com-) 72 347 P0.32 (parisons, one for each digit. Using regular expressions, we can create a character class and make) 72 330 P(one comparison:) 72 313 T3 F(String s1;) 108 290 T(Regexp re = "[0-9]";) 108 276 T(...) 108 262 T(if\050s1 == re\051) 108 248 T( do_something\050\051;) 108 234 T0 F0.04 (In the example above, the regular expression contains "[0-9]". The "[]" brackets enclose the char-) 72 214 P-0.58 (acter class) 72 197 P2 F-0.58 (0-9) 123.49 197 P0 F-0.58 ( which matches any single digit. Therefore, if) 139.48 197 P2 F-0.58 (s1) 356.15 197 P0 F-0.58 ( contains a digit then the comparison) 366.82 197 P(with) 72 180 T2 F(re) 96.34 180 T0 F( will be true.) 106.33 180 T-0.33 (Before a regular expression can be used it must first be declared. For example, this will not) 108 161 P(work:) 72 144 T3 F(if\050s1 == "[0-9]"\051) 108 121 T( do_something\050\051;) 108 107 T0 F(because the == operator will compare s1 with the literal string "[0-9]". However, this will work:) 72 87 TFMENDPAGE%%EndPage: "5" 5%%Page: "6" 6612 792 0 FMBEGINPAGE[0 0 0 1 0 0 0][ 0 1 1 0 1 0 0][ 1 0 1 0 0 1 0][ 1 1 0 0 0 0 1][ 1 0 0 0 0 1 1][ 0 1 0 0 1 0 1][ 0 0 1 0 1 1 0] 7 FrameSetSepColorsFrameNoSep0 0 0 1 0 0 0 K0 0 0 1 0 0 0 K0 0 0 1 0 0 0 K0 0 0 1 0 0 0 K72 746 540 756 R7 X0 0 0 1 0 0 0 KV72 18 540 45 RV72 34.99 540 45 C0 0 0 1 0 0 0 K0 0 0 1 0 0 0 K72 34.99 540 45 R7 X0 0 0 1 0 0 0 KV72 43.99 541.01 43.99 2 LV1 H2 Z0 XN0 0 612 792 C0 12 Q0 X0 0 0 1 0 0 0 K(String++ Version 3.1) 255.07 28.33 T(6) 534 28.33 T72 72 540 720 R7 XV3 F0 X(if\050s1 == Regexp\050"[0-9]"\051\051) 108 712 T( do_something\050\051;) 108 698 T0 F-0.47 (Several string functions include support for regular expressions. Like the other AWK func-) 108 678 P1.93 (tions included with the String class, the) 72 661 P1 F1.93 (match) 277.51 661 P0 F1.93 ( function returns the position of the matching) 309.5 661 P0.52 (substring using C\325s zero-based array offset, and -1 if the match failed. Because the ~ operator is) 72 644 P-0.44 (unary in C++, it could not be overloaded to provide the same functionality as in AWK. Instead, the) 72 627 P(== operator and the != operator have been overloaded to use regular expressions.) 72 610 T0.08 (For more information concerning the use of regular expressions, consult a text on Unix or) 108 591 P3.42 (the AWK language \050such as) 72 574 P2 F3.42 (The AWK Programming Language) 226.74 574 P0 F3.42 (, by Aho, Kernighan, and) 404.67 574 P(Weinberger\051.) 72 557 T1 14 Q(Using the String Class) 72 523.67 T0 12 Q-0.18 (Before using the String class, you need to set it up for the version of Borland C++ that you) 108 504 P0.47 (are using. In 3.x, Borland used a class named) 72 487 P2 F0.47 (String) 296.23 487 P0 F0.47 ( in the Container Class Library. Therefore,) 325.58 487 P0.32 (you cannot have another class named) 72 470 P2 F0.32 (String) 259.19 470 P0 F0.32 (. In 4.x, Borland used an entirely new class named) 288.53 470 P2 F(string) 72 453 T0 F(, so another) 100.01 453 T2 F(string) 158.66 453 T0 F( class would be illegal. In str.h there are two typedef statements:) 186.67 453 T3 F(typedef StrPP String) 108 430 T(typedef StrPP string) 108 410 T0 F0.21 (These basically define alternate names for the class StrPP, which is referred to throughout this) 72 390 P-0.13 (document as "the String class". If you are using BC++ 3.x comment out the String typedef, and if) 72 373 P0.37 (you are using 4.x comment out the string typedef. If you want to derive your own custom class) 72 356 P(named) 72 339 T2 F(string) 106.99 339 T0 F( or) 135 339 T2 F(String) 151 339 T0 F(, comment out the appropriate typedef, or both.) 180.34 339 T-0.1 ( There are several ways to add the String class to your program. You could simply copy all of) 72 320 P-0.23 (the files to your project directory and add the) 72 303 P2 F-0.23 (cpp) 295.09 303 P0 F-0.23 ( files to the project list, and) 312.42 303 P1 F-0.23 (#include "str.h") 444.8 303 P0 F-0.23 ( in) 527.89 303 P-0.28 (any module that uses a string. You could also compile the) 72 286 P2 F-0.28 (cpp) 352.28 286 P0 F-0.28 ( files to object format and place the) 369.61 286 P0.39 (object files in Borland's LIB directory and the header files in Borland's H directory. Then) 72 269 P0.27 (add the) 72 252 P2 F0.27 (obj) 110.54 252 P0 F0.27 ( files to the project list and) 125.87 252 P1 F0.27 (#include <str.h>) 268.59 252 P0 F0.27 (. Finally, you could split the) 352.55 252 P2 F0.27 (cpp) 498.74 252 P0 F0.27 ( files) 516.06 252 P-0.13 (into individual function files and use them to create a more efficient) 72 235 P2 F-0.13 (lib) 405.47 235 P0 F-0.13 ( file which can be placed) 418.15 235 P0.19 (in Borland's LIB directory and added to the project list. To use regular expressions you will also) 72 218 P(need to) 72 201 T1 F(#include regexp.h) 109.99 201 T0 F( in modules that use them.) 200.66 201 TFMENDPAGE%%EndPage: "6" 6%%Page: "7" 7612 792 0 FMBEGINPAGE[0 0 0 1 0 0 0][ 0 1 1 0 1 0 0][ 1 0 1 0 0 1 0][ 1 1 0 0 0 0 1][ 1 0 0 0 0 1 1][ 0 1 0 0 1 0 1][ 0 0 1 0 1 1 0] 7 FrameSetSepColorsFrameNoSep0 0 0 1 0 0 0 K0 0 0 1 0 0 0 K0 0 0 1 0 0 0 K0 0 0 1 0 0 0 K72 746 540 756 R7 X0 0 0 1 0 0 0 KV72 18 540 45 RV72 34.99 540 45 C0 0 0 1 0 0 0 K0 0 0 1 0 0 0 K72 34.99 540 45 R7 X0 0 0 1 0 0 0 KV72 43.99 541.01 43.99 2 LV1 H2 Z0 XN0 0 612 792 C0 12 Q0 X0 0 0 1 0 0 0 K(String++ Version 3.1) 255.07 28.33 T(7) 534 28.33 T72 72 540 720 R7 XV1 18 Q0 X(Class Operators) 72 708 T72 684.99 540 695 C0 0 0 1 0 0 0 K0 0 0 1 0 0 0 K72 684.99 540 695 R7 X0 0 0 1 0 0 0 KV72 693.99 541.01 693.99 2 LV1 H2 Z0 XN0 0 612 792 C1 14 Q0 X0 0 0 1 0 0 0 K(operator =) 72 675.66 T1 12 Q(Syntax:) 72 650.99 T0 F(String& operator=\050char) 117 650.99 T2 F(c) 233.08 650.99 T0 F(\051;) 238.4 650.99
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -