VTK
vtkBlueObeliskDataParser.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkBlueObeliskDataParser.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
35 #ifndef vtkBlueObeliskDataParser_h
36 #define vtkBlueObeliskDataParser_h
37 
38 #include "vtkDomainsChemistryModule.h" // For export macro
39 #include "vtkXMLParser.h"
40 
41 #include "vtkSmartPointer.h" // For vtkSmartPointer
42 
43 class vtkAbstractArray;
44 class vtkBlueObeliskData;
45 class vtkFloatArray;
46 class vtkStdString;
47 class vtkStringArray;
49 
51 {
52  public:
54  static vtkBlueObeliskDataParser * New();
55 
58  virtual void SetTarget(vtkBlueObeliskData *bodr);
59 
61  virtual int Parse();
62 
64 
67  virtual int Parse(const char *);
68  virtual int Parse(const char *, unsigned int);
70 
71 protected:
74 
75  void StartElement(const char *name, const char **attr);
76  void EndElement(const char *name);
77 
78  void CharacterDataHandler(const char *data, int length);
79 
80  void SetCurrentValue(const char *data, int length);
81  void SetCurrentValue(const char *data);
82 
84 
86  void NewAtomStarted(const char **attr);
87  void NewAtomFinished();
88 
90  void NewValueStarted(const char **attr);
91  void NewValueFinished();
92 
94 
96  None = 0,
115  } CurrentValueType;
116 
123  float CurrentMass;
130  float CurrentDefaultColor[3];
133  unsigned int CurrentPeriod;
134  unsigned int CurrentGroup;
135 
136 private:
137  vtkBlueObeliskDataParser(const vtkBlueObeliskDataParser&); // Not implemented
138  void operator=(const vtkBlueObeliskDataParser&); // Not implemented
139 
141 
142  static void ResizeArrayIfNeeded(vtkAbstractArray *arr, vtkIdType ind);
143  static void ResizeAndSetValue(vtkStdString *val,
144  vtkStringArray *arr,
145  vtkIdType ind);
146  static void ResizeAndSetValue(float val,
147  vtkFloatArray *arr,
148  vtkIdType ind);
149  static void ResizeAndSetValue(unsigned short val,
151  vtkIdType ind);
153 
155 
156  static int parseInt(const char *);
157  static float parseFloat(const char *);
158  static void parseFloat3(const char * str, float[3]);
159  static unsigned short parseUnsignedShort(const char *);
161 
163 
165  static vtkStdString * ToLower(vtkStdString *);
166 };
168 
169 #endif
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:46
virtual int Parse()
Parse XML to handle element tags and attributes.
Definition: vtkXMLParser.h:41
Abstract superclass for all arrays.
virtual void StartElement(const char *name, const char **atts)
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:45
a vtkAbstractArray subclass for strings
int vtkIdType
Definition: vtkType.h:247
#define VTKDOMAINSCHEMISTRY_EXPORT
virtual void CharacterDataHandler(const char *data, int length)
virtual void EndElement(const char *name)
static vtkXMLParser * New()
Fill a vtkBlueObeliskData container with data from the BODR XML dataset.
dynamic, self-adjusting array of unsigned short
Contains chemical data from the Blue Obelisk Data Repository.