CPPRODOMCS

RAD C++Builder runtime optimiser and Control Store
cppsrodomcs, cpprodomcs, cpprodomc, cpprodoms, cpprocs, cbrocs

Other versions

.h

// ---------------------------------------------------------------------------
/*
 *  @AUTHOR : Jason Robinson
 *  @TITLE : AppCatch
 *  @VERSION : 1.0.0.0
 *  @RELEASE : alpha
 *  @COPYRIGHT : (C)2010. All rights reserved.
 *  @LICENSE : http://www.KitchenPages.com/library/i3/license
 *  @TODO : bug fixing / testing
 */
// ---------------------------------------------------------------------------
#ifndef cppappcatcheH
#define cppappcatcheH
// ---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <ComCtrls.hpp>
#include <AnsiStrings.hpp>

/**
 * -------------------------------------------------------------------------<author>Jason Robinson</author><version>1.0.0.0</version>
 */
class Tappcatche : public TForm {
__published: // IDE-managed Components

	/* @OBJECT : appcatche
	 *  @RETURNS : Object
	 *  @CLASS : appcatche
	 *  General class name given to group functions, methods, events, and values of appcatche.js
	 */

	/* Create RICHEDIT object to hold data
	 */
	TRichEdit *appcatcheformta;

	void __fastcall appcatche__createform_EVENT(TObject *Sender);

	/* @FUNCTION : appcatche.catchstore
	 *  @VALUE : String
	 *  Creates Sender value/s within store
	 */
	void __fastcall appcatche__catchstore(AnsiString &appcatchelinestoStore,
		TObject *Sender);

	/* @FUNCTION : appcatche.catchstoren
	 *  Creates a new store for the Sender
	 *  @SEE : appcatche.catchstore
	 */
	void __fastcall appcatche__catchstoren(AnsiString &appcatchelinetoStore,
		TObject *Sender);

	/* @FUNCTION : appcatche.catchstored
	 *  Closes a new store for the Sender
	 */
	void __fastcall appcatche__catchstored(TObject *Sender);

	/* @FUNCTION : appcatche.ifstr
	 *  @VALUE : String
	 *  @RETURNS : bool
	 *  Searchs stores, and if found returns a value of true as bool to Sender
	 */
	bool __fastcall appcatche__ifstr(AnsiString &appcatchelinetoFind,
		TObject *Sender);

	/* @FUNCTION : appcatche.exestr
	 *  @VALUE : String
	 *  @RETURNS : String
	 *  Searchs for store and returns matching value/s as String to Sender
	 */
	AnsiString __fastcall appcatche__exestr(AnsiString &appcatchelinestoFind,
		TObject *Sender);

	/* @FUNCTION : appcatche.clearstore
	 *  Clears all identification and value/s within store
	 */
	void __fastcall appcatche__clearstore(TObject *Sender);

	/* @FUNCTION : appcatche.usestore
	 *  @VALUE : bool
	 *  Set store mode to true or false for allowing this kind of mode change override; Store mode should always be set to true
	 *  @VALUE : bool
	 *  Set store funciton appcatche.ifstr return bool as override to always be true or false
	 *  @SEE : appcatche.ifstr
	 */
	void __fastcall appcatche__userstore(bool &appcatcheOnOff,
		bool &appcatcheAutoIFset, TObject *Sender);

private: // User declarations
public: // User declarations
	__fastcall Tappcatche(TComponent* Owner);

	// bool appcatcheDebug;
	bool appcatcheAuto;
	bool appcatcheAutoIF;
	/* @VALUE : appcatche.catchstr
	 *  @TYPE : String
	 *  store resource identification String
	 */
	AnsiString appcatche__catchstr;
	// Demo testing only
	// AnsiString testvalue;
};

// ---------------------------------------------------------------------------
extern PACKAGE Tappcatche *appcatche;
// ---------------------------------------------------------------------------
#endif


.cpp

// ---------------------------------------------------------------------------
/*
 *  @AUTHOR : Jason Robinson
 *  @TITLE : AppCatch
 *  @VERSION : 1.0.0.0
 *  @RELEASE : alpha
 *  @COPYRIGHT : (C)2010. All rights reserved.
 *  @LICENSE : http://www.KitchenPages.com/library/i3/license
 *  @TODO : bug fixing / testing
 */
// ---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "cppappcatche.h"
// ---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
Tappcatche *appcatche;

// ---------------------------------------------------------------------------
__fastcall Tappcatche::Tappcatche(TComponent* Owner) : TForm(Owner) {
}

// ---------------------------------------------------------------------------
void __fastcall Tappcatche::appcatche__createform_EVENT(TObject *Sender) { 
	/* @NOTICE : this function was Tappcatche::form_oncreate(TObject *Sender)
	 *  @VALUE : appcatche.catchstr
	 *  @TYPE : String
	 *  store resource identification String
	 */
	appcatcheAuto = false;
	appcatcheAutoIF = true;
	appcatche__catchstr = ""; // this function can be skipped as the function Sender will set the value
	// --------------pretend start of function
	// perform demo one
	// testvalue = "2010";
	// --------------store starts
	/* catche return starts */
	// appcatche__catchstr = "appcatche__createform_EVENT(this)[kpdsquare]";
	// if(appcatche__ifstr(appcatche__catchstr,this)==false){appcatche__catchstoren(AnsiString(appcatche__catchstr),this);
	/* catche return ends */
	// --------------store line
	/* catche return starts */
	// appcatche__catchstore(AnsiString("testvalue = \"" + testvalue + "\";"),this);
	/* catche return ends */
	// --------------store ends
	/* catche return starts */
	// appcatche__catchstored(this); }else{ appcatche__exestr(appcatche__catchstr,this);
	// }/*catche return ends*/
	// --------------end of function
}

/* @FUNCTION : appcatche.catchstore
 *  @VALUE : String
 *  Creates Sender value/s within store
 */
void __fastcall Tappcatche::appcatche__catchstore(AnsiString &appcatchelinestoStore, TObject *Sender) {
	appcatcheformta->Lines->Text = appcatcheformta->Lines->Text +
	appcatchelinestoStore + "";
}

/* @FUNCTION : appcatche.catchstoren
 *  Creates a new store for the Sender
 *  @SEE : appcatche.catchstore
 *  @REQUIRES : AnsiStrings.hpp
 */
void __fastcall Tappcatche::appcatche__catchstoren(AnsiString &appcatchelinetoStore, TObject *Sender) {
	AnsiReplaceText("\r", PChar(WideString(appcatchelinetoStore)),
		appcatchelinetoStore);
	AnsiReplaceText("\n", PChar(WideString(appcatchelinetoStore)),
		appcatchelinetoStore);
	appcatcheformta->Lines->Text = appcatcheformta->Lines->Text +
	appcatchelinetoStore;
}

/* @FUNCTION : appcatche.catchstored
 *  Closes a new store for the Sender
 */
void __fastcall Tappcatche::appcatche__catchstored(TObject *Sender) {
	appcatcheformta->Lines->Text = Trim(appcatcheformta->Lines->Text)
	+ "---appcatched---\r\n";
}

/* @FUNCTION : appcatche.ifstr
 *  @VALUE : String
 *  @RETURNS : bool
 *  Searchs stores, and if found returns a value of true as bool to Sender
 *  @REQUIRES : AnsiStrings.hpp
 */
bool __fastcall Tappcatche::appcatche__ifstr(AnsiString &appcatchelinetoFind, TObject *Sender) {
	bool appcatcheStatus = false;
	if (appcatcheAuto == true) {
		appcatcheStatus = appcatcheAutoIF;
	}
	else {
		if (appcatcheformta->Lines->IndexOf
			(PChar(WideString(appcatchelinetoFind))) != -1) {
			appcatcheStatus = true;
		}
	}
	return appcatcheStatus;
}

/* @FUNCTION : appcatche.exestr
 *  @VALUE : String
 *  @RETURNS : String
 *  Searchs for store and returns matching value/s as String to Sender
 *  @REQUIRES : AnsiStrings.hpp
 */
AnsiString __fastcall Tappcatche::appcatche__exestr(AnsiString &appcatchelinestoFind, TObject *Sender) {
	AnsiString appcatcheESTR = appcatcheformta->Lines->Text;
	int foundatESTR = appcatcheESTR.AnsiPos
	(appcatchelinestoFind + AnsiString("\r\n")) + appcatchelinestoFind.Length
	();
	appcatcheESTR = Trim(appcatcheESTR.SubString(foundatESTR,
			appcatcheESTR.Length()));
	appcatcheESTR = Trim(appcatcheESTR.SubString(0,
			AnsiString(appcatcheESTR).AnsiPos(AnsiString("---appcatched---"))
			- 1));
	return appcatcheESTR;
}

/* FUNCTION : appcatche.clearstore
 *  Clears all identification and value/s within store
 */
void __fastcall Tappcatche::appcatche__clearstore(TObject *Sender) {
	appcatche__catchstr = "";
	appcatcheformta->Lines->Text = "";
}

/* @FUNCTION : appcatche.usestore
 *  @VALUE : bool
 *  Set store mode to true or false for allowing this kind of mode change override; Store mode should always be set to true
 *  @VALUE : bool
 *  Set store funciton appcatche.ifstr return bool as override to always be true or false
 *  @SEE : appcatche.ifstr
 */
void __fastcall Tappcatche::appcatche__userstore(bool &appcatcheOnOff, bool &appcatcheAutoIFset, TObject *Sender) {
	appcatcheAuto = appcatcheOnOff;
	appcatcheAutoIF = appcatcheAutoIFset;
}
// ---------------------------------------------------------------------------


The final function command to reload saved data should be re-directed though a processor; as example:-

myfunctionprocessor( AnsiString( appcatche__exestr(appcatche__catchstr,this) ), this);

Within your myfunctionprocessor function make new code to :- (1) find a known function/s name from the store value, (2) get the function/s args from the store value, (3) execute C++ call/s, (4) repeat until end of stored value

Static, inline run by exact command, example :-
myfunctionprocessor (AnsiString &storevalue, TObject *Sender) {
	if (storevalue.AnsiPos("Button->Caption = myvalue;")) != -1) { 
		Button->Caption = myvalue; 
	}
	if (storevalue.AnsiPos("Button->Caption = someothervalue;")) != -1) { 
		Button->Caption = someothervalue; 
	}
}



Other versions


©Copyright 2010. Rights reserved