#include "camtypes.h"
#include <iostream>
#include <stdarg.h>
#include "camelot.h"
Go to the source code of this file.
Functions | |
DECLARE_SOURCE ("$Revision: 1282 $") | |
INT32 | SmartLoadString (UINT32 modID, UINT32 resID, LPTCHAR buf, INT32 size) |
Loading a string resource, possibly from a .DLL. If modID is non-zero then that module is tried first, falling back to the main program if not found. Also has to work-around a nasty bug in Win32s LoadStringA. Also recognises Tool resource IDs and works out the module automatically (if modID is zero). | |
std::istream & | operator>> (std::istream &is, StringBase &s) |
Read a string from a (non-persistent) stream. The input is terminated by a newline character (NOT whitespace, cf. reading C-style character arrays). If the string is longer than MAX_STRING_RES_LENGTH get() will read as many characters as possible and put a newline at the end. | |
std::ostream & | operator<< (std::ostream &os, const StringBase &s) |
Write a string to a (non-persistent) stream. If the string is 0 then "[0]" is printed. | |
const TCHAR * | cc_lstrstr (const TCHAR *String1, const TCHAR *String2) |
Read/write a string to/from a persistent stream, a.k.a. an archive, depending upon the value of ar.IsStoring(). Finds the first occurrence of string2 in string1 This version is case sensitive. Notes: Replaces the Windows API version which seems to be missing. Uses TCHAR's instead of char's, and also uses CompareString for multinational support. |
|
Read/write a string to/from a persistent stream, a.k.a. an archive, depending upon the value of ar.IsStoring(). Finds the first occurrence of string2 in string1 This version is case sensitive. Notes: Replaces the Windows API version which seems to be missing. Uses TCHAR's instead of char's, and also uses CompareString for multinational support.
Definition at line 1632 of file basestr.cpp. 01633 { 01634 ERROR3IF(String1 == 0 || String2 == 0, 01635 "0 (zero) parameters passed to cc_lstrstr"); 01636 01637 if (String1 == 0 || String2 == 0) return 0; 01638 if (!*String2) return String1; 01639 return camStrstr(String1, String2); 01640 01641 // TCHAR *cp = String1; 01642 // TCHAR *s1; 01643 // TCHAR *s2; 01644 01645 // while (*cp) 01646 // { 01647 // s1 = cp; 01648 // s2 = String2; 01649 01650 // // DCBS compatible case sensitive string compare 01651 // while(*s1 && *s2 && (CompareString(LOCALE_USER_DEFAULT, 01652 // (NORM_IGNOREKANATYPE | NORM_IGNOREWIDTH), 01653 // s1, 1, s2, 1) == 2)) 01654 // s1++, s2++; 01655 // if(!*s2) 01656 // return(cp); 01657 // cp++; 01658 // } 01659 // 01660 // return(0); 01661 }
|
|
Definition of the string class, as declared in StringBase.h. |
|
Write a string to a (non-persistent) stream. If the string is 0 then "[0]" is printed.
Definition at line 1274 of file basestr.cpp. 01275 { 01276 ERROR3IF(!s.text, "Call to ostream << for an unALLOCated String"); 01277 os << (s.Length() ? s.text : TEXT("[0]")); 01278 return os; 01279 }
|
|
Read a string from a (non-persistent) stream. The input is terminated by a newline character (NOT whitespace, cf. reading C-style character arrays). If the string is longer than MAX_STRING_RES_LENGTH get() will read as many characters as possible and put a newline at the end.
Definition at line 1240 of file basestr.cpp. 01241 { 01242 ERROR3IF(!s.text, "Call to istream >> for an unALLOCated String"); 01243 01244 char temp[MAX_STRING_RES_LENGTH]; 01245 is >> std::ws; // skip any leading whitespace 01246 is.get(temp, MAX_STRING_RES_LENGTH); // grab a chunk of input, up to a newline 01247 01248 ERROR3IF( size_t(s.length) <= strlen(temp), "Call to istream >> will overflow String" ); 01249 #if wxUSE_UNICODE 01250 PORTNOTE("other","This is not very efficient needs revisiting") 01251 TCHAR ptsz[MAX_STRING_RES_LENGTH]; 01252 mbstowcs( ptsz, temp, MAX_STRING_RES_LENGTH ); 01253 #else 01254 s = temp; // NB. s.operator=(const TCHAR*) 01255 #endif 01256 return is; 01257 }
|
|
Loading a string resource, possibly from a .DLL. If modID is non-zero then that module is tried first, falling back to the main program if not found. Also has to work-around a nasty bug in Win32s LoadStringA. Also recognises Tool resource IDs and works out the module automatically (if modID is zero).
Definition at line 1090 of file basestr.cpp. 01091 { 01092 PORTNOTE("other","SmartLoadString - needs to be converted to GetText") 01093 ERROR3IF(resID == 0, "Zero string resource ID in SmartLoadString"); 01094 ERROR3IF(buf == 0, "No output buffer in SmartLoadString"); 01095 INT32 numchars = size/sizeof(TCHAR); 01096 ERROR3IF(numchars < 2, "Buffer too small in SmartLoadString"); 01097 01098 camStrncpy( buf, CamResource::GetText(resID), numchars ); // NB GetText cannot fail 01099 buf[numchars-1]=0; // ensure zero terminated 01100 return (camStrlen(buf)+1)*sizeof(TCHAR); // return number of bytes copied 01101 }
|