no c++ just c
--HG-- rename : c/tex_parser/tex_table_class.cpp => c/tex_parser/tex_table.c rename : c/tex_parser/tex_table_class.geany => c/tex_parser/tex_table.geany rename : c/tex_parser/tex_table_class.hpp => c/tex_parser/tex_table.h rename : c/tex_parser/tex_table_class_tags.hpp => c/tex_parser/tex_table_tags.h rename : c/tex_parser/tex_table_class_test.cpp => c/tex_parser/tex_table_test.c
This commit is contained in:
parent
cc27cee3be
commit
0f3ecd8e70
|
@ -16,7 +16,7 @@ long_line_behaviour=1
|
|||
long_line_column=72
|
||||
|
||||
[files]
|
||||
current_page=1
|
||||
current_page=0
|
||||
FILE_NAME_0=781;C;0;16;1;1;1;/home/kolan/dev/c/realloc_speed_test/realloc_speed_test_c.c;0
|
||||
FILE_NAME_1=515;C++;0;16;1;1;1;/home/kolan/dev/c/realloc_speed_test/realloc_speed_test_cpp.cpp;0
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ ifeq ($(mode),)
|
|||
mode = debug
|
||||
endif
|
||||
ifeq ($(mode),debug)
|
||||
CFLAGS = -O0 -g -std=c++0x -pedantic -Wextra -Wconversion
|
||||
CFLAGS = -O0 -g -std=gnu99 -pedantic -Wextra -Wconversion
|
||||
LDFLAGS =
|
||||
endif
|
||||
ifeq ($(mode),profile)
|
||||
|
@ -26,10 +26,12 @@ ifeq ($(mode),release)
|
|||
LDFLAGS += -O1
|
||||
endif
|
||||
|
||||
CFLAGS += -Wall $(shell pkg-config --cflags liblist)
|
||||
LDFLAGS += -Wall $(shell pkg-config --libs liblist) -lpthread -lexpat
|
||||
CFLAGS += -Wall
|
||||
#~ $(shell pkg-config --cflags liblist)
|
||||
LDFLAGS += -Wall
|
||||
#~ $(shell pkg-config --libs liblist) -lpthread -lexpat
|
||||
|
||||
all: tex_table_class_test
|
||||
all: tex_table_test
|
||||
|
||||
ifneq ($(mode),debug)
|
||||
ifneq ($(mode),profile)
|
||||
|
@ -45,25 +47,27 @@ endif
|
|||
@echo ".........................."
|
||||
@echo "Building on "$(mode)" mode "
|
||||
@echo "CFLAGS=$(CFLAGS)"
|
||||
@echo "LDLAGS=$(LDFLAGS)"
|
||||
@echo "LDFLAGS=$(LDFLAGS)"
|
||||
@echo ".........................."
|
||||
|
||||
%.o :
|
||||
$(CXX) -c $(CFLAGS) $(LDFLAGS) $(INCLUDE) -o $@ $<
|
||||
$(CC) -c $(CFLAGS) $(LDFLAGS) $(INCLUDE) -o $@ $<
|
||||
|
||||
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_test_obj = tex_table_test.o tex_table.o zmalloc.o xmalloc.o xerror.o
|
||||
tex_table_test: $(tex_table_test_obj)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) $(INCLUDE) -o $@ $(tex_table_test_obj)
|
||||
|
||||
tex_table_class_test.o: tex_table_class_test.cpp tex_table_class.o
|
||||
tex_table_test.o: tex_table_test.c tex_table.o
|
||||
|
||||
tex_table_class.o: tex_table_class.[c,h]pp xmalloc.o
|
||||
tex_table.o: tex_table.c tex_table.h zmalloc.o xmalloc.o
|
||||
|
||||
xmalloc.o: $(KOLAN_INCLUDE)/xmalloc.[c,h] xerror.o
|
||||
zmalloc.o: $(KOLAN_INCLUDE)/zmalloc.c $(KOLAN_INCLUDE)/zmalloc.h xerror.o
|
||||
|
||||
xerror.o: $(KOLAN_INCLUDE)/xerror.[c,h]
|
||||
xmalloc.o: $(KOLAN_INCLUDE)/xmalloc.c $(KOLAN_INCLUDE)/xmalloc.h xerror.o
|
||||
|
||||
xerror.o: $(KOLAN_INCLUDE)/xerror.c $(KOLAN_INCLUDE)/xerror.h
|
||||
|
||||
clean:
|
||||
$(RM) *.o *.out callgrind.out.* *.gcno tex_table_class_test
|
||||
$(RM) *.o *.out callgrind.out.* *.gcno tex_table_test
|
||||
|
||||
.PHONY: all clean
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
#include "tex_table.h"
|
||||
|
||||
#include "tex_table_tags.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
int parse_table(const char *table_source, size_t len, struct table_s *table, struct xerror_s *error)
|
||||
{
|
||||
if (!len)
|
||||
len = strlen(table_source);
|
||||
|
||||
for (size_t i = 0; i < len; i++) {
|
||||
char c = table_source[i];
|
||||
|
||||
c = c;
|
||||
}
|
||||
|
||||
table->id = "Drossel1.Table1";
|
||||
|
||||
error->message = NULL;
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -8,7 +8,7 @@ indent_mode=2
|
|||
|
||||
[project]
|
||||
name=tex_table_class
|
||||
base_path=/home/kolan/dev/cpp/tex_parser/
|
||||
base_path=/home/kolan/dev/c/tex_parser/
|
||||
description=
|
||||
|
||||
[long line marker]
|
||||
|
@ -16,15 +16,12 @@ long_line_behaviour=1
|
|||
long_line_column=72
|
||||
|
||||
[files]
|
||||
current_page=5
|
||||
FILE_NAME_0=116;C++;0;61;1;1;1;/home/kolan/dev/cpp/tex_parser/tex_table_class_test.cpp;0
|
||||
FILE_NAME_1=370;C++;0;61;1;1;1;/home/kolan/dev/cpp/tex_parser/tex_table_class.cpp;0
|
||||
FILE_NAME_2=0;C++;0;61;1;1;1;/home/kolan/dev/cpp/tex_parser/tex_table_class.hpp;0
|
||||
FILE_NAME_3=0;C++;0;61;1;1;1;/home/kolan/dev/cpp/tex_parser/tex_table_class_tags.hpp;0
|
||||
FILE_NAME_4=0;Make;0;61;1;1;1;/home/kolan/dev/cpp/tex_parser/Makefile;0
|
||||
FILE_NAME_5=314;C;0;16;1;1;1;/home/kolan/projects/include/xmalloc.c;0
|
||||
FILE_NAME_6=252;LaTeX;0;45;1;1;1;/home/kolan/dev/cpp/tex_parser/tables4.tex;0
|
||||
FILE_NAME_7=0;LaTeX;0;45;1;1;1;/home/kolan/dev/cpp/tex_parser/tables5.tex;0
|
||||
current_page=2
|
||||
FILE_NAME_0=375;C;0;16;1;1;1;/home/kolan/dev/c/tex_parser/tex_table_test.c;0
|
||||
FILE_NAME_1=53;C;0;16;1;1;1;/home/kolan/dev/c/tex_parser/tex_table.c;0
|
||||
FILE_NAME_2=2213;C;0;16;1;1;1;/home/kolan/dev/c/tex_parser/tex_table.h;0
|
||||
FILE_NAME_3=0;C;0;16;1;1;1;/home/kolan/dev/c/tex_parser/tex_table_tags.h;0
|
||||
FILE_NAME_4=1725;Make;0;16;1;1;1;/home/kolan/dev/c/tex_parser/Makefile;0
|
||||
|
||||
[build-menu]
|
||||
NF_00_LB=_Сделать
|
|
@ -1,8 +1,7 @@
|
|||
#ifndef TEX_TABLE_CLASS
|
||||
#define TEX_TABLE_CLASS
|
||||
#ifndef TEX_TABLE_H
|
||||
#define TEX_TABLE_H
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "xerror.h"
|
||||
|
||||
|
@ -11,50 +10,45 @@
|
|||
* следующие n-1 ячеек в таблице пустые и при компиляции
|
||||
* к ним не добавляется символ &
|
||||
*/
|
||||
class cell_c {
|
||||
public:
|
||||
std::string before;
|
||||
std::string request;
|
||||
std::string after;
|
||||
struct cell_s {
|
||||
char *before;
|
||||
char *request;
|
||||
char *after;
|
||||
};
|
||||
|
||||
/* Строка.
|
||||
* Заканчивается тегом "\tabularnewline"
|
||||
*/
|
||||
class row_c {
|
||||
public:
|
||||
std::string before;
|
||||
std::vector<cell_c> cells;
|
||||
std::string after;
|
||||
struct row_s {
|
||||
char *before;
|
||||
struct cell_s *cells;
|
||||
char *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 {
|
||||
public:
|
||||
std::string before;
|
||||
std::vector<row_c> rows;
|
||||
std::string after;
|
||||
struct header_s {
|
||||
char *before;
|
||||
struct row_s *rows;
|
||||
char *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 {
|
||||
public:
|
||||
std::string before;
|
||||
std::vector<row_c> rows;
|
||||
std::string after;
|
||||
struct footer_s {
|
||||
char *before;
|
||||
struct row_s *rows;
|
||||
char *after;
|
||||
};
|
||||
|
||||
class table_c {
|
||||
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;
|
||||
struct table_s {
|
||||
char *id; // "Drossel1.Table1"
|
||||
char **coumnt_scheme; // "|>{\centering}m{0.1\paperwidth}"
|
||||
struct header_s header;
|
||||
struct footer_s footer;
|
||||
struct row_s *rows;
|
||||
};
|
||||
|
||||
int parse_table(const char *table_source, table_c *table, struct xerror_s *error);
|
||||
int parse_table(const char *table_source, size_t len, struct table_s *table, struct xerror_s *error);
|
||||
|
||||
#endif // TEX_TABLE_CLASS
|
||||
#endif // TEX_TABLE_H
|
|
@ -1,22 +0,0 @@
|
|||
#include "tex_table_class.hpp"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "tex_table_class_tags.hpp"
|
||||
|
||||
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;
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
#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 *ALL_TAGS[] {
|
||||
TAG_BEGIN,
|
||||
TAG_CLINE,
|
||||
TAG_END,
|
||||
TAG_ENDFOOT,
|
||||
TAG_ENDHEAD,
|
||||
TAG_HLINE,
|
||||
TAG_HSPACE,
|
||||
TAG_MULTICOLUMN,
|
||||
TAG_MULTIROW,
|
||||
TAG_TABULARNEWLINE
|
||||
};
|
||||
|
||||
|
||||
#endif // TEX_TABLE_CLASS_TAGS_HPP
|
|
@ -0,0 +1,28 @@
|
|||
#ifndef TEX_TABLE_H
|
||||
#define TEX_TABLE_H
|
||||
|
||||
const char *TEX_TAG_BEGIN = "begin";
|
||||
const char *TEX_TAG_CLINE = "cline";
|
||||
const char *TEX_TAG_END = "end";
|
||||
const char *TEX_TAG_ENDFOOT = "endfoot";
|
||||
const char *TEX_TAG_ENDHEAD = "endhead";
|
||||
const char *TEX_TAG_HLINE = "hline";
|
||||
const char *TEX_TAG_HSPACE = "hspace";
|
||||
const char *TEX_TAG_MULTICOLUMN = "multicolumn";
|
||||
const char *TEX_TAG_MULTIROW = "multirow";
|
||||
const char *TEX_TAG_TABULARNEWLINE = "tabularnewline";
|
||||
|
||||
const char *ALL_TAGS[] {
|
||||
TEX_TAG_BEGIN,
|
||||
TEX_TAG_CLINE,
|
||||
TEX_TAG_END,
|
||||
TEX_TAG_ENDFOOT,
|
||||
TEX_TAG_ENDHEAD,
|
||||
TEX_TAG_HLINE,
|
||||
TEX_TAG_HSPACE,
|
||||
TEX_TAG_MULTICOLUMN,
|
||||
TEX_TAG_MULTIROW,
|
||||
TEX_TAG_TABULARNEWLINE
|
||||
};
|
||||
|
||||
#endif // TEX_TABLE_H
|
|
@ -1,15 +1,17 @@
|
|||
#include <sys/stat.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "tex_table_class.hpp"
|
||||
#include "tex_table.h"
|
||||
#include "zmalloc.h"
|
||||
#include "xmalloc.h"
|
||||
#include "xerror.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
if (argc != 2)
|
||||
xerrx(-1, "Usage: ./tex_table_class_test /path/to/table.tex", NULL);
|
||||
xerrx(-1, "Usage: ./tex_table_test /path/to/table.tex", NULL);
|
||||
|
||||
FILE *tex_file = fopen(argv[1], "rb");
|
||||
if (!tex_file)
|
||||
|
@ -22,13 +24,14 @@ int main(int argc, char *argv[])
|
|||
char *tex_buf = (char *)xmalloc((size_t)stat_buf.st_size + 1);
|
||||
if (fread(tex_buf, 1, (size_t)stat_buf.st_size, tex_file) != (size_t)stat_buf.st_size)
|
||||
xerrx(errno, "Error reading %s", argv[1]);
|
||||
fclose(tex_file);
|
||||
tex_buf[stat_buf.st_size] = 0;
|
||||
|
||||
struct xerror_s error;
|
||||
struct table_c table;
|
||||
parse_table(tex_buf, &table, &error);
|
||||
struct table_s table;
|
||||
parse_table(tex_buf, (size_t)stat_buf.st_size, &table, &error);
|
||||
|
||||
fclose(tex_file);
|
||||
xfree(&tex_buf);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
Loading…
Reference in New Issue