libsurf
Programmer's Documentation

steplistrep.h (r6227/r5337)
1 
2 /* Copyright (C) 2015 David Eller <david@larosterna.com>
3  *
4  * Commercial License Usage
5  * Licensees holding valid commercial licenses may use this file in accordance
6  * with the terms contained in their respective non-exclusive license agreement.
7  * For further information contact david@larosterna.com .
8  *
9  * GNU General Public License Usage
10  * Alternatively, this file may be used under the terms of the GNU General
11  * Public License version 3.0 as published by the Free Software Foundation and
12  * appearing in the file gpl.txt included in the packaging of this file.
13  */
14 
15 
16 #ifndef SURF_STEPLISTREP_H
17 #define SURF_STEPLISTREP_H
18 
19 #include "step.h"
20 #include <genua/defines.h>
21 
26 {
27 public:
28 
30  StepListRep(const char *s);
31 
33  bool valid() const {return last != 0;}
34 
36  const char *begin() const {return first;}
37 
39  const char *end() const {return last;}
40 
42  uint nChildLists() const;
43 
45  uint nComma() const;
46 
48  uint nelements() const {return nComma() + 1;}
49 
51  bool parseIds(StepID val[]) const;
52 
54  bool parseInts(int val[]) const;
55 
57  bool parseStrings(std::string val[]) const;
58 
60  bool parseFloats(double val[]) const;
61 
63  template <int N>
64  bool parseFloats(double val[]) const {
65  char *tail;
66  const char *s = first + 1;
67  for (int i=0; i < N; ++i) {
68  while (*s == ',' or isspace(*s))
69  ++s;
70  val[i] = genua_strtod(s, &tail);
71  if (tail == s)
72  return false;
73  s = tail;
74  }
75  return true;
76  }
77 
79  template <int N>
80  bool parseInts(int val[]) const {
81  char *tail;
82  const char *s = first + 1;
83  for (int i=0; i < N; ++i) {
84  while (*s == ',' or isspace(*s))
85  ++s;
86  val[i] = genua_strtol(s, &tail, 10);
87  if (tail == s)
88  return false;
89  s = tail;
90  }
91  return true;
92  }
93 
95  template <int N>
96  bool parseIds(StepID val[]) const {
97  char *tail;
98  const char *s = first + 1;
99  for (int i=0; i < N; ++i) {
100  while (*s == ',' or isspace(*s))
101  ++s;
102  val[i] = genua_strtol(s, &tail, 10);
103  if (tail == s)
104  return false;
105  s = tail;
106  }
107  return true;
108  }
109 
110 private:
111 
113  const char *first;
114 
116  const char *last;
117 };
118 
119 #endif // STEPLISTREP_H
StepListRep(const char *s)
identify list
Definition: steplistrep.cpp:17
bool parseIds(StepID val[]) const
extract fixed-size list of floating-point values
Definition: steplistrep.h:96
bool parseFloats(double val[]) const
extract fixed-size list of floating-point values
Definition: steplistrep.h:64
bool valid() const
determine whether list was identified
Definition: steplistrep.h:33
A list in a STEP file line.
Definition: steplistrep.h:25
uint nComma() const
number of commas in list
Definition: steplistrep.cpp:47
const char * first
first character of list
Definition: steplistrep.h:113
bool parseInts(int val[]) const
extract list of integers
Definition: steplistrep.cpp:75
uint nelements() const
number of list elements
Definition: steplistrep.h:48
bool parseFloats(double val[]) const
extract list of floating-point values, unknown length
Definition: steplistrep.cpp:95
const char * begin() const
first character of the list &#39;(&#39;
Definition: steplistrep.h:36
const char * last
points to last character (closing char)
Definition: steplistrep.h:116
bool parseIds(StepID val[]) const
extract list of entity ids
Definition: steplistrep.cpp:55
bool parseStrings(std::string val[]) const
extract list of strings
Definition: steplistrep.cpp:115
uint nChildLists() const
number of child lists contained
Definition: steplistrep.cpp:39
bool parseInts(int val[]) const
extract fixed-size list of floating-point values
Definition: steplistrep.h:80
const char * end() const
last character of the list &#39;)&#39;
Definition: steplistrep.h:39
Generated on Mon Jan 24 2022 03:03:16 for libsurf by   doxygen 1.8.5