#include включён tex_table_class.[c,h]pp

This commit is contained in:
Kolan Sh 2011-06-08 15:13:26 +04:00
parent 18d143405e
commit a2ef429f94
5 changed files with 56 additions and 38 deletions

View File

@ -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

View File

@ -1,18 +1,22 @@
#include "table_class.hpp"
#include "tex_table_class.hpp"
#include <string.h>
#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;
}

View File

@ -4,50 +4,57 @@
#include <vector>
#include <string>
#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<cell_c> cells;
std::string after;
public:
std::string before;
std::vector<cell_c> 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<row_c> rows;
std::string after;
public:
std::string before;
std::vector<row_c> 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<row_c> rows;
std::string after;
public:
std::string before;
std::vector<row_c> rows;
std::string after;
};
class table_c {
std::string id; // "Drossel1.Table1"
std::vector<std::string> columns_scheme; // "|>{\centering}m{0.1\paperwidth}"
header_c header;
footer_c footer;
std::vector<row_c> rows;
public:
std::string id; // "Drossel1.Table1"
std::vector<std::string> columns_scheme; // "|>{\centering}m{0.1\paperwidth}"
header_c header;
footer_c footer;
std::vector<row_c> 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

View File

@ -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,

View File

@ -3,6 +3,7 @@
#include <sys/stat.h>
#include <errno.h>
#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;