CMS 3D CMS Logo

Functions
SimpleSAXParser.cc File Reference
#include "Fireworks/Core/src/SimpleSAXParser.h"

Go to the source code of this file.

Functions

void debug_state_machine (enum SimpleSAXParser::PARSER_STATES state)
 
bool fgettoken (std::istream &in, char **buffer, size_t *maxSize, const char *separators, int *firstChar)
 

Function Documentation

◆ debug_state_machine()

void debug_state_machine ( enum SimpleSAXParser::PARSER_STATES  state)

Definition at line 18 of file SimpleSAXParser.cc.

18  {
19 #ifdef SIMPLE_SAX_PARSER_DEBUG
20  static char *debug_states[] = {"IN_DOCUMENT",
21  "IN_BEGIN_TAG",
22  "IN_DONE",
23  "IN_BEGIN_ELEMENT",
24  "IN_ELEMENT_WHITESPACE",
25  "IN_END_ELEMENT",
26  "IN_ATTRIBUTE_KEY",
27  "IN_END_TAG",
28  "IN_DATA",
29  "IN_BEGIN_ATTRIBUTE_VALUE",
30  "IN_STRING",
31  "IN_END_ATTRIBUTE_VALUE",
32  "IN_STRING_ENTITY",
33  "IN_DATA_ENTITY"};
34 
35  std::cerr << debug_states[state] << std::endl;
36 #endif
37 }

References EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0::cerr.

Referenced by SimpleSAXParser::parse().

◆ fgettoken()

bool fgettoken ( std::istream &  in,
char **  buffer,
size_t *  maxSize,
const char *  separators,
int *  firstChar 
)

Helper function which gets a token delimited by separator from the file and write it, 0 terminated in the buffer found in buffer.

Notice that if the token is larger than maxSize, the buffer is reallocated and maxSize is updated to the new size.

The trailing separator after a token is not put in the token and is left in the buffer. If nextChar is not 0, the delimiter is put there.

in the input stream to be parsed.

buffer a pointer to the buffer where to put the tokens. The buffer will be redimensioned accordingly, if the token is larger of the buffer.

maxSize, a pointer to the size of the buffer. Notice that in case the buffer is reallocated to have more space, maxSize is updated with the new size.

firstChar a pointer with the first character in the buffer, notice that the first charater in the stream must be obtained separately!!!

Returns
whether or not we were able to get a (possibly empty) token from the file.

Definition at line 224 of file SimpleSAXParser.cc.

224  {
225  // if the passed first character is EOF or a separator,
226  // return an empty otherwise use it as first character
227  // of the buffer.
228  if (*firstChar == EOF || (int)separators[0] == *firstChar || strchr(separators + 1, *firstChar)) {
229  (*buffer)[0] = 0;
230  return true;
231  } else
232  (*buffer)[0] = (char)*firstChar;
233 
234  size_t i = 1;
235 
236  while (true) {
237  if (i >= *maxSize) {
238  *maxSize += 1024;
239  *buffer = (char *)realloc(*buffer, *maxSize);
240  if (!*buffer)
241  return false;
242  }
243 
244  int c = in.get();
245 
246  if (c == EOF) {
247  (*buffer)[i] = 0;
248  *firstChar = c;
249  return false;
250  }
251 
252  if (separators[0] == c || strchr(separators + 1, c)) {
253  (*buffer)[i] = 0;
254  *firstChar = c;
255  return true;
256  }
257 
258  (*buffer)[i++] = (char)c;
259  }
260 }

References edmScanValgrind::buffer, c, mps_fire::i, recoMuon::in, and reco_skim_cfg_mod::maxSize.

Referenced by SimpleSAXParser::getToken().

mps_fire.i
i
Definition: mps_fire.py:428
edmScanValgrind.buffer
buffer
Definition: edmScanValgrind.py:171
recoMuon::in
Definition: RecoMuonEnumerators.h:6
reco_skim_cfg_mod.maxSize
maxSize
Definition: reco_skim_cfg_mod.py:154
RunInfoPI::state
state
Definition: RunInfoPayloadInspectoHelper.h:16
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:46
EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0.cerr
cerr
Definition: EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0.py:8