diff --git a/include/gds-render/layer/mapping-parser.h b/include/gds-render/layer/mapping-parser.h index cca1318..2b77fbc 100644 --- a/include/gds-render/layer/mapping-parser.h +++ b/include/gds-render/layer/mapping-parser.h @@ -36,17 +36,6 @@ #include #include -/** - * @brief Load a line from \p stream and parse try to parse it as layer information - * @param stream Input data stream - * @param export Layer shall be exported - * @param name Layer name. Free returned pointer after using. - * @param layer Layer number - * @param color RGBA color. - * @return 1 if malformatted line, 0 if parsing was successful and parameters are valid, -1 if file end - */ -int mapping_parser_load_line(GDataInputStream *stream, gboolean *export, char **name, int *layer, GdkRGBA *color); - /** * @brief Create Line for LayerMapping file with supplied information * @param layer_element information diff --git a/layer/mapping-parser.c b/layer/mapping-parser.c index ad0d1e7..94d854a 100644 --- a/layer/mapping-parser.c +++ b/layer/mapping-parser.c @@ -31,69 +31,6 @@ #include -int mapping_parser_load_line(GDataInputStream *stream, gboolean *export, char **name, int *layer, GdkRGBA *color) -{ - int ret; - gsize len; - gchar *line; - GRegex *regex; - GMatchInfo *mi; - char *match; - - if ((!export) || (!name) || (!layer) || (!color)) { - ret = 1; - goto ret_direct; - } - - regex = g_regex_new("^(?[0-9]+),(?[0-9\\.]+),(?[0-9\\.]+),(?[0-9\\.]+),(?[0-9\\.]+),(?[01]),(?.*)$", 0, 0, NULL); - - line = g_data_input_stream_read_line(stream, &len, NULL, NULL); - if (!line) { - ret = -1; - goto destroy_regex; - } - - /* Match line in CSV */ - g_regex_match(regex, line, 0, &mi); - if (g_match_info_matches(mi)) { - /* Line is valid */ - match = g_match_info_fetch_named(mi, "layer"); - *layer = (int)g_ascii_strtoll(match, NULL, 10); - g_free(match); - match = g_match_info_fetch_named(mi, "r"); - color->red = g_ascii_strtod(match, NULL); - g_free(match); - match = g_match_info_fetch_named(mi, "g"); - color->green = g_ascii_strtod(match, NULL); - g_free(match); - match = g_match_info_fetch_named(mi, "b"); - color->blue = g_ascii_strtod(match, NULL); - g_free(match); - match = g_match_info_fetch_named(mi, "a"); - color->alpha = g_ascii_strtod(match, NULL); - g_free(match); - match = g_match_info_fetch_named(mi, "export"); - *export = ((!strcmp(match, "1")) ? TRUE : FALSE); - g_free(match); - match = g_match_info_fetch_named(mi, "name"); - *name = match; - - ret = 0; - } else { - /* Line is malformatted */ - printf("Could not recognize line in CSV as valid entry: %s\n", line); - ret = 1; - } - - g_match_info_free(mi); - g_free(line); -destroy_regex: - g_regex_unref(regex); -ret_direct: - return ret; - -} - void mapping_parser_gen_csv_line(LayerElement *layer_element, char *line_buffer, size_t max_len) { int i;