////////////////////////////////// // // // // // Leo's Hello World // // // // // // Free for personal use // // // // // ////////////////////////////////// // Copyright (C) 2003-2006 Leonard Mada /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301 USA */ // * Version 2003.12.13 * // * minor corrections 2005/01 // * 2006/06 deleted code NOT related to string-formatter // MAY BE FREELY USED IN OPENOFFICE.ORG / STAROFFICE // MAY BE FREELY USED IN ANY FREE SOFTWARE // BUT STRONGLY CONSIDER REWRITING CODE // This code was successfully compiled with MS Visual C++ 6.0 // I do not know IF it can be compiled with different versions/compilers #pragma warning(disable: 4786) //#include //#include #include #include #include #include "iostream" #include #include #include #include #include using namespace std ; //////////////////////////////////////////////////////// enum YESNO{ YES=1, NO =0 }; const int _MultipleSpaces_DeleteOK = YES; // Delete Multiple Spaces (=Convert to 1 DEFAULT Space) const int _MultipleSpaces_DeleteNO = NO; // Do NOT Delete Multiple Spaces // int _MultipleSpaces_Delete=_MultipleSpaces_DeleteOK;// Actual Variable --> Change ONLY THIS // // Default Space is set by (wchar) sSpaceDefaultW / (char) sSpaceDefault // Space Equivalents are set using the sSpaceEqW/sSpaceEq variable // // // Is the current string begining(/ending) at a master-string start(/end) position // or is this a selection begining(/ending) in the middle of that master-string? // (e.g. when casing a selection and NOT the whole string; // => parsing aplication must decide this!) // const int _String_BeginOK = YES; // Selection begins at 'start' position, NO -> IF NOT START Position const int _String_EndOK = YES; // Selection ends at 'ending' position, NO -> IF NOT END Position // const int _String_BeginWord = YES; // IF _String_BeginOK==NO, current string is a selection inside // another string. Parsing application must decide if this is // a new word or if the selection begins inside a word const int _Spaces_Delete_Begin =1; // Delete All Spaces at START of String (MUST BE _String_BeginOK) const int _Spaces_Delete_Middle =2; // Delete All Spaces in the Middle of the String const int _Spaces_Delete_End =4; // Delete All Spaces at the END of the String (MUST BE _String_EndOK) // int _Spaces_Delete_Var = (_Spaces_Delete_Begin|_Spaces_Delete_End); // Actual variable --> Change ONLY THIS // // IF (_Spaces_Delete_Middle AND (NOT _String_BeginOK) AND (NOT _String_EndOK)) // // -> LEADING AND ENDING SPACES DELETED AS WELL !!! // // PUT HERE THE CHARACTERS WHICH YOU WOULD LIKE TO PROCESS // // THERE ARE 6 TYPES OF PREDEFINED CHARACTER GROUPS: // // * SPACE EQUIVALENTS: AFTER THEM A NEW WORD WILL BEGIN; || THIS CHARACTERS CAN BE DELETED // BY PROCESSING THE OTHER CHARACTERS // * SPACE BEFORE; BUT DELETE ANY SPACES AFTER THEM || // * SPACE AFTER; BUT DELETE ANY SPACES BEFORE || // * SPACE BOTH BEFORE AND AFTER || ALL THESE CAN NOT BE DELETED!!! // * DELETE ANY SPACES BEFORE AND AFTER || // * AS THE SPACE EQUIVALENTS; BUT CANNOT BE DELETED; || // // THESE GROUPS ARE ALWAYS PROCESSED IN THIS ORDER // // YOU CAN PUT A CHARACTER IN ONE OR MORE GROUPS, BUT ONLY THE FIRST GROUP WITH THAT CHARACTER WILL BE PROCESSED; // ALSO: IF A GROUP CONTAINS NO CHARACTERS, IT WILL BE SIMPLY IGNORED: // // DELETING SPACES HAS ALWAYS PRECEDENCE OVER INSERTING A SPACE!!! // string sSpaceEq = " _ "; // Space Equivalents: Space, Underscore, TAB [MAY BE DELETED] wstring sSpaceEqW =L" _ "; string sSpaceBefore = "([{$~"; // Delete Space After THIS, but Leave_ Space Before THIS wstring sSpaceBeforeW =L"([{$~"; string sSpaceAfter = "),.!?;]}:"; // Leave_ Space After THIS, but Delete Space Before THIS wstring sSpaceAfterW =L"),.!?;]}:"; string sSpaceAround = "-&=+"; // Leave_ Spaces BOTH Before AND After THIS wstring sSpaceAroundW =L"-&=+"; string sSpaceNOSpace = "\\/\n"; // Delete Spaces BOTH Before AND After THIS wstring sSpaceNOSpaceW =L"\\/\n"; string sSpaceIgnore = "#%*\"<>'"; // Ignore Any Spaces Around, BUT Casing as for _Word_Case_Begin [IS NOT DELETED] wstring sSpaceIgnoreW =L"#%*\"<>'"; // /\ // || // YOU MAY CHANGE THESE CHARACTERS template > class SpChStW { // This class will contain the special character groups (see above) // to be processed by the string process class (CAW template class) public: vector vsSpaceStruct; }; string sSpaceDefault = " "; // Default Space Character // SHOULD BE 1 CHARACTER-long wstring sSpaceDefaultW = L" "; // but when _MultipleSpaces_DeleteOK works with more then 1 character as well // string sSentenceCharacter = "-.?!\\/"; // Begins New Sentence wstring sWSentenceCharacter = L"-.?!\\/"; string sDestroy_NewSentence = ")]},"; // After THIS Character, NEW Sentence Attribute is DELETED wstring sWDestroy_NewSentence = L")]},"; string sApostropheC = "'"; // After THIS Character, NEW/ NO NEW Word, depending on position of "'" wstring sWApostropheC = L"'"; // const int _Word_Case_NOP = 0; // No Operation, leave Case as it is const int _Word_Case_Inverse = 1; // Inverse Case, IF Lower make Upper, else IF Upper make Lower const int _Word_Case_UPPER = 2; // Change to Upper Case const int _Word_Case_Lower = 3; // Change to Lower Case const int _Word_Case_Weird = 4; // Change to Weird Case const int _Word_Case_Custom = 5; // Change to a Custom Casing Function (This Function MUST be Loaded at RunTime) // // struct WordCase { const int _Word_Case_Begin ;//=; // Case of Beginning of Word const int _Word_Case_Middle ;//=; // Case of Middle of the Word const int _Word_Case_Sentence;//=; // Case of Word beginning NEW Sentence // WordCase(const int iWordBegin,const int iWordMiddle, const int iWordSentence): _Word_Case_Begin (iWordBegin), _Word_Case_Middle (iWordMiddle), _Word_Case_Sentence (iWordSentence){} }; // WordCase clWC( // A struct of type WordCase is passed to the constructor of the CAW template class _Word_Case_UPPER, // Case of Beginning of Word || _Word_Case_Lower, // Case of Middle of the Word || Actual variables, CHANGE ONLY THIS _Word_Case_UPPER); // Case of Word beginning NEW Sentence || /////////////////////////////////////////////////////////////////////////// /* */ typedef string *(*pF )( string *); // WERE USED IN THE OLD CLASSES!!! typedef wstring *(*pFW)(wstring *); // STILL USED IN MAIN (load CustomCase Function at runtime) /////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////// //////////////////////////////////////// // // // *** DEFINITIONS NOT USED IN THE CLASSES *** // // *** ONLY FOR MAIN *** // //////////////////////////////////////// LPCTSTR MyTitle=_T("Leo's Hello World"); const int iCase=2; // Select 2 for the String Formatter #define TEST #ifdef TEST const int AutoClp_Load = NO; // Start directly by pasting text from the Clipboard const int AutoClp_Copy = YES; // Copy formatted string automatically to Clipboard const int AutoExit = NO; // Automatically Exit the program when finishing, without any user notification #endif #ifndef TEST const int AutoClp_Load = YES; const int AutoClp_Copy = YES; const int AutoExit = YES; #endif const int FileExtensionChange= NO; // Ignore file extension, i.e. don't format like rest of string, // but format like FileExtensionFormat const int FileExtensionFormat= _Word_Case_Lower; // Format of File Extension // // *** END EXTERNAL DEFINITIONS *** // ///////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////// // // // // // *** EXTERNAL FUNCTIONS *** // // // // // ////////////////////////////////// // Are NOT part of the string formatter // but only to test a specific feature (when casing with _Word_Case_Custom) string *CaseFunction_External(string *sString) { // // This function converts a string to AlTeRnAtInG Case! (it's only a dirty example) // // To access it, you must load at RunTime the pointer to this function into your // case processor class with CAW::SetCustomCase([_pointer_to_function]) // and then put some of the _Word_Case_Begin/_Middle/_End to _Word_Case_Custom // and the corresponding parts of the word will be 'cased' by this function! // // Alternatively, you can write your own function: // basic_string * [YOUR_FUNCTION](basic_string *) // It should take a pointer to a string as argument and return a pointer to a string // // With CAW::SetCustomCase([_pointer_to_function]) you set the pointer // to your function; with CAW::DelCustomCase() you delete that pointer! // static int *iX=new int(0); if(sString==NULL){try{delete iX;iX=NULL;}catch(...){} return NULL;} if((*iX)!=1){*sString=toupper (*sString->begin());*iX=1;} else{*sString=tolower (*sString->begin());*iX=0;} return sString; } wstring *CaseFunction_External(wstring *sString) { static int *iX=new int(0); if(sString==NULL){try{delete iX;iX=NULL;}catch(...){} return NULL;} if((*iX)!=1){*sString=towupper (*sString->begin());*iX=1;} else{*sString=towlower (*sString->begin());*iX=0;} return sString; } // // *** END EXTERNAL FUNCTIONS *** // //////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////// // // // // // *** START OF CLASSES *** // // // // // ////////////////////////////////////////// ////////////////////////////// // // // // // Default Space // // // // // ////////////////////////////// template class DfSp { mutable STRW::iterator pSpBegin; mutable int _IS_RUNNING; bool Freeze(bool b)const {return (_IS_RUNNING==YES)?b:!b;}; bool Freeze() const {return (_IS_RUNNING==YES)?true:(_IS_RUNNING=YES,false);}; void UnFreeze() const { _IS_RUNNING=NO;}; STRW sDfSp,sSpEq; STRW* (DfSp::*pFPrS)(STRW &) const; STRW* ProcessSpaces_MulDelOK (STRW &sWString) const; STRW* ProcessSpaces_MulDelNO (STRW &sWString) const; public: DfSp(const STRW sLDfSp, const STRW sLSpEq, const int iDelMultSp) {pSpBegin=0;sDfSp=sLDfSp;sSpEq=sLSpEq;UnFreeze(); switch (iDelMultSp) { case _MultipleSpaces_DeleteNO:{ pFPrS= &DfSp::ProcessSpaces_MulDelNO; break;} default:{ pFPrS= &DfSp::ProcessSpaces_MulDelOK; break;} } }; int SetDfSp (const STRW sNewDfSp) {return (Freeze(false))? sDfSp=sNewDfSp,YES: NO;}; int SetSpEq (const STRW sNewSpEq) {return (Freeze(false))? sSpEq=sNewSpEq,YES: NO;}; STRW ProcessSpaces (STRW &sString) const {return*(this->*pFPrS) (sString); }; bool IsRunning(void) const {return Freeze(true);}; }; template STRW * DfSp::ProcessSpaces_MulDelOK (STRW &sWString) const { // // // We can convert Multiple Spaces to ONE Space // // extern const int _String_BeginOK; extern const int _String_EndOK; // // // if(Freeze()){return NULL;} STRW::iterator iSF=sWString.begin(); size_t stSS; // // START MAIN LOOP // for(;iSF=sWString.end()-1) {// _Space_is_at_END of String if (pSpBegin>sWString.begin()) { if (((_Spaces_Delete_Var & _Spaces_Delete_End )&&(_String_EndOK == YES))|| ((_Spaces_Delete_Var & _Spaces_Delete_Middle)&&(_String_EndOK != YES)) ) { // We can delete ALL Ending Spaces sWString.resize(pSpBegin-sWString.begin());//iSF=--pSpBegin; Exact, but we don't need it anymore pSpBegin=0; break;} // ELSE // We can NOT delete ALL Spaces, // but we will convert Multiple Spaces to ONE Space // iSF=pSpBegin; // sWString.replace(iSF,sWString.end(),sDfSp); // pSpBegin=0; break;} else {// String is ONLY Space // Now We Got A Problem // // If Spaces_Delete_(ANY) we will return NULL // wprintf(L"We've got a problem!\n"); // For Debugging purposes // if (_Spaces_Delete_Var) {sWString.erase(); pSpBegin=0; break;} // // ELSE, we convert the Multiple Spaces to ONE Space // sWString=sDfSp; iSF=sWString.begin(); // =SpaceBeginPointer pSpBegin=0; break;} }// END _Space_is_at_END of String // ELSE Space is NOT at END of String //continue; <-- Alternative code --> THEN DELETE IN THE FOLLOWING IF THE CONDITION (stSS==npos) } // // if ((pSpBegin>0)&&(stSS==STRW::npos)) { // A Space sequence has just ended // We must process it now! // if (pSpBegin>sWString.begin()) {//The Space is NOT at the Beginning // And the Space Sequence is NOT at the END, // so it should be in the MIDDLE of the string. // if (_Spaces_Delete_Var & _Spaces_Delete_Middle) {// We are allowed to Delete ALL Spaces /// sWString.erase(pSpBegin,iSF); iSF=pSpBegin; pSpBegin=0;} else {// We are NOT Allowed to Delete ALL Spaces /// But we will convert Multiple Spaces to ONE Space! // sWString.replace(pSpBegin,iSF,sDfSp); iSF=++pSpBegin; pSpBegin=0;}} else {// The Space is at the Beginning of the string if (((_Spaces_Delete_Var & _Spaces_Delete_Begin )&&(_String_BeginOK == YES))|| ((_Spaces_Delete_Var & _Spaces_Delete_Middle)&&(_String_BeginOK != YES)) ) { // We are allowed to Delete ALL Spaces sWString.erase(sWString.begin()/* =pSpBegin */,iSF); iSF=sWString.begin(); /* =pSpBegin */ pSpBegin=0;} else {//We are NOT Allowed to Delete ALL Spaces // But we will convert Multiple Spaces to ONE Space! // sWString.replace(sWString.begin()/* =pSpBegin */,iSF,sDfSp); iSF=++pSpBegin; pSpBegin=0;}} } } //while(iSF STRW* DfSp ::ProcessSpaces_MulDelNO (STRW &sWString) const { // // // We can NOT convert Multiple Spaces to ONE Space // But we will convert Multiple Spaces to a sequence of DEFAULT Spaces // // extern const int _String_BeginOK; extern const int _String_EndOK; // // // if(Freeze()){return NULL;} STRW::iterator iSF=sWString.begin(); size_t stSS; // for(;iSF=sWString.end()-1) {// Space is at END of String if (pSpBegin>sWString.begin()) { if (((_Spaces_Delete_Var & _Spaces_Delete_End )&&(_String_EndOK == YES))|| ((_Spaces_Delete_Var & _Spaces_Delete_Middle)&&(_String_EndOK != YES)) ) { // We can delete ALL Ending Spaces sWString.resize(pSpBegin-sWString.begin()); //iSF=--SpaceBeginPointer; // Exact, but we don't need it anymore pSpBegin=0; break;} // Else we can NOT delete ALL Spaces, // but we will convert the Remainder Spaces to DEFAULT Spaces // STRW sLSpString; iSF++; size_t tsl=iSF-pSpBegin; sLSpString.resize(tsl,sDfSp[0] ); sWString.replace(pSpBegin,iSF,sLSpString); pSpBegin=0; break; } else {// String is ONLY Space /// Now We Got A Problem /// If Spaces_Delete_(ANY) we will return NULL wprintf(L"We've got a problem!\n"); if (_Spaces_Delete_Var) {sWString.erase(); pSpBegin=0; break;} // // Else, we convert the Multiple Spaces to Multiple Default Spaces STRW sLSpString; // Actually pSpBegin = 0 iSF++; sLSpString.resize(iSF-pSpBegin,sDfSp[0] ); sWString=sLSpString; pSpBegin=0; break; } }// END _Space_is_at_END of String } // // if ((pSpBegin>0)&&(stSS==STRW::npos)) { // A Space sequence has just ended // We must process it now! if (pSpBegin>sWString.begin()) { // The Space is NOT at the Beginning // And the Space Sequence is NOT at the END, // so it should be in the MIDDLE of the string. if (_Spaces_Delete_Var & _Spaces_Delete_Middle) {// We are allowed to Delete ALL Spaces sWString.erase(pSpBegin,iSF); iSF=pSpBegin; pSpBegin=0;} else {// We are NOT Allowed to Delete ALL Spaces /// But we will convert the Multiple Spaces to DEFAULT Spaces! STRW sLSpString; size_t tsl=iSF-pSpBegin; sLSpString.resize(tsl,sDfSp[0] ); sWString.replace(pSpBegin,iSF,sLSpString); pSpBegin=0;} } else { // The Space is at the Beginning of the string if (((_Spaces_Delete_Var & _Spaces_Delete_Begin )&&(_String_BeginOK == YES))|| ((_Spaces_Delete_Var & _Spaces_Delete_Middle)&&(_String_BeginOK != YES)) ) { // We are allowed to Delete ALL Spaces sWString.erase(sWString.begin(),iSF); // =pSpBegin iSF=sWString.begin(); pSpBegin=0;} else {// We are NOT Allowed to Delete ALL Spaces /// But we will convert the Multiple Spaces to DEFAULT Spaces! STRW sLSpString; size_t tsl=iSF-sWString.begin();// -pSpBegin sLSpString.resize(tsl,sDfSp[0] ); sWString.replace(0,tsl,sLSpString); pSpBegin=0;} } } }//while(iSF class CAW { // _WUP and _WLOW run only with wstring's, BUT I didn't figure out how the // ctype::tolower/toupper can be made to function in any locale correctly! public: CAW(const SpChStW &clMySp, const WordCase &clWCL, const STRW sNewDfSp, const STRW sWNSentenceCharacter, const STRW sWNDelSentence, const STRW sWNApostrophe); ~CAW(){DelCustomCase();STRW sL;CaseWeird(sL); CaseWeird((STR*)(NULL)); wcout< viSpace; int iSpaceModifiersNr; STRW sWSpaceModifiers; inline STRW::iterator DeleteSpaces (const STRW::iterator &itFirst,const STRW::iterator &itLast) const { STRW::iterator itS=itFirst; for(;itS MyCType; // STILL LOCALE NOT FUNCTIONAL, SO I DECIDED NOT TO USE IT }; // // *** THE CONSTRUCTOR *** // // // *** ALTERNATIVE CONSTRUCTOR *** // template CAW::CAW( const SpChStW &clMySpace, const WordCase &clWCL, const STRW sNewDfSp, const STRW sWNSentenceCharacter, const STRW sWNDelSentence, const STRW sWNApostrophe): _Word_Case_Begin (clWCL._Word_Case_Begin), _Word_Case_Middle (clWCL._Word_Case_Middle), _Word_Case_Sentence (clWCL._Word_Case_Sentence) { pCC=NULL; iSpaceModifiersNr=0; _IS_RUNNING=NO; // _IS_RUNNING is NOT yet implemented in this Template Class sWSpaceModifiers.erase(); sDfSp=sNewDfSp; iNewSentence= 0; sNewSentence= sWNSentenceCharacter; // Begins New Sentence sNewSentence_DelAttrib =sWNDelSentence; // After THIS: No new Sentence sApostrophe = sWNApostrophe; // After THIS: NEW/ NO NEW Word // const SpChStW *pSSp=&clMySpace; // for (int j=0; j<(pSSp)->vsSpaceStruct.size(); j++ ) {viSpace.push_back(iSpaceModifiersNr+=(pSSp)->vsSpaceStruct[j].length()); sWSpaceModifiers.append( (pSSp)->vsSpaceStruct[j]); } } // // *** ACTUAL MEMBER FUNCTIONS *** // template inline STRW CAW::DeleteSpaces(STRW &sString) const { int iSpaceExist=0; STRW::iterator itS=sString.begin(); // for(;itS STRW CAW::CaseProcess(STRW sString) { extern const int _String_BeginWord; // size_t iStringPos=0; size_t i;//=sString.length(); // int iSpaceExist=-1; // for(;iStringPos 1) && (sWSpaceModifiers.find(sString.at(iStringPos - 2))!= STRW::npos)) {iSpaceExist = sNr; continue;} if((iStringPos == 1) && (_String_BeginOK == YES)) {iSpaceExist = sNr; continue;} iSpaceExist = -1; continue; } // // NOW WE PROCESS THE SPECIAL CHARACTERS // if(sNr < viSpace[0]) // THIS IS JUST AN ORDINARY SPACE {iSpaceExist=sNr; continue;} //else{ if(sNr < viSpace[1]) {// /// PUT SPACE BEFORE , BUT DELETE SPACES AFTER // if((iSpaceExist==-1)&&((iStringPos>0)||(_String_BeginOK!=YES))) {// INSERT SPACE BEFORE sString.insert(iStringPos,sDfSp); iStringPos++; } // // DELETE SPACES AFTER // iStringPos++; if(iStringPos>=sString.length())break; // sString.erase(sString.begin()+iStringPos,DeleteSpaces(sString.begin()+iStringPos,sString.end())); // iSpaceExist=sNr; iStringPos--; continue; } //else{ if(sNr < viSpace[2]) {// /// PUT SPACE AFTER , BUT DELETE SPACES BEFORE // if(iSpaceExist>=0) {// /// DELETE SPACES BEFORE // i=sString.length(); sString.erase(DeleteSpaces(sString.rbegin()+sString.length()-iStringPos,sString.rend()),sString.begin()+iStringPos); iStringPos-=i-sString.length();} // PUT SPACE AFTER THIS iStringPos++; // if(iStringPos // if((iSpaceExist==-1)&&((iStringPos>0)||(_String_BeginOK!=YES))) {// Insert Space Before sString.insert(iStringPos,sDfSp); iStringPos++;} // Is Next Character Space? iStringPos++; // if(iStringPos // i=sString.length(); sString.erase(DeleteSpaces(sString.rbegin()+sString.length()-iStringPos,sString.rend()),sString.begin()+iStringPos); iStringPos-=i-sString.length(); // // DELETE SPACES AFTER // iStringPos++; if(iStringPos>=sString.length())break; // sString.erase(sString.begin()+iStringPos,DeleteSpaces(sString.begin()+iStringPos,sString.end())); // iSpaceExist=sNr; iStringPos--; continue; } //else{ if(sNr < viSpace[5]) {// /// IGNORE SPACES AROUND THIS, BUT CASE AS FOR _WORD_BEGIN // iSpaceExist=sNr; continue;} /*}}}}}*/ } else {// This Character is NOT Space STRW sLocalString; sLocalString=sString.at(iStringPos); // wcout< inline STRW CAW::Case(STRW &sString, const int iWord_Case) { switch (iWord_Case) { case _Word_Case_NOP: {return sString;} case _Word_Case_UPPER: {return _WUP(sString);} case _Word_Case_Lower: {return _WLOW(sString);} case _Word_Case_Inverse: {STRW sLocalString; if(sString.length()==1) {sLocalString= CaseInverse(sString);} else {sLocalString=sString; STRW::iterator itsL=sLocalString.begin(); for(; itsL inline STRW CAW::CaseWeird(const STRW &sString) const { static double *pdsR=new double; if(pdsR==NULL){if(!sString.empty()){pdsR=new double;}} STRW sLocalString; if(sString.empty()){delete [] pdsR; pdsR=NULL;return sLocalString;} // sLocalString=sString; double dRX=*pdsR; dRX+=((int)pdsR)%100; // // Enter ANY RANDOM GENERATOR FUNCTION // dRX=sin(dRX+=((int)*sLocalString.begin())); dRX*=100; dRX+=0.6; dRX=ceil(dRX)-dRX; dRX*=100; *pdsR=dRX; if((int)(ceil(dRX*100))%2==0) {return _WUP(sLocalString);} else {return _WLOW(sLocalString);} } template inline STR CAW::CaseWeird(const STR *pcString) const { static double *pdsR=new double; if(pdsR==NULL){if(pcString==NULL){pdsR=new double;}} if(pcString==NULL){delete [] pdsR; pdsR=NULL;return NULL;} // double dRX=*pdsR; dRX+=((int)pdsR)%100; // // Enter ANY RANDOM GENERATOR FUNCTION // dRX=sin(dRX+=((int)*pcString)); dRX*=100; dRX+=0.6; dRX=ceil(dRX)-dRX; dRX*=100; *pdsR=dRX; if((int)(ceil(dRX*100))%2==0) {return _WUP(*pcString);} else {return _WLOW(*pcString);} } // //////////////////////////////// // // // // // *** MAIN *** // // // // // //////////////////////////////// int main(int argc, char* argv[]) { setlocale( LC_ALL, ".OCP" );_wsetlocale( LC_ALL,L".OCP"); wstring sWLocalString; SetConsoleTitle(MyTitle); if(argc>1) { sSpaceDefault = argv[1]; sSpaceDefaultW = btowc(*argv[1]); } {HWND MyWindowHandle=GetForegroundWindow(); wprintf(L"Handle to this window: %Xh\n",MyWindowHandle); if(AutoClp_Load == NO) { wprintf(L"\nTo copy text from clipboard just hit ENTER, else\nEnter string: ");_flushall(); // sWLocalString.reserve(100); wstring::iterator its = sWLocalString.begin(); istreambuf_iterator insbIt(wcin); // while(1){ if(*insbIt==0x0a){break;} sWLocalString.resize(its-sWLocalString.begin()+1);*its++=*insbIt++; } wprintf(L"\n"); } // // The Clipboard does FINALLY work!!! // if(sWLocalString.empty()) { if(OpenClipboard(MyWindowHandle)) {HANDLE hClp=GetClipboardData(CF_UNICODETEXT); if(hClp) { sWLocalString=(wchar_t *)GlobalLock(hClp);GlobalUnlock(hClp); } CloseClipboard(); wcout< > MySpChStW; MySpChStW.vsSpaceStruct.push_back( sSpaceEqW); // Space Equivalent MySpChStW.vsSpaceStruct.push_back( sSpaceBeforeW); // Space Before MySpChStW.vsSpaceStruct.push_back( sSpaceAfterW); // Space After MySpChStW.vsSpaceStruct.push_back( sSpaceAroundW); // Space Around MySpChStW.vsSpaceStruct.push_back( sSpaceNOSpaceW); // Space Delete Both Before AND After MySpChStW.vsSpaceStruct.push_back( sSpaceIgnoreW); // Space Ignore, BUT Case as for _Word_Case_Begin // // {DfSp > MyDfSp(sSpaceDefaultW,sSpaceEqW,_MultipleSpaces_Delete); sWLocalString=MyDfSp.ProcessSpaces(sWLocalString); }// Deafault Space Character // wcout< > MyCAW(MySpChStW, clWC, sSpaceDefaultW, sWSentenceCharacter, sWDestroy_NewSentence, sWApostropheC); {pFW *pFd=new (pFW); *pFd=&CaseFunction_External; MyCAW.SetCustomCase(*pFd); delete pFd; pFd=NULL; } sWLocalString=MyCAW.CaseProcess(sWLocalString); } wcout< > MyDfSp(sSpaceDefaultW,sSpaceEqW,_MultipleSpaces_DeleteOK); sWFileExtension=MyDfSp.ProcessSpaces(sWFileExtension); } // Default Space: Delete ALL Spaces in File Extension // if(FileExtensionFormat!=_Word_Case_NOP) {// /// FILE EXTENSION FORMATTING // WordCase clCFE( FileExtensionFormat, // Case of Beginning of Word = FileExtensionFormat FileExtensionFormat, // Case of Middle of the Word = FileExtensionFormat FileExtensionFormat); // Case of Word beginning NEW Sentence = FileExtensionFormat /// SpChStW > SpChStW_Empty; // Just an EMPTY class {CAW > MyCAW(SpChStW_Empty, clCFE, sSpaceDefaultW, sWSentenceCharacter, sWDestroy_NewSentence, sWApostropheC); pFW *pFd=new (pFW); *pFd=&CaseFunction_External;MyCAW.SetCustomCase(*pFd); delete pFd; pFd=NULL; sWFileExtension=MyCAW.CaseProcess(sWFileExtension); } } // End of IF(!_Case_NOP) wcout< osbIt(wcout); for(irws=sWLocalString.rbegin();irws