Skip to content

doxide.hpp

 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#pragma once

#include <string>
#include <regex>
#include <stack>
#include <list>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <filesystem>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <variant>
#include <regex>

#include <cassert>

#include <yaml.h>
#include <tree_sitter/api.h>
#include <glob/glob.hpp>
#include <CLI/CLI.hpp>

/**
 * Print a warning message.
 * 
 * @ingroup developer
 */
#define warn(msg) \
    std::cerr << "warning: " << msg << std::endl;

/**
 * Print an error message and exit.
 * 
 * @ingroup developer
 */
#define error(msg) \
    std::cerr << "error: " << msg << std::endl; \
    exit(EXIT_FAILURE);

/**
 * Regular expression configuration.
 * 
 * @ingroup developer
 */
static const std::regex_constants::syntax_option_type regex_flags =
    std::regex_constants::ECMAScript|std::regex_constants::optimize;

/**
 * Write a whole file.
 * 
 * @ingroup developer
 */
void write_file(const std::string& contents, const std::filesystem::path& dst);

/**
 * Write a whole file, prompting to confirm overwrite if it already exists.
 * 
 * @ingroup developer
 */
void write_file_prompt(const std::string& contents, const std::filesystem::path& dst);

/**
 * Read in a whole file.
 * 
 * @ingroup developer
 */
std::string gulp(const std::filesystem::path& src);

/**
 * Tree-sitter C++ language handle.
 * 
 * @ingroup developer
 */
extern "C" const TSLanguage* tree_sitter_cpp();

/**
 * Tree-sitter CUDA language handle.
 * 
 * @ingroup developer
 */
extern "C" const TSLanguage* tree_sitter_cuda();