[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [sc-dev] library config



On Tue, Dec 16, 2003 at 09:18:26PM -0800, James McCartney wrote:
> I'd like to move the library config parser out of SC_TerminalClient so 
> that the app can use it.

i've added the headers/sources lang/SC_LibraryConfig.* and
common/SC_StringBuffer.* for use in the pb-project.

ENABLE_LIBRARY_CONFIGURATOR has to be defined in PyrLexer.cpp.

> I'd like to be able to change to a different .cfg file. I'd search for 
> ~/*.cfg and ./*.cfg and let the user choose one from a menu or find one 
> with the file dialog. This way it would be easy to switch between 
> configs. Similarly the command line version might want to give an 
> option to specify a different .cfg file.

there are two functions in SC_LibraryConfig to set/free the global
instance at runtime:

SC_LibraryConfig::readLibraryConfig
SC_LibraryConfig::freeLibraryConfig

usage example:

char* fileName = ".sclang.cfg"; // used for error messages
SC_StringBuffer filePath(32);
filePath.appendf("/home/steve/%s", fileName);
filePath.finish();
SC_LibraryConfigFile file(&::post);
if (file.open(filePath.getData())) {
    SC_LibraryConfig::readLibraryConfig(file, fileName);
    file.close();
}

<sk>