Программа преобразования исходного текста на С++ в RTF-файл

Автор работы: Пользователь скрыл имя, 04 Июня 2012 в 12:17, курсовая работа

Краткое описание

Целью курсовой работы является разработка программного продукта, реализующего преобразование Си текста в RTF-файл. Для реализации поставленной цели были определены следующие задачи:
1. Разобрать структуру RTF-файла.
2. Реализовать алгоритм чтения файла.
3. Реализовать алгоритм преобразования Си в RTF.
4. Реализовать запись полученных данных в файл.

Содержание

Введение 3
I.Теоретический раздел 4
1.1 RTF- Rich Text Format 4
II. Технологический раздел 11
2.1. Стандартные заголовочные файлы. 11
2.2.Стандартные типы данных. 13
2.3. Описание собственных функций 14
Заключение 16
Литература 17
Приложение 18

Вложенные файлы: 1 файл

Документ Microsoft Word.doc

— 235.00 Кб (Скачать файл)

}

string colorBREAK(string &text,string &base){

       string str;

        string BREAK("break");

        string afterBREAK("\{\\cf1\\b break\}");

        int position=0;

            position=text.find(BREAK);

            while(position!=-1){

                               str=text.substr(0,position+5);

                               str.replace(position,5,afterBREAK);

                               text=text.substr(position+5);

                               base+=str;

                               return colorBREAK(text,base);

           }

           text=base+text;

           base="";    

                            

return text;                            

}

string colorGOTO(string &text,string &base){

       string str;

        string GOTO("goto");

        string afterGOTO("\{\\cf1\\b goto\}");

        int position=0;

            position=text.find(GOTO);

            while(position!=-1){

                               str=text.substr(0,position+4);

                               str.replace(position,4,afterGOTO);

                               text=text.substr(position+4);

                               base+=str;

                               return colorGOTO(text,base);

           }

           text=base+text;

           base="";    

                            

return text;                            

}

string colorNEW(string &text,string &base){

       string str;

        string NEW("new");

        string afterNEW("\{\\cf1\\b new\}");

        int position=0;

            position=text.find(NEW);

            while(position!=-1){

                               str=text.substr(0,position+3);

                               str.replace(position,3,afterNEW);

                               text=text.substr(position+3);

                               base+=str;

                               return colorNEW(text,base);

           }

           text=base+text;

           base="";    

                            

return text;                            

}

string colorDELETE(string &text,string &base){

        string str;

        string DELETE("delete");

        string afterDELETE("\{\\cf1\\b delete\}");

        int position=0;

            position=text.find(DELETE);

            while(position!=-1){

                               str=text.substr(0,position+6);

                               str.replace(position,6,afterDELETE);

                               text=text.substr(position+6);

                               base+=str;

                               return colorDELETE(text,base);

           }

           text=base+text;

           base="";    

                            

return text;                            

}

string colorNAMESPACE(string &text,string &base){

        string str;

        string NAMESPACE("using namespace");

        string afterNAMESPACE("\{\\cf1\\b using namespace\}");

        int position=0;

            position=text.find(NAMESPACE);

            while(position!=-1){

                               str=text.substr(0,position+15);

                               str.replace(position,15,afterNAMESPACE);

                               text=text.substr(position+15);

                               base+=str;

                               return colorNAMESPACE(text,base);

           }

           text=base+text;

           base="";    

                            

return text;                            

}

string colorINT (string &text,string &base){

                            string str;

                            string INT("int ");

        string afterINT("\{\\cf3 int\}");

                           

                            int position=0; 

           position=text.find(INT);

           while(position!=-1){

                               str=text.substr(0,position+3);

                               str.replace(position,3,afterINT);

                               text=text.substr(position+3);

                               base+=str;

                               return colorINT(text,base);

           }

           text=base+text;

           base="";      

              return text;             

}

string colorCHAR (string &text,string &base){

                            string str;

                            string CHAR("char");

        string afterCHAR("\{\\cf3 char\}");

                           

                            int position=0; 

           position=text.find(CHAR);

           while(position!=-1){

                               str=text.substr(0,position+4);

                               str.replace(position,4,afterCHAR);

                               text=text.substr(position+4);

                               base+=str;

                               return colorCHAR(text,base);

           }

           text=base+text;

           base="";      

              return text;             

}

string colorVOID (string &text,string &base){

                            string str;

                            string VOID("void ");

        string afterVOID("\{\\cf3 void\}");

                           

                            int position=0; 

           position=text.find(VOID);

           while(position!=-1){

                               str=text.substr(0,position+4);

                               str.replace(position,4,afterVOID);

                               text=text.substr(position+4);

                               base+=str;

                               return colorVOID(text,base);

           }

           text=base+text;

           base="";      

              return text;             

}

string colorFLOAT (string &text,string &base){

                            string str;

                            string FLOAT("float ");

        string afterFLOAT("\{\\cf3 float\}");

                           

                            int position=0; 

           position=text.find(FLOAT);

           while(position!=-1){

                               str=text.substr(0,position+5);

                               str.replace(position,5,afterFLOAT);

                               text=text.substr(position+5);

                               base+=str;

                               return colorFLOAT(text,base);

           }

           text=base+text;

           base="";      

              return text;             

}

string colorDOUBLE (string &text,string &base){

                            string str;

                            string DOUBLE("double ");

        string afterDOUBLE("\{\\cf3 double\}");

                           

                            int position=0; 

           position=text.find(DOUBLE);

           while(position!=-1){

                               str=text.substr(0,position+6);

                               str.replace(position,6,afterDOUBLE);

                               text=text.substr(position+6);

                               base+=str;

                               return colorDOUBLE(text,base);

           }

           text=base+text;

           base="";      

              return text;             

}

string colorBOOL (string &text,string &base){

                            string str;

                            string BOOL("bool ");

        string afterBOOL("\{\\cf3 bool\}");

                           

                            int position=0; 

           position=text.find(BOOL);

           while(position!=-1){

                               str=text.substr(0,position+4);

                               str.replace(position,4,afterBOOL);

                               text=text.substr(position+4);

                               base+=str;

                               return colorBOOL(text,base);

           }

           text=base+text;

           base="";      

              return text;             

}

string colorSIGNED (string &text,string &base){

                            string str;

                            string SIGNED("signed ");

        string afterSIGNED("\{\\cf3 signed\}");

                           

                            int position=0; 

           position=text.find(SIGNED);

           while(position!=-1){

                               str=text.substr(0,position+6);

                               str.replace(position,6,afterSIGNED);

                               text=text.substr(position+6);

                               base+=str;

                               return colorSIGNED(text,base);

           }

           text=base+text;

           base="";      

              return text;             

}

string colorUNSIGNED (string &text,string &base){

                            string str;

                            string UNSIGNED("unsigned ");

        string afterUNSIGNED("\{\\cf3 unsigned\}");

                           

                            int position=0; 

           position=text.find(UNSIGNED);

           while(position!=-1){

                               str=text.substr(0,position+8);

                               str.replace(position,8,afterUNSIGNED);

                               text=text.substr(position+8);

                               base+=str;

                               return colorUNSIGNED(text,base);

           }

           text=base+text;

           base="";      

              return text;             

}

string colorLONG (string &text,string &base){

                            string str;

                            string LONG("long ");

        string afterLONG("\{\\cf3 long\}");

                           

                            int position=0; 

           position=text.find(LONG);

           while(position!=-1){

                               str=text.substr(0,position+4);

                               str.replace(position,4,afterLONG);

                               text=text.substr(position+4);

                               base+=str;

                               return colorLONG(text,base);

           }

           text=base+text;

           base="";      

              return text;             

}

string colorSHORT (string &text,string &base){

                            string str;

                            string SHORT("short ");

        string afterSHORT("\{\\cf3 short\}");

                

                            int position=0; 

           position=text.find(SHORT);

           while(position!=-1){

                               str=text.substr(0,position+5);

                               str.replace(position,5,afterSHORT);

                               text=text.substr(position+5);

                               base+=str;

                               return colorSHORT(text,base);

           }

           text=base+text;

           base="";      

Информация о работе Программа преобразования исходного текста на С++ в RTF-файл