2 * Copyright 2003 Maurizio Umberto Puxeddu <umbpux@tin.it>
3 * Copyright 2011 Jakob Leben
5 * This file is part of SuperCollider.
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of the
10 * License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
24 #ifndef SC_LIBRARYCONFIG_H_INCLUDED
25 #define SC_LIBRARYCONFIG_H_INCLUDED
32 // =====================================================================
33 // SC_LibraryConfigFile
34 // simple library configuration file parser
35 // =====================================================================
37 class SC_LanguageConfig
;
39 class SC_LibraryConfigFile
42 typedef void (*ErrorFunc
)(const char* fmt
, ...);
45 SC_LibraryConfigFile(ErrorFunc errorFunc
=0);
47 bool open(const char* filePath
);
48 bool read(const char* fileName
, SC_LanguageConfig
* libConf
);
68 bool read(int depth
, const char* fileName
, SC_LanguageConfig
* libConf
);
69 bool parseLine(int depth
, const char* fileName
, int lineNumber
, const char* line
, SC_LanguageConfig
* libConf
);
70 static void defaultErrorFunc(const char* fmt
, ...);
77 class SC_LanguageConfig
80 typedef std::vector
<std::string
> DirVector
;
82 const DirVector
& includedDirectories() { return mIncludedDirectories
; }
83 const DirVector
& excludedDirectories() { return mExcludedDirectories
; }
85 void postExcludedDirectories(void);
86 bool forEachIncludedDirectory(bool (*func
)(const char *, int));
88 bool pathIsExcluded(const char *path
);
90 void addIncludedDirectory(const char *name
);
91 void addExcludedDirectory(const char *name
);
92 void removeIncludedDirectory(const char *name
);
93 void removeExcludedDirectory(const char *name
);
95 // convenience functions to access the global library config
96 static bool readLibraryConfig(const char* fileName
);
97 static bool readLibraryConfigYAML(const char* fileName
);
98 static bool writeLibraryConfigYAML(const char* fileName
);
99 static void freeLibraryConfig();
100 static bool defaultLibraryConfig(void);
101 static bool readDefaultLibraryConfig();
104 DirVector mIncludedDirectories
;
105 DirVector mExcludedDirectories
;
108 extern SC_LanguageConfig
* gLibraryConfig
;
110 #endif // SC_LIBRARYCONFIG_H_INCLUDED