-
Notifications
You must be signed in to change notification settings - Fork 946
Expand file tree
/
Copy pathbaseParser.h
More file actions
58 lines (47 loc) · 1.78 KB
/
Copy pathbaseParser.h
File metadata and controls
58 lines (47 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// SPDX-License-Identifier: BSD-3-Clause
// Copyright (c) 2019-2025, The OpenROAD Authors
#pragma once
#include <string>
#include <vector>
#include "yaml-cpp/yaml.h"
namespace utl {
class Logger;
}
namespace odb {
struct Coordinate;
struct Header;
class BaseParser
{
public:
BaseParser(utl::Logger* logger);
virtual ~BaseParser() = default;
protected:
// YAML helper methods
template <typename T>
void extractValue(const YAML::Node& node, const std::string& key, T& value);
template <typename T>
void extractValue(const YAML::Node& node, T& value);
void parseCoordinate(Coordinate& coord, const YAML::Node& coord_node);
void parseCoordinates(std::vector<Coordinate>& coords,
const YAML::Node& coords_node);
void parseHeader(Header& header, const YAML::Node& header_node);
void parseDefines(std::string& content);
std::string resolvePath(const std::string& path);
void resolvePaths(const std::string& path, std::vector<std::string>& paths);
// Extracts a single resolved path from a YAML list-of-strings under
// parent[key], honoring wildcard expansion. Returns "" when the key is
// absent or the (expanded) list is empty. Emits a parser error when the
// expanded set has more than one file (cardinality > 1 is unsupported per
// the 3DBlox external spec). `context` identifies the owning element in the
// error message.
std::string extractSinglePathFromList(const YAML::Node& parent,
const std::string& key,
const std::string& context);
// Utility methods
void logError(const std::string& message);
std::string trim(const std::string& str);
// Member variables
utl::Logger* logger_ = nullptr;
std::string current_file_path_;
};
} // namespace odb