Debian Codegraph @

sys/Script.cpp

raw
1 /* Script.cpp
2 *
3 * Copyright (C) 1997-2005,2009,2011,2015,2016,2020,2024-2026 Paul Boersma
4 *
5 * This code is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or (at
8 * your option) any later version.
9 *
10 * This code is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 * See the GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this work. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 #include "Script.h"
20
21 Thing_implement (Script, SimpleString, 0);
22 Thing_implement (ScriptSet, SortedSetOfString, 0);
23
24 static autoScriptSet theKnownScripts;
25
26 autoScript Script_createFromFile (MelderFile file) {
27 autoScript me = Thing_new (Script);
28 my string = Melder_dup (MelderFile_peekPath (file));
29 return me;
30 }
31
32 void Script_rememberDuringThisAppSession_move (autoScript me) {
33 if (! theKnownScripts)
34 theKnownScripts = ScriptSet_create ();
35 //TRACE
36 trace (U"Adding script: \"", my string.get(), U"\"");
37 theKnownScripts -> addItem_move (me.move());
38 }
39
40 Script Script_find (conststring32 filePath) {
41 const integer position = theKnownScripts -> lookUp (filePath);
42 Melder_assert (position != 0);
43 return theKnownScripts -> at [position];
44 }
45
46 /* End of file Script.cpp */