FACT++  1.0
bool ofits::Key::check ( bool  trim = false)
inline

Definition at line 132 of file ofits.h.

References ___err___, ___warn___, CalcSize(), FormatComment(), FormatKey(), and gLog.

Referenced by ofits::Set().

133  {
134  if (!FormatKey())
135  return false;
136 
137  if (!FormatComment())
138  return false;
139 
140  size_t sz = CalcSize();
141  if (sz<=80)
142  return true;
143 
144  if (!trim)
145  {
146  std::ostringstream sout;
147  sout << "Size " << sz << " of entry for key '" << key << "' exceeds 80 characters.";
148 #ifdef __EXCEPTIONS
149  throw std::runtime_error(sout.str());
150 #else
151  gLog << ___err___ << "ERROR - " << sout.str() << std::endl;
152 #endif
153  return false;
154  }
155 
156  //looks like something went wrong. Maybe entry is too long ?
157  //try to remove the comment
158  comment = "";
159 
160  sz = CalcSize();
161  if (sz<=80)
162  {
163 #ifndef __EXCEPTIONS
164  std::ostringstream sout;
165  sout << "Size " << sz << " of entry for key '" << key << "' exceeds 80 characters... removed comment.";
166  gLog << ___warn___ << "WARNING - " << sout.str() << std::endl;
167 #endif
168  return true;
169  }
170 
171  std::ostringstream sout;
172  sout << "Size " << sz << " of entry for key '" << key << "' exceeds 80 characters even without comment.";
173 #ifdef __EXCEPTIONS
174  throw std::runtime_error(sout.str());
175 #else
176  gLog << ___err___ << "ERROR - " << sout.str() << std::endl;
177  return false;
178 #endif
179  }
std::string key
Definition: ofits.h:37
#define gLog
Definition: fits.h:36
bool FormatKey()
Definition: ofits.h:63
#define ___err___
Definition: fits.h:37
bool FormatComment()
Definition: ofits.h:108
std::string comment
Definition: ofits.h:40
size_t CalcSize() const
Definition: ofits.h:181
#define ___warn___
Definition: fits.h:38

+ Here is the call graph for this function:

+ Here is the caller graph for this function: