VTK  9.2.6
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 =========================================================================*/
36 #ifndef vtkBlueObeliskDataParser_h
37 #define vtkBlueObeliskDataParser_h
38 
39 #include "vtkDomainsChemistryModule.h" // For export macro
40 #include "vtkXMLParser.h"
41 
42 #include "vtkSmartPointer.h" // For vtkSmartPointer
43 
44 class vtkAbstractArray;
45 class vtkBlueObeliskData;
46 class vtkFloatArray;
47 class vtkStdString;
48 class vtkStringArray;
50 
51 class VTKDOMAINSCHEMISTRY_EXPORT vtkBlueObeliskDataParser : public vtkXMLParser
52 {
53 public:
55  void PrintSelf(ostream& os, vtkIndent indent) override;
56 
57  static vtkBlueObeliskDataParser* New();
58 
63  virtual void SetTarget(vtkBlueObeliskData* bodr);
64 
68  int Parse() override;
69 
71 
76  int Parse(const char*) override;
77  int Parse(const char*, unsigned int) override;
79 
80 protected:
82  ~vtkBlueObeliskDataParser() override;
83 
84  void StartElement(const char* name, const char** attr) override;
85  void EndElement(const char* name) override;
86 
87  void CharacterDataHandler(const char* data, int length) override;
88 
89  void SetCurrentValue(const char* data, int length);
90  void SetCurrentValue(const char* data);
91 
93 
95  void NewAtomStarted(const char** attr);
96  void NewAtomFinished();
97 
99  void NewValueStarted(const char** attr);
100  void NewValueFinished();
101 
103 
105  {
106  None = 0,
125  } CurrentValueType;
126 
133  float CurrentMass;
140  float CurrentDefaultColor[3];
143  unsigned int CurrentPeriod;
144  unsigned int CurrentGroup;
145 
146 private:
148  void operator=(const vtkBlueObeliskDataParser&) = delete;
149 
151 
154  static void ResizeArrayIfNeeded(vtkAbstractArray* arr, vtkIdType ind);
155  static void ResizeAndSetValue(vtkStdString* val, vtkStringArray* arr, vtkIdType ind);
156  static void ResizeAndSetValue(float val, vtkFloatArray* arr, vtkIdType ind);
157  static void ResizeAndSetValue(unsigned short val, vtkUnsignedShortArray* arr, vtkIdType ind);
159 
161 
164  static int parseInt(const char*);
165  static float parseFloat(const char*);
166  static void parseFloat3(const char* str, float[3]);
167  static unsigned short parseUnsignedShort(const char*);
169 
171 
175  static vtkStdString* ToLower(vtkStdString*);
177 };
178 
179 #endif
Wrapper around std::string to keep symbols short.
Definition: vtkStdString.h:38
virtual int Parse()
Parse the XML input.
Parse XML to handle element tags and attributes.
Definition: vtkXMLParser.h:42
Abstract superclass for all arrays.
virtual void StartElement(const char *name, const char **atts)
dynamic, self-adjusting array of float
Definition: vtkFloatArray.h:41
a vtkAbstractArray subclass for strings
int vtkIdType
Definition: vtkType.h:332
virtual void CharacterDataHandler(const char *data, int length)
a simple class to control print indentation
Definition: vtkIndent.h:39
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
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.