Commit e93593e2 authored by jclamber's avatar jclamber

user sqlite3 own db cia .unsio

git-svn-id: http://svn.oamp.fr/repos/unsio/trunk@153 ce2cc22f-6084-46ce-a062-084b172ee5dc
parent 3083e65f
......@@ -22,7 +22,62 @@
#include <assert.h>
#include <cmath>
#include <cstdlib>
#include <fstream>
namespace uns {
// ============================================================================
// parseConfig
std::string CSnapshotInterfaceIn::parseConfig(std::string req)
{
std::string config_file(std::string(getenv("HOME")) + "/.unsio");
std::ifstream fi;
bool exist=true;
std::string key,value="";
fi.open(config_file.c_str(), std::ios::in);
if (! fi.is_open()) {
std::cerr << "Unable to open file ["<<config_file<<"] for reading, skipping...\n";
exist = false;
}
if (exist) {
bool stop = false;
while (!stop && ! fi.eof()) { // while ! eof
std::string line;
getline(fi,line); // read on eline
if ( ! fi.eof()) {
std::istringstream str(line); // stream line
std::string parse;
// following loop parse each lines previously read
//
int cpt=0;
bool equal=false;
while ( str >> parse && // something to read
parse[0] != '#' && // not commented out
parse[0] != '!' // not commented out
) {
cpt++;
if (cpt==1) { // key
key=parse;
}
if (cpt==2) { // sim type
if (parse == "=") {
equal=true;
} else {
equal = false;
}
}
if (cpt==3 && equal && key==req) { // value
value=parse;
stop=true; // found pair key value
}
}
}
}
fi.close();
}
return value;
}
// ============================================================================
// parseSelectTime
void CSnapshotInterfaceIn::parseSelectTime()
......
......@@ -138,6 +138,7 @@ namespace uns {
bool isValidData() { return valid; }
void setFileName(std::string _f) { filename = _f;}
bool getRangeSelect(const char *, int *, int *, int * , bool fortran=false);
std::string parseConfig(std::string);
//std::string getFileName() const { return filename;};
int getInterfaceIndex() { return interface_index; }
bool isFileExist() { return true; }
......
This diff is collapsed.
......@@ -208,7 +208,7 @@ int main(int argc, char ** argv )
uns->snapshot->getData("time",&time);
std::cout << "Nbody selected = " << nbody << "\nTime="<<time <<"\n";
if (file_structure=="range") {
if (0 && file_structure=="range") {
displayInfo(display,maxlines,"all",uns);
} else {
displayInfo(display,maxlines,"gas" ,uns);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment