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  // Not implemented
139  void operator=(const vtkBlueObeliskDataParser&);
140 
142 
143  static void ResizeArrayIfNeeded(vtkAbstractArray *arr, vtkIdType ind);
144  static void ResizeAndSetValue(vtkStdString *val,
145  vtkStringArray *arr,
146  vtkIdType ind);
147  static void ResizeAndSetValue(float val,
148  vtkFloatArray *arr,
149  vtkIdType ind);
150  static void ResizeAndSetValue(unsigned short val,
152  vtkIdType ind);
154 
156 
157  static int parseInt(const char *);
158  static float parseFloat(const char *);
159  static void parseFloat3(const char * str, float[3]);
160  static unsigned short parseUnsignedShort(const char *);
162 
164 
166  static vtkStdString * ToLower(vtkStdString *);
167 };
169 
170 #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:275
#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.