#ifndef _tedit_h_
#define _tedit_h_
#define NO_PRIORITY_OPERATION 0x0000
#define COMPARE_OPERATIONS 0x0001
#define ARITHMETY_OPERATIONS 0X0010
#define LOGIC_OPERATIONS 0x0100
#define SYNTAX_ELEMENTS 0x1000
/* TYPE __string__ DEFINITION */
typedef struct __string__
{
int length; // STRING LENGTH
char *text; // POINTER TO TEXT
}STR;
/* END OF TYPE __string__ DEFINITION */
/* DEFINITION OF 'IPriorityController' CLASS
THIS CLASS CHECKS FOR PRIORITY ELEMENT AND
RETURNS TYPE OF PRIORITY */
class IPriorityController
{
private:
public:
/* DEFAULT CTOR DEFINITION */
IPriorityController ()
{
}
/* END OF DEFAULT CTOR DEFINITION */
/* DTOR DEFINITION */
~IPriorityController ()
{
}
/* END OF DTOR DEFINITION */
public:
/* THIS METHODS CHECKS PRIORITY ELEMENT */
short KindOfPriority (char ch)
{
short kindofoperation = NO_PRIORITY_OPERATION;
if (ch == '<' || ch == '>' || ch == '=' || ch == '!')
kindofoperation |= COMPARE_OPERATIONS;
if (ch == '+' || ch == '-' || ch == '*' || ch == '/' ||
ch == '=' || ch == '%')
kindofoperation |= ARITHMETY_OPERATIONS;
if (ch == '&' || ch == '|' || ch == '!' || ch == '^')
kindofoperation |= LOGIC_OPERATIONS;
if (ch == ';' || ch == '.' || ch == ',' ||
ch == '(' || ch == ')' ||
ch == '{' || ch == '}' ||
ch == '[' || ch == ']')
kindofoperation = SYNTAX_ELEMENTS;
return kindofoperation;
}
/* END OF 'KindOfPriority' METHOD */
bool IsPriority (char ch)
{
if (ch == ';' || ch == '.' || ch == ',' ||
ch == '(' || ch == ')' ||
ch == '=' || ch == '<' || ch == '>' || ch == '!' ||
ch == '[' || ch == ']' ||
ch == '{' || ch == '}' ||
ch == '^' ||
ch == '/' || ch == '*' || ch == '-' || ch == '+' ||
ch == '&' || ch == '|' )
return true;
return false;
}
/* END OF 'IsPriority' METHOD */
};
/* END OF 'IPriorityController' CLASS DEFINITION */
/* DEFINITION OF 'ITextEditor' CLASS
THIS CLASS IS FOR SIMPLE TEXT OPERATIONS */
class ITextFormatter : IPriorityController
{
/********************************************************************
PRIVATE MEMBERS DEFINITIONS
********************************************************************/
private:
bool BuildedText; // TRUE IF TEXT IS BUILDED
STR FirstText; // DEFAULT TEXT
STR OutText; // FORMATTED TEXT
int POSITION; // POSITION IN FORMATTED TEXT
private:
/* THIS METHOD DELETES COMENTS (AS C++ COMENTS) */
/* THIS METHOD IS NOT YET COMPLIETED */
void DeleteComents (void)
{
OutText.length = FirstText.length;
OutText.text = FirstText.text;
}
/* END OF 'DeleteLines' METHOD */
/* REDUCE SPACES METHOD DEFINITION */
void ReduceSpaces (void)
{
char *result = (char*)malloc (0);
int pos = 0, i = 0;
bool SPACE = false;
while (i < OutText.length)
Уважаемый посетитель!
Чтобы распечатать файл, скачайте его (в формате Word).
Ссылка на скачивание - внизу страницы.