Coverage Report

Created: 2024-11-21 20:24

/root/doris/be/src/geo/wkt_parse.cpp
Line
Count
Source
1
// Licensed to the Apache Software Foundation (ASF) under one
2
// or more contributor license agreements.  See the NOTICE file
3
// distributed with this work for additional information
4
// regarding copyright ownership.  The ASF licenses this file
5
// to you under the Apache License, Version 2.0 (the
6
// "License"); you may not use this file except in compliance
7
// with the License.  You may obtain a copy of the License at
8
//
9
//   http://www.apache.org/licenses/LICENSE-2.0
10
//
11
// Unless required by applicable law or agreed to in writing,
12
// software distributed under the License is distributed on an
13
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
// KIND, either express or implied.  See the License for the
15
// specific language governing permissions and limitations
16
// under the License.
17
18
#include "geo/wkt_parse.h"
19
20
#include "geo/wkt_parse_ctx.h"
21
#include "geo/wkt_parse_type.h" // IWYU pragma: keep
22
#include "geo/wkt_yacc.y.hpp"
23
24
#define YYSTYPE WKT_STYPE
25
#define YY_EXTRA_TYPE WktParseContext*
26
#include "geo/wkt_lex.l.h"
27
28
namespace doris {
29
30
25
GeoParseStatus WktParse::parse_wkt(const char* str, size_t len, GeoShape** shape) {
31
25
    WktParseContext ctx;
32
    // initialize lexer
33
25
    wkt_lex_init_extra(&ctx, &ctx.scaninfo);
34
25
    wkt__scan_bytes(str, len, ctx.scaninfo);
35
36
    // parse
37
25
    auto res = wkt_parse(&ctx);
38
25
    wkt_lex_destroy(ctx.scaninfo);
39
25
    if (res == 0) {
40
16
        *shape = ctx.shape;
41
16
    } else {
42
9
        if (ctx.parse_status == GEO_PARSE_OK) {
43
7
            ctx.parse_status = GEO_PARSE_WKT_SYNTAX_ERROR;
44
7
        }
45
9
    }
46
25
    return ctx.parse_status;
47
25
}
48
49
} // namespace doris