Skip to content

Instantly share code, notes, and snippets.

@cnd
Created November 19, 2012 10:08
Show Gist options
  • Save cnd/4109956 to your computer and use it in GitHub Desktop.
Save cnd/4109956 to your computer and use it in GitHub Desktop.
///<Summary>
///Load list of config files
///</Summary>
case 0xB0: {
unsigned char bytes[] = { 0x0A, 0xB0 };
LString luafile;
LBytes lselect = (message.extract(2, sizeof(int)));
int lsel = 0;
memcpy(&lsel, lselect.ptr(), sizeof(int));
cout << lsel << " ";
switch ( lsel ) {
case 0: luafile = "lua/example.lua"; break;
case 1: luafile = "lua/example2.lua"; break;
}
cout << luafile << endl;
ifstream f(luafile);
f >> noskipws; //don't want to skip spaces !
//initialize a vector with a pair of istream_iterators
vector<unsigned char> v((istream_iterator<unsigned char>(f)),
(istream_iterator<unsigned char>()));
LBytes lexing = (LBytes(bytes, 2));
lexing += lselect;
lexing += (LBytes(v.data(), v.size()));
f.close();
return lexing;
} break;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment