FACT++  1.0
bool ofits::Key::FormatKey ( )
inline

Definition at line 63 of file ofits.h.

References ___err___, gLog, and Trim().

Referenced by check().

64  {
65  key = Trim(key);
66  if (key.empty())
67  {
68 #ifdef __EXCEPTIONS
69  throw std::runtime_error("Key name empty.");
70 #else
71  gLog << ___err___ << "ERROR - Key name empty." << std::endl;
72  return false;
73 #endif
74  }
75  if (key.size()>8)
76  {
77  std::ostringstream sout;
78  sout << "Key '" << key << "' exceeds 8 bytes.";
79 #ifdef __EXCEPTIONS
80  throw std::runtime_error(sout.str());
81 #else
82  gLog << ___err___ << "ERROR - " << sout.str() << std::endl;
83  return false;
84 #endif
85  }
86 
87  //transform(key.begin(), key.end(), key.begin(), toupper);
88 #if GCC_VERSION < 40603
89  for (std::string::const_iterator c=key.begin(); c<key.end(); c++)
90 #else
91  for (std::string::const_iterator c=key.cbegin(); c<key.cend(); c++)
92 #endif
93  if ((*c<'A' || *c>'Z') && (*c<'0' || *c>'9') && *c!='-' && *c!='_')
94  {
95  std::ostringstream sout;
96  sout << "Invalid character '" << *c << "' found in key '" << key << "'";
97 #ifdef __EXCEPTIONS
98  throw std::runtime_error(sout.str());
99 #else
100  gLog << ___err___ << "ERROR - " << sout.str() << std::endl;
101  return false;
102 #endif
103  }
104 
105  return true;
106  }
std::string key
Definition: ofits.h:37
#define gLog
Definition: fits.h:36
#define ___err___
Definition: fits.h:37
std::string Trim(const std::string &str)
Definition: ofits.h:50

+ Here is the call graph for this function:

+ Here is the caller graph for this function: