TraceMaker
C++ API of the engine
Loading...
Searching...
No Matches
sexpr.hpp File Reference

Lossless s-expression documents for KiCad files (design doc 08 §3). More...

#include <charconv>
#include <cstdint>
#include <optional>
#include <span>
#include <stdexcept>
#include <string>
#include <string_view>
#include <vector>

Go to the source code of this file.

Classes

struct  tmk::sexpr::Node
class  tmk::sexpr::ParseError
class  tmk::sexpr::Document

Namespaces

namespace  tmk
namespace  tmk::sexpr

Typedefs

using tmk::sexpr::NodeId = std::uint32_t

Enumerations

enum class  tmk::sexpr::Kind : std::uint8_t { tmk::sexpr::List , tmk::sexpr::Symbol , tmk::sexpr::String }

Functions

std::string tmk::sexpr::quote (std::string_view s)
 Escapes a string for KiCad s-expressions and adds quotes.
std::string tmk::sexpr::format_mm (std::int64_t nm)
 Formats nanometres as a KiCad millimetre number: shortest exact decimal, no trailing zeros ("0.25", "-12", "1.000001").
std::optional< std::int64_t > tmk::sexpr::parse_mm (std::string_view s)
 Parses a decimal millimetre string to nanometres exactly; rounds half away from zero beyond 6 decimals.

Variables

constexpr NodeId tmk::sexpr::kNoNode = 0xFFFFFFFFu

Detailed Description

Lossless s-expression documents for KiCad files (design doc 08 §3).

The parser keeps the original text and records each node's byte span, so writing an unmodified document reproduces the input byte for byte. Edits are recorded as span replacements and insertions and applied on write; untouched text is never re-formatted.

Definition in file sexpr.hpp.