aboutsummaryrefslogtreecommitdiffstats
path: root/src/beta_cfg.cpp
blob: c373688dd7b9d13850048e72c8c3406f5373d82a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
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;
}