blob: a2c2551f6dec6023dc07120b7ca54c69b13beefe (
plain) (
blame)
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
|
/*
* script.hh - Definition of the Script class
* libhscript, the HorizonScript library for
* Project Horizon
*
* Copyright (c) 2019 Adélie Linux and contributors. All rights reserved.
* This code is licensed under the AGPL 3.0 license, as noted in the
* LICENSE-code file in the root directory of this repository.
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
#ifndef __HSCRIPT_SCRIPT_HH_
#define __HSCRIPT_SCRIPT_HH_
#include <string>
#include <vector>
#include <memory>
namespace Horizon {
/**** Script option flags ****/
/*! Don't stop after the first error. */
#define SCRIPT_KEEP_GOING 0x0001
/*! Ensure network resources are available. */
#define SCRIPT_USE_NETWORK 0x0002
/*! Treat warnings as errors. */
#define SCRIPT_STRICT_MODE 0x0004
/*! This is an Installation Environment - validate more keys */
#define SCRIPT_INSTALL_ENV 0x0008
typedef uint32_t ScriptOptions;
/*! Defines the Script class, which represents a HorizonScript. */
class Script {
public:
/*! Initialise the Script class. */
Script();
/*! Load a HorizonScript from the specified path.
* @param path The path to load from.
* @param options Options to use for parsing, validation, and execution.
* @return true if the Script could be loaded; false otherwise.
*/
static const Script *load(std::string path, ScriptOptions options = 0);
/*! Load a HorizonScript from the specified stream.
* @param stream The stream to load from.
* @param options Options to use for parsing, validation, and execution.
* @return true if the Script could be loaded; false otherwise.
*/
static const Script *load(std::istream &stream, ScriptOptions options = 0);
/*! Determines if the HorizonScript is valid. */
bool validate();
private:
struct ScriptPrivate;
/*! Internal data. */
const std::unique_ptr<ScriptPrivate> internal;
};
}
#endif /* !__HSCRIPT_SCRIPT_HH_ */
|