CCCC - C and C++ Code Counter  9999-git
CCCC Development version (post-3.1.4)
Static Public Member Functions | List of all members
CCCC_Options Class Reference

#include <cccc_opt.h>

Static Public Member Functions

static void Load_Options (const string &filename)
 
static void Load_Options ()
 
static void Save_Options (const string &filename)
 
static void Add_Option (CCCC_Item &option_line)
 
static string getFileLanguage (const string &filename)
 
static Metric_TreatmentgetMetricTreatment (const string &metric_tag)
 
static string dialectKeywordPolicy (const string &lang, const string &kw)
 

Detailed Description

Definition at line 40 of file cccc_opt.h.

Member Function Documentation

void CCCC_Options::Add_Option ( CCCC_Item option_line)
static

Definition at line 90 of file cccc_opt.cc.

91 {
92  string first_token;
93  bool retval=option.Extract(first_token);
94 
95  if(retval==false)
96  {
97  // do nothing
98  }
99  else if(first_token=="CCCC_FileExt")
100  {
101  add_file_extension(option);
102  }
103  else if(first_token=="CCCC_MetTmnt")
104  {
105  add_treatment(option);
106  }
107  else if(first_token=="CCCC_Dialect")
108  {
109  add_dialect_keyword(option);
110  }
111  else
112  {
113  retval=false;
114  }
115 }
static void add_file_extension(CCCC_Item &fileext_line)
Definition: cccc_opt.cc:43
void add_treatment(CCCC_Item &treatment_line)
Definition: cccc_opt.cc:56
static void add_dialect_keyword(CCCC_Item &dialect_keyword_line)
Definition: cccc_opt.cc:75

Here is the call graph for this function:

Here is the caller graph for this function:

string CCCC_Options::dialectKeywordPolicy ( const string &  lang,
const string &  kw 
)
static

Definition at line 264 of file cccc_opt.cc.

265 {
266  string retval;
267  dialect_keyword_map_t::key_type kt(lang,kw);
268  dialect_keyword_map_t::const_iterator iter=dialect_keyword_map.find(kt);
269  if(iter!=dialect_keyword_map.end())
270  {
271  retval=(*iter).second;
272  }
273  return retval;
274 }
static dialect_keyword_map_t dialect_keyword_map
Definition: cccc_opt.cc:36
string CCCC_Options::getFileLanguage ( const string &  filename)
static

Definition at line 220 of file cccc_opt.cc.

221 {
222  string retval;
223  string extension;
224  file_extension_language_map_t::iterator iter;
225 
226  unsigned int extpos=filename.rfind(".");
227  if(extpos!=string::npos)
228  {
229  extension=filename.substr(extpos);
230  iter=extension_map.find(extension);
231  if(iter!=extension_map.end())
232  {
233  retval=(*iter).second;
234  }
235  }
236  if(retval.size()==0)
237  {
238  iter=extension_map.find("");
239  if(iter!=extension_map.end())
240  {
241  retval=(*iter).second;
242  }
243  else
244  {
245  // could not find language for extension
246  cerr << "No language found for extension " << extension.c_str() << endl;
247  }
248  }
249  return retval;
250 }
static file_extension_language_map_t extension_map
Definition: cccc_opt.cc:34

Here is the caller graph for this function:

Metric_Treatment * CCCC_Options::getMetricTreatment ( const string &  metric_tag)
static

Definition at line 253 of file cccc_opt.cc.

254 {
255  Metric_Treatment *retval=NULL;
256  metric_treatment_map_t::iterator iter=treatment_map.find(metric_tag);
257  if(iter!=treatment_map.end())
258  {
259  retval=(*iter).second;
260  }
261  return retval;
262 }
static metric_treatment_map_t treatment_map
Definition: cccc_opt.cc:35

Here is the caller graph for this function:

void CCCC_Options::Load_Options ( const string &  filename)
static

Definition at line 164 of file cccc_opt.cc.

165 {
166  ifstream optstr(filename.c_str());
167 
168  while(optstr.good())
169  {
170  CCCC_Item option_line;
171  if(optstr.good() &&
172  option_line.FromFile(optstr)
173  )
174  {
175  Add_Option(option_line);
176  }
177  }
178 
179 }
bool FromFile(ifstream &ifstr)
Definition: cccc_itm.cc:119
static void Add_Option(CCCC_Item &option_line)
Definition: cccc_opt.cc:90

Here is the call graph for this function:

void CCCC_Options::Load_Options ( )
static

Definition at line 182 of file cccc_opt.cc.

183 {
184  int i=0;
185 
186  const char **option_ptr;
187 
188  option_ptr=default_fileext_options;
189  while( (*option_ptr)!=NULL)
190  {
191  string option_string="CCCC_FileExt@";
192  option_string+=(*option_ptr);
193  CCCC_Item option_line(option_string);
194  Add_Option(option_line);
195  option_ptr++;
196  }
197 
198  option_ptr=default_treatment_options;
199  while( (*option_ptr)!=NULL)
200  {
201  string option_string="CCCC_MetTmnt@";
202  option_string+=(*option_ptr);
203  CCCC_Item option_line(option_string);
204  Add_Option(option_line);
205  option_ptr++;
206  }
207 
208  option_ptr=default_dialect_options;
209  while( (*option_ptr)!=NULL)
210  {
211  string option_string="CCCC_Dialect@";
212  option_string+=(*option_ptr);
213  CCCC_Item option_line(option_string);
214  Add_Option(option_line);
215  option_ptr++;
216  }
217 }
const char * default_treatment_options[]
Definition: cccc_opt.cc:325
const char * default_dialect_options[]
Definition: cccc_opt.cc:391
static void Add_Option(CCCC_Item &option_line)
Definition: cccc_opt.cc:90
const char * default_fileext_options[]
Definition: cccc_opt.cc:277

Here is the call graph for this function:

Here is the caller graph for this function:

void CCCC_Options::Save_Options ( const string &  filename)
static

Definition at line 118 of file cccc_opt.cc.

119 {
120  ofstream optstr(filename.c_str());
121  file_extension_language_map_t::iterator felIter;
122  for(felIter=extension_map.begin();
123  felIter!=extension_map.end();
124  ++felIter)
125  {
126  CCCC_Item extLine;
127  extLine.Insert("CCCC_FileExt");
128  extLine.Insert((*felIter).first.c_str());
129  extLine.Insert((*felIter).second.c_str());
130  extLine.ToFile(optstr);
131  }
132 
133  metric_treatment_map_t::iterator tIter;
134  for(tIter=treatment_map.begin();
135  tIter!=treatment_map.end();
136  ++tIter)
137  {
138  CCCC_Item tmtLine;
139  tmtLine.Insert("CCCC_MetTmnt");
140  tmtLine.Insert((*tIter).second->code);
141  tmtLine.Insert((*tIter).second->lower_threshold);
142  tmtLine.Insert((*tIter).second->upper_threshold);
143  tmtLine.Insert((*tIter).second->numerator_threshold);
144  tmtLine.Insert((*tIter).second->width);
145  tmtLine.Insert((*tIter).second->precision);
146  tmtLine.Insert((*tIter).second->name);
147  tmtLine.ToFile(optstr);
148  }
149 
150  dialect_keyword_map_t::iterator dkIter;
151  for(dkIter=dialect_keyword_map.begin();
152  dkIter!=dialect_keyword_map.end();
153  ++dkIter)
154  {
155  CCCC_Item dkLine;
156  dkLine.Insert("CCCC_Dialect");
157  dkLine.Insert((*dkIter).first.first);
158  dkLine.Insert((*dkIter).first.second);
159  dkLine.Insert((*dkIter).second);
160  dkLine.ToFile(optstr);
161  }
162 }
bool Insert(const string &s)
Definition: cccc_itm.cc:31
static file_extension_language_map_t extension_map
Definition: cccc_opt.cc:34
static dialect_keyword_map_t dialect_keyword_map
Definition: cccc_opt.cc:36
static metric_treatment_map_t treatment_map
Definition: cccc_opt.cc:35
bool ToFile(ofstream &ofstr)
Definition: cccc_itm.cc:112

Here is the call graph for this function:

Here is the caller graph for this function:


The documentation for this class was generated from the following files: