diff options
author | Aaron LI <aaronly.me@outlook.com> | 2017-02-20 12:26:17 +0800 |
---|---|---|
committer | Aaron LI <aaronly.me@outlook.com> | 2017-02-20 12:26:17 +0800 |
commit | 4ea7a05ea9a7352602f1f48a860fd81c36e8bc04 (patch) | |
tree | beab7ec18d48c3e2093cd35fd8c79bd66f604a03 /src/beta_cfg.cpp | |
parent | 9cec16d87f6dc2e0b34b605d88d0837a4a48d18c (diff) | |
download | chandra-acis-analysis-4ea7a05ea9a7352602f1f48a860fd81c36e8bc04.tar.bz2 |
Rename mass_profile to src; Add install & uninstall to Makefile
Diffstat (limited to 'src/beta_cfg.cpp')
-rw-r--r-- | src/beta_cfg.cpp | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/src/beta_cfg.cpp b/src/beta_cfg.cpp new file mode 100644 index 0000000..c373688 --- /dev/null +++ b/src/beta_cfg.cpp @@ -0,0 +1,85 @@ +#include "beta_cfg.hpp" +#include <sstream> +#include <cstdlib> +using namespace std; + +cfg_map parse_cfg_file(std::istream& is) +{ + cfg_map result; + result.rmin_pixel=-1; + result.rmin_kpc=-1; + for(;;) + { + std::string line; + getline(is,line); + line+="\n"; + if(!is.good()) + { + break; + } + string key; + istringstream iss(line); + iss>>key; + if(key=="sbp_data") + { + string value; + iss>>value; + result.sbp_data=value; + } + else if(key=="cfunc_profile") + { + string value; + iss>>value; + result.cfunc_profile=value; + } + else if(key=="tprofile") + { + string value; + iss>>value; + result.tprofile=value; + } + else if(key=="z") + { + double z; + iss>>z; + result.z=z; + } + else if(key=="cm_per_pixel") + { + double cm_per_pixel; + iss>>cm_per_pixel; + result.cm_per_pixel=cm_per_pixel; + } + else if(key=="rmin_pixel") + { + double v; + iss>>v; + result.rmin_pixel=v; + } + else if(key=="rmin_kpc") + { + double v; + iss>>v; + result.rmin_kpc=v; + } + else + { + std::vector<double> value; + for(;;) + { + double v; + iss>>v; + if(!iss.good()) + { + break; + } + value.push_back(v); + } + if(!value.empty()) + { + result.param_map[key]=value; + } + } + } + return result; +} |