diff --git a/cpp/tex_parser/Makefile b/cpp/tex_parser/Makefile index 09efd13..c3c6f8b 100644 --- a/cpp/tex_parser/Makefile +++ b/cpp/tex_parser/Makefile @@ -10,7 +10,7 @@ ifeq ($(mode),) mode = debug endif ifeq ($(mode),debug) - CFLAGS = -O0 -g -std=gnu++98 -pedantic -Wextra -Wconversion + CFLAGS = -O0 -g -std=c++0x -pedantic -Wextra -Wconversion LDFLAGS = endif ifeq ($(mode),profile) @@ -51,11 +51,13 @@ endif %.o : $(CXX) -c $(CFLAGS) $(LDFLAGS) $(INCLUDE) -o $@ $< -tex_table_class_test_obj = xmalloc.o xerror.o -tex_table_class_test: tex_table_class_test.o $(tex_table_class_test_obj) - $(CXX) $(CFLAGS) $(LDFLAGS) $(INCLUDE) -o $@ tex_table_class_test.o $(tex_table_class_test_obj) +tex_table_class_test_obj = tex_table_class_test.o tex_table_class.o xmalloc.o xerror.o +tex_table_class_test: $(tex_table_class_test_obj) + $(CXX) $(CFLAGS) $(LDFLAGS) $(INCLUDE) -o $@ $(tex_table_class_test_obj) -tex_table_class_test.o: tex_table_class_test.cpp $(tex_table_class_test_obj) +tex_table_class_test.o: tex_table_class_test.cpp tex_table_class.o + +tex_table_class.o: tex_table_class.[c,h]pp xmalloc.o xmalloc.o: $(KOLAN_INCLUDE)/xmalloc.[c,h] xerror.o diff --git a/cpp/tex_parser/tex_table_class.cpp b/cpp/tex_parser/tex_table_class.cpp index dfa5417..ba39a6c 100644 --- a/cpp/tex_parser/tex_table_class.cpp +++ b/cpp/tex_parser/tex_table_class.cpp @@ -1,18 +1,22 @@ -#include "table_class.hpp" +#include "tex_table_class.hpp" + +#include #include "tex_table_class_tags.hpp" -int parse_table(const char *table_source, table_c *table) +int parse_table(const char *table_source, table_c *table, struct xerror_s *error) { size_t table_source_len = strlen(table_source); for (size_t i = 0; i < table_source_len; i++) { char c = table_source[i]; - - - + c = c; } + table->id = 3; + + error->message = NULL; + return 0; } diff --git a/cpp/tex_parser/tex_table_class.hpp b/cpp/tex_parser/tex_table_class.hpp index 314db12..4e215e0 100644 --- a/cpp/tex_parser/tex_table_class.hpp +++ b/cpp/tex_parser/tex_table_class.hpp @@ -4,50 +4,57 @@ #include #include +#include "xerror.h" + /* Ячейка. * Если встречается ячейка с \multicolumn{n}, то * следующие n-1 ячеек в таблице пустые и при компиляции * к ним не добавляется символ & */ class cell_c { - std::string before; - std::string request; - std::string after; + public: + std::string before; + std::string request; + std::string after; }; /* Строка. * Заканчивается тегом "\tabularnewline" */ class row_c { - std::string before; - std::vector cells; - std::string after; + public: + std::string before; + std::vector cells; + std::string after; }; /* \hline\multicolumn{8}{|c|}{Сводный протокол результатов испытания двигателя ТВ7-117В \textnumero{}}\tabularnewline\multicolumn{8}{|c|}{Стенд \textnumero{}18 ~~ ИУД СИК ~ Дата: ~~~~~~~~ г. Время:~~~~~~~~~ Рн = ~~~ мм рт ст~~ tвх = ~~~ $\,^{\circ}\mbox{C}$}\tabularnewline\multicolumn{8}{|c|}{Характеристика ~~~~~~~ Акт сдачи, контрольные точки}\tabularnewline\hline\endhead */ class header_c { - std::string before; - std::vector rows; - std::string after; + public: + std::string before; + std::vector rows; + std::string after; }; /* \hline\multicolumn{2}{|>{\centering}m{0.11\linewidth}|}{\centering{}Составил} & \multicolumn{2}{c|}{Инженер по испытаниям} & Начальник БТК & Начальник участка УИД СИК & \multicolumn{2}{c|}{Представитель заказчика}\tabularnewline\hline\multicolumn{2}{|>{\centering}p{0.11\linewidth}|}{\centering{}\textit{Подпись}} & \multicolumn{2}{c|}{\textit{Подпись}} & \centering{}\textit{Подпись} & \centering{}\textit{Подпись} & \multicolumn{2}{c|}{\textit{Подпись}}\tabularnewline\multicolumn{2}{|>{\centering}p{0.11\linewidth}|}{\textit{фамилия}} & \multicolumn{2}{c|}{\textit{фамилия}} & \multicolumn{1}{c|}{\textit{фамилия}} & \textit{фамилия} & \multicolumn{2}{c|}{\textit{фамилия}}\tabularnewline\hline\endfoot */ class footer_c { - std::string before; - std::vector rows; - std::string after; + public: + std::string before; + std::vector rows; + std::string after; }; class table_c { - std::string id; // "Drossel1.Table1" - std::vector columns_scheme; // "|>{\centering}m{0.1\paperwidth}" - header_c header; - footer_c footer; - std::vector rows; + public: + std::string id; // "Drossel1.Table1" + std::vector columns_scheme; // "|>{\centering}m{0.1\paperwidth}" + header_c header; + footer_c footer; + std::vector rows; }; -int parse_table(const char *table_source, table_c *table); +int parse_table(const char *table_source, table_c *table, struct xerror_s *error); #endif // TEX_TABLE_CLASS diff --git a/cpp/tex_parser/tex_table_class_tags.hpp b/cpp/tex_parser/tex_table_class_tags.hpp index df44f94..26dc214 100644 --- a/cpp/tex_parser/tex_table_class_tags.hpp +++ b/cpp/tex_parser/tex_table_class_tags.hpp @@ -1,16 +1,16 @@ #ifndef TEX_TABLE_CLASS_TAGS_HPP #define TEX_TABLE_CLASS_TAGS_HPP -const char *TAG_BEGIN "begin" -const char *TAG_CLINE "cline" -const char *TAG_END "end" -const char *TAG_ENDFOOT "endfoot" -const char *TAG_ENDHEAD "endhead" -const char *TAG_HLINE "hline" -const char *TAG_HSPACE "hspace" -const char *TAG_MULTICOLUMN "multicolumn" -const char *TAG_MULTIROW "multirow" -const char *TAG_TABULARNEWLINE "tabularnewline" +const char *TAG_BEGIN = "begin"; +const char *TAG_CLINE = "cline"; +const char *TAG_END = "end"; +const char *TAG_ENDFOOT = "endfoot"; +const char *TAG_ENDHEAD = "endhead"; +const char *TAG_HLINE = "hline"; +const char *TAG_HSPACE = "hspace"; +const char *TAG_MULTICOLUMN = "multicolumn"; +const char *TAG_MULTIROW = "multirow"; +const char *TAG_TABULARNEWLINE = "tabularnewline"; const char *ALL_TAGS[] { TAG_BEGIN, diff --git a/cpp/tex_parser/tex_table_class_test.cpp b/cpp/tex_parser/tex_table_class_test.cpp index 330847b..a397ef4 100644 --- a/cpp/tex_parser/tex_table_class_test.cpp +++ b/cpp/tex_parser/tex_table_class_test.cpp @@ -3,6 +3,7 @@ #include #include +#include "tex_table_class.hpp" #include "xmalloc.h" #include "xerror.h" @@ -26,6 +27,10 @@ int main(int argc, char *argv[]) xerrx(errno, "Error reading %s", argv[1]); tex_buf[stat_buf.st_size] = 0; + struct xerror_s error; + struct table_c table; + parse_table(tex_buf, &table, &error); + fclose(tex_file); return EXIT_SUCCESS;