KiCad PCB EDA Suite
WRLPROC Class Reference

#include <wrlproc.h>

Public Member Functions

 WRLPROC (LINE_READER *aLineReader)
 
 ~WRLPROC ()
 
bool eof (void)
 
WRLVERSION GetVRMLType (void)
 
const char * GetParentDir (void)
 
std::string GetError (void)
 
bool GetFilePosData (size_t &line, size_t &column)
 
std::string GetFileName (void)
 
bool EatSpace (void)
 
char Peek (void)
 
void Pop (void)
 
bool ReadGlob (std::string &aGlob)
 
bool ReadName (std::string &aName)
 
bool DiscardNode (void)
 
bool DiscardList (void)
 
bool ReadString (std::string &aSFString)
 
bool ReadSFBool (bool &aSFBool)
 
bool ReadSFColor (WRLVEC3F &aSFColor)
 
bool ReadSFFloat (float &aSFFloat)
 
bool ReadSFInt (int &aSFInt32)
 
bool ReadSFRotation (WRLROTATION &aSFRotation)
 
bool ReadSFVec2f (WRLVEC2F &aSFVec2f)
 
bool ReadSFVec3f (WRLVEC3F &aSFVec3f)
 
bool ReadMFString (std::vector< std::string > &aMFString)
 
bool ReadMFColor (std::vector< WRLVEC3F > &aMFColor)
 
bool ReadMFFloat (std::vector< float > &aMFFloat)
 
bool ReadMFInt (std::vector< int > &aMFInt32)
 
bool ReadMFRotation (std::vector< WRLROTATION > &aMFRotation)
 
bool ReadMFVec2f (std::vector< WRLVEC2F > &aMFVec2f)
 
bool ReadMFVec3f (std::vector< WRLVEC3F > &aMFVec3f)
 

Private Member Functions

bool getRawLine (void)
 

Private Attributes

LINE_READERm_file
 
std::string m_buf
 
bool m_eof
 
unsigned int m_fileline
 
unsigned int m_bufpos
 
WRLVERSION m_fileVersion
 
std::string m_error
 
std::string m_badchars
 
std::string m_filename
 
std::string m_filedir
 

Detailed Description

Definition at line 40 of file wrlproc.h.

Constructor & Destructor Documentation

◆ WRLPROC()

WRLPROC::WRLPROC ( LINE_READER aLineReader)

Definition at line 49 of file wrlproc.cpp.

50 {
52  m_eof = false;
53  m_fileline = 0;
54  m_bufpos = 0;
55  m_file = aLineReader;
56 
57  if( NULL == aLineReader )
58  {
59  m_eof = true;
60  return;
61  }
62 
63  m_error.clear();
64  wxString tname = m_file->GetSource();
65  m_filename = tname.ToUTF8();
66  wxFileName fn( tname );
67 
68  if( fn.IsRelative() )
69  fn.Normalize();
70 
71  m_filedir = fn.GetPathWithSep().ToUTF8();
72 
73  m_buf.clear();
74  GETLINE;
75 
76  if( m_eof )
77  return;
78 
79  if( m_buf.compare( 0, 16, "#VRML V1.0 ascii" ) == 0 )
80  {
82  // nothing < 0x20, and no:
83  // single or double quote
84  // backslash
85  // curly brace
86  // plus
87  // period
88  m_badchars = "\"'\\{}+.";
89  return;
90  }
91 
92  if( m_buf.compare( 0, 15, "#VRML V2.0 utf8" ) == 0 )
93  {
95  // nothing < 0x20, and no:
96  // single or double quotes
97  // sharp (#)
98  // plus
99  // minus
100  // comma
101  // period
102  // square brackets []
103  // curly braces {}
104  // backslash
105  // NOTE: badchars should include '-' but due to my bad model naming scheme
106  // in the VRML model generator, I have allowed '-'. Other VRML parsers seem to
107  // accept '-'. FreeCAD produces names with '+' in them so '+' has been allowed
108  // as well; '+' is not even valid for VRML1.
109  //m_badchars = "'\"#,.+-[]\\{}";
110  m_badchars = "'\"#,.[]\\{}";
111  return;
112  }
113 
114  m_buf.clear();
116  m_eof = true;
117 
118  m_error = "not a valid VRML file: '";
119  m_error.append( m_filename );
120  m_error.append( 1, '\'' );
121  m_badchars.clear();
122 
123  return;
124 }
virtual const wxString & GetSource() const
Function GetSource returns the name of the source of the lines in an abstract sense.
Definition: richio.h:131
unsigned int m_bufpos
Definition: wrlproc.h:47
std::string m_filedir
Definition: wrlproc.h:53
LINE_READER * m_file
Definition: wrlproc.h:43
unsigned int m_fileline
Definition: wrlproc.h:46
std::string m_badchars
Definition: wrlproc.h:51
#define NULL
std::string m_error
Definition: wrlproc.h:50
std::string m_buf
Definition: wrlproc.h:44
std::string m_filename
Definition: wrlproc.h:52
bool m_eof
Definition: wrlproc.h:45
#define GETLINE
Definition: wrlproc.cpp:31
WRLVERSION m_fileVersion
Definition: wrlproc.h:49

References GETLINE, LINE_READER::GetSource(), m_badchars, m_buf, m_bufpos, m_eof, m_error, m_file, m_filedir, m_fileline, m_filename, m_fileVersion, NULL, VRML_INVALID, VRML_V1, and VRML_V2.

◆ ~WRLPROC()

WRLPROC::~WRLPROC ( )

Definition at line 127 of file wrlproc.cpp.

128 {
129  return;
130 }

Member Function Documentation

◆ DiscardList()

bool WRLPROC::DiscardList ( void  )

Definition at line 482 of file wrlproc.cpp.

483 {
484  if( !m_file )
485  {
486  m_error = "no open file";
487  return false;
488  }
489 
490  if( !EatSpace() )
491  {
492  std::ostringstream ostr;
493  ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
494  ostr << " * [INFO] failed on file '" << m_filename << "'\n";
495  ostr << " * [INFO] " << m_error;
496  m_error = ostr.str();
497 
498  return false;
499  }
500 
501  if( '[' != m_buf[m_bufpos] )
502  {
503  std::ostringstream ostr;
504  ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
505  ostr << " * [INFO] failed on file '" << m_filename << "'\n";
506  ostr << " * [INFO] expecting character '[' at line " << m_fileline;
507  ostr << ", column " << m_bufpos;
508  m_error = ostr.str();
509 
510  return false;
511  }
512 
513  size_t fileline = m_fileline;
514  size_t linepos = m_bufpos;
515 
516  ++m_bufpos;
517  size_t lvl = 1;
518  std::string tmp;
519 
520  while( lvl > 0 )
521  {
522  if( !EatSpace() )
523  {
524  std::ostringstream ostr;
525  ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
526  ostr << " * [INFO] failed on file '" << m_filename << "'\n";
527  ostr << " * [INFO] line " << fileline << ", char " << linepos << " -- ";
528  ostr << "line " << m_fileline << ", char " << m_bufpos << "\n";
529  ostr << " * [INFO] " << m_error;
530  m_error = ostr.str();
531 
532  return false;
533  }
534 
535  // comments must be skipped
536  if( '#' == m_buf[m_bufpos] )
537  {
538  m_bufpos = 0;
539  m_buf.clear();
540  continue;
541  }
542 
543  if( '[' == m_buf[m_bufpos] )
544  {
545  ++m_bufpos;
546  ++lvl;
547  continue;
548  }
549 
550  if( ']' == m_buf[m_bufpos] )
551  {
552  ++m_bufpos;
553  --lvl;
554  continue;
555  }
556 
557  // note: if we have a '}' we must skip it and test the next non-blank character;
558  // this ensures that we don't miss a ']' in cases where the braces are not
559  // separated by space. if we had proceeded to ReadGlob() we could have had a problem.
560  if( '}' == m_buf[m_bufpos] || '{' == m_buf[m_bufpos] )
561  {
562  ++m_bufpos;
563  continue;
564  }
565 
566  // strings are handled as a special case since they may contain
567  // control characters and braces
568  if( '"' == m_buf[m_bufpos] )
569  {
570  if( !ReadString( tmp ) )
571  {
572  std::ostringstream ostr;
573  ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
574  ostr << " * [INFO] failed on file '" << m_filename << "'\n";
575  ostr << " * [INFO] line " << fileline << ", char " << linepos << " -- ";
576  ostr << "line " << m_fileline << ", char " << m_bufpos << "\n";
577  ostr << " * [INFO] " << m_error;
578  m_error = ostr.str();
579 
580  return false;
581  }
582  }
583 
584  // everything at this point can be read and discarded via ReadGlob()
585  if( !ReadGlob( tmp ) )
586  {
587  std::ostringstream ostr;
588  ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
589  ostr << " * [INFO] failed on file '" << m_filename << "'\n";
590  ostr << " * [INFO] line " << fileline << ", char " << linepos << " -- ";
591  ostr << "line " << m_fileline << ", char " << m_bufpos << "\n";
592  ostr << " * [INFO] " << m_error;
593  m_error = ostr.str();
594 
595  return false;
596  }
597  }
598 
599  return false;
600 }
unsigned int m_bufpos
Definition: wrlproc.h:47
bool ReadGlob(std::string &aGlob)
Definition: wrlproc.cpp:236
LINE_READER * m_file
Definition: wrlproc.h:43
unsigned int m_fileline
Definition: wrlproc.h:46
std::string m_error
Definition: wrlproc.h:50
std::string m_buf
Definition: wrlproc.h:44
std::string m_filename
Definition: wrlproc.h:52
bool ReadString(std::string &aSFString)
Definition: wrlproc.cpp:603
bool EatSpace(void)
Definition: wrlproc.cpp:182

References EatSpace(), m_buf, m_bufpos, m_error, m_file, m_fileline, m_filename, ReadGlob(), and ReadString().

Referenced by WRL2BASE::ReadNode().

◆ DiscardNode()

bool WRLPROC::DiscardNode ( void  )

Definition at line 359 of file wrlproc.cpp.

360 {
361  if( !m_file )
362  {
363  m_error = "no open file";
364  return false;
365  }
366 
367  if( !EatSpace() )
368  {
369  std::ostringstream ostr;
370  ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
371  ostr << " * [INFO] failed on file '" << m_filename << "'\n";
372  ostr << " * [INFO] " << m_error;
373  m_error = ostr.str();
374 
375  return false;
376  }
377 
378  if( '{' != m_buf[m_bufpos] )
379  {
380  std::ostringstream ostr;
381  ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
382  ostr << " * [INFO] failed on file '" << m_filename << "'\n";
383  ostr << " * [INFO] expecting character '{' at line " << m_fileline;
384  ostr << ", column " << m_bufpos;
385  m_error = ostr.str();
386 
387  wxLogTrace( MASK_VRML, "%s\n", m_error.c_str() );
388 
389  return false;
390  }
391 
392  size_t fileline = m_fileline;
393  size_t linepos = m_bufpos;
394 
395  ++m_bufpos;
396  size_t lvl = 1;
397  std::string tmp;
398 
399  while( lvl > 0 )
400  {
401  if( !EatSpace() )
402  {
403  std::ostringstream ostr;
404  ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
405  ostr << " * [INFO] failed on file '" << m_filename << "'\n";
406  ostr << " * [INFO] line " << fileline << ", char " << linepos << " -- ";
407  ostr << "line " << m_fileline << ", char " << m_bufpos << "\n";
408  ostr << " * [INFO] " << m_error;
409  m_error = ostr.str();
410 
411  return false;
412  }
413 
414  // comments must be skipped
415  if( '#' == m_buf[m_bufpos] )
416  {
417  m_bufpos = 0;
418  m_buf.clear();
419  continue;
420  }
421 
422  if( '{' == m_buf[m_bufpos] )
423  {
424  ++m_bufpos;
425  ++lvl;
426  continue;
427  }
428 
429  if( '}' == m_buf[m_bufpos] )
430  {
431  ++m_bufpos;
432  --lvl;
433  continue;
434  }
435 
436  // note: if we have a ']' we must skip it and test the next non-blank character;
437  // this ensures that we don't miss a '}' in cases where the braces are not
438  // separated by space. if we had proceeded to ReadGlob() we could have had a problem.
439  if( ']' == m_buf[m_bufpos] || '[' == m_buf[m_bufpos] )
440  {
441  ++m_bufpos;
442  continue;
443  }
444 
445  // strings are handled as a special case since they may contain
446  // control characters and braces
447  if( '"' == m_buf[m_bufpos] )
448  {
449  if( !ReadString( tmp ) )
450  {
451  std::ostringstream ostr;
452  ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
453  ostr << " * [INFO] failed on file '" << m_filename << "'\n";
454  ostr << " * [INFO] line " << fileline << ", char " << linepos << " -- ";
455  ostr << "line " << m_fileline << ", char " << m_bufpos << "\n";
456  ostr << " * [INFO] " << m_error;
457  m_error = ostr.str();
458 
459  return false;
460  }
461  }
462 
463  // everything at this point can be read and discarded via ReadGlob()
464  if( !ReadGlob( tmp ) )
465  {
466  std::ostringstream ostr;
467  ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
468  ostr << " * [INFO] failed on file '" << m_filename << "'\n";
469  ostr << " * [INFO] line " << fileline << ", char " << linepos << " -- ";
470  ostr << "line " << m_fileline << ", char " << m_bufpos << "\n";
471  ostr << " * [INFO] " << m_error;
472  m_error = ostr.str();
473 
474  return false;
475  }
476  }
477 
478  return true;
479 }
#define MASK_VRML
Definition: wrltypes.h:37
unsigned int m_bufpos
Definition: wrlproc.h:47
bool ReadGlob(std::string &aGlob)
Definition: wrlproc.cpp:236
LINE_READER * m_file
Definition: wrlproc.h:43
unsigned int m_fileline
Definition: wrlproc.h:46
std::string m_error
Definition: wrlproc.h:50
std::string m_buf
Definition: wrlproc.h:44
std::string m_filename
Definition: wrlproc.h:52
bool ReadString(std::string &aSFString)
Definition: wrlproc.cpp:603
bool EatSpace(void)
Definition: wrlproc.cpp:182

References EatSpace(), m_buf, m_bufpos, m_error, m_file, m_fileline, m_filename, MASK_VRML, ReadGlob(), and ReadString().

Referenced by WRL2BASE::readInline(), WRL1BASE::ReadNode(), and WRL2BASE::ReadNode().

◆ EatSpace()

bool WRLPROC::EatSpace ( void  )

Definition at line 182 of file wrlproc.cpp.

183 {
184  if( !m_file )
185  {
186  m_error = "no open file";
187  return false;
188  }
189 
190  if( m_bufpos >= m_buf.size() )
191  m_buf.clear();
192 
193 RETRY:
194  while( m_buf.empty() && !m_eof )
195  getRawLine();
196 
197  // buffer may be empty if we have reached EOF or encountered IO errors
198  if( m_buf.empty() )
199  return false;
200 
201  // eliminate leading white space (including control characters and comments)
202  while( m_bufpos < m_buf.size() )
203  {
204  if( m_buf[m_bufpos] > 0x20 )
205  break;
206 
207  ++m_bufpos;
208  }
209 
210  if( m_bufpos == m_buf.size() || '#' == m_buf[m_bufpos] )
211  {
212  // lines consisting entirely of white space are not unusual
213  m_buf.clear();
214  goto RETRY;
215  }
216 
217  return true;
218 }
unsigned int m_bufpos
Definition: wrlproc.h:47
LINE_READER * m_file
Definition: wrlproc.h:43
std::string m_error
Definition: wrlproc.h:50
std::string m_buf
Definition: wrlproc.h:44
bool m_eof
Definition: wrlproc.h:45
bool getRawLine(void)
Definition: wrlproc.cpp:133

References getRawLine(), m_buf, m_bufpos, m_eof, m_error, and m_file.

Referenced by DiscardList(), DiscardNode(), Peek(), ReadGlob(), ReadMFColor(), ReadMFFloat(), ReadMFInt(), ReadMFRotation(), ReadMFString(), ReadMFVec2f(), ReadMFVec3f(), ReadName(), ReadSFBool(), ReadSFFloat(), ReadSFInt(), ReadSFRotation(), ReadSFVec2f(), ReadSFVec3f(), and ReadString().

◆ eof()

◆ GetError()

◆ GetFileName()

std::string WRLPROC::GetFileName ( void  )

Definition at line 1967 of file wrlproc.cpp.

1968 {
1969  if( !m_file )
1970  {
1971  m_error = "no open file";
1972  return "";
1973  }
1974 
1975  return std::string( m_file->GetSource().ToUTF8() );
1976 }
virtual const wxString & GetSource() const
Function GetSource returns the name of the source of the lines in an abstract sense.
Definition: richio.h:131
LINE_READER * m_file
Definition: wrlproc.h:43
std::string m_error
Definition: wrlproc.h:50

References LINE_READER::GetSource(), m_error, and m_file.

Referenced by WRL1SWITCH::Read(), WRL1MATBINDING::Read(), WRL1SHAPEHINTS::Read(), WRL1COORDS::Read(), WRL1TRANSFORM::Read(), WRL2BOX::Read(), WRL1FACESET::Read(), WRL2NORMS::Read(), WRL2COLOR::Read(), WRL2COORDS::Read(), WRL2SWITCH::Read(), WRL2INLINE::Read(), WRL1MATERIAL::Read(), WRL2MATERIAL::Read(), WRL2TRANSFORM::Read(), WRL2SHAPE::Read(), WRL2APPEARANCE::Read(), WRL2POINTSET::Read(), WRL2LINESET::Read(), and WRL2FACESET::Read().

◆ GetFilePosData()

◆ GetParentDir()

const char * WRLPROC::GetParentDir ( void  )

Definition at line 227 of file wrlproc.cpp.

228 {
229  if( m_filedir.empty() )
230  return NULL;
231 
232  return m_filedir.c_str();
233 }
std::string m_filedir
Definition: wrlproc.h:53
#define NULL

References m_filedir, and NULL.

Referenced by WRL2BASE::Read().

◆ getRawLine()

bool WRLPROC::getRawLine ( void  )
private

Definition at line 133 of file wrlproc.cpp.

134 {
135  m_error.clear();
136 
137  if( !m_file )
138  {
139  m_error = "no open file";
140  return false;
141  }
142 
143  if( m_bufpos >= m_buf.size() )
144  m_buf.clear();
145 
146  if( !m_buf.empty() )
147  return true;
148 
149  if( m_eof )
150  return false;
151 
152  GETLINE;
153 
154  if( m_eof && m_buf.empty() )
155  return false;
156 
157  // strip the EOL characters
158  while( !m_buf.empty() && ( *m_buf.rbegin() == '\r' || *m_buf.rbegin() == '\n' ) )
159  m_buf.erase( --m_buf.end() );
160 
161  if( VRML_V1 == m_fileVersion && !m_buf.empty() )
162  {
163  std::string::iterator sS = m_buf.begin();
164  std::string::iterator eS = m_buf.end();
165 
166  while( sS != eS )
167  {
168  if( ((*sS) & 0x80) )
169  {
170  m_error = " non-ASCII character sequence in VRML1 file";
171  return false;
172  }
173 
174  ++sS;
175  }
176  }
177 
178  return true;
179 }
unsigned int m_bufpos
Definition: wrlproc.h:47
LINE_READER * m_file
Definition: wrlproc.h:43
std::string m_error
Definition: wrlproc.h:50
std::string m_buf
Definition: wrlproc.h:44
bool m_eof
Definition: wrlproc.h:45
#define GETLINE
Definition: wrlproc.cpp:31
WRLVERSION m_fileVersion
Definition: wrlproc.h:49

References GETLINE, m_buf, m_bufpos, m_eof, m_error, m_file, m_fileVersion, and VRML_V1.

Referenced by EatSpace(), and ReadString().

◆ GetVRMLType()

WRLVERSION WRLPROC::GetVRMLType ( void  )

Definition at line 221 of file wrlproc.cpp.

222 {
223  return m_fileVersion;
224 }
WRLVERSION m_fileVersion
Definition: wrlproc.h:49

References m_fileVersion.

Referenced by LoadVRML(), WRL1BASE::Read(), and WRL2BASE::Read().

◆ Peek()

char WRLPROC::Peek ( void  )

Definition at line 1979 of file wrlproc.cpp.

1980 {
1981  if( !m_file )
1982  {
1983  std::ostringstream ostr;
1984  ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
1985  ostr << " * [BUG] no open file";
1986  m_error = ostr.str();
1987  return '\0';
1988  }
1989 
1990  if( !EatSpace() )
1991  {
1992  if( m_error.empty() )
1993  {
1994  std::ostringstream ostr;
1995  ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
1996  ostr << " * [INFO] failed to read data from file\n";
1997  m_error = ostr.str();
1998  }
1999 
2000  return '\0';
2001  }
2002 
2003  return m_buf[m_bufpos];
2004 }
unsigned int m_bufpos
Definition: wrlproc.h:47
LINE_READER * m_file
Definition: wrlproc.h:43
std::string m_error
Definition: wrlproc.h:50
std::string m_buf
Definition: wrlproc.h:44
bool EatSpace(void)
Definition: wrlproc.cpp:182

References EatSpace(), m_buf, m_bufpos, m_error, and m_file.

Referenced by WRL1GROUP::Read(), WRL1SEPARATOR::Read(), WRL1SWITCH::Read(), WRL1MATBINDING::Read(), WRL1SHAPEHINTS::Read(), WRL1COORDS::Read(), WRL1TRANSFORM::Read(), WRL2BOX::Read(), WRL1FACESET::Read(), WRL2NORMS::Read(), WRL2COLOR::Read(), WRL2COORDS::Read(), WRL2INLINE::Read(), WRL2SWITCH::Read(), WRL2MATERIAL::Read(), WRL1MATERIAL::Read(), WRL2TRANSFORM::Read(), WRL1BASE::Read(), WRL2SHAPE::Read(), WRL2APPEARANCE::Read(), WRL2POINTSET::Read(), WRL2LINESET::Read(), WRL2FACESET::Read(), WRL2SWITCH::readChildren(), and WRL2TRANSFORM::readChildren().

◆ Pop()

◆ ReadGlob()

bool WRLPROC::ReadGlob ( std::string &  aGlob)

Definition at line 236 of file wrlproc.cpp.

237 {
238  aGlob.clear();
239 
240  if( !m_file )
241  {
242  m_error = "no open file";
243  return false;
244  }
245 
246  while( true )
247  {
248  if( !EatSpace() )
249  return false;
250 
251  // if the text is the start of a comment block, clear the buffer and loop
252  if( '#' == m_buf[m_bufpos] )
253  m_buf.clear();
254  else
255  break;
256  }
257 
258  size_t ssize = m_buf.size();
259 
260  while( m_bufpos < ssize && m_buf[m_bufpos] > 0x20 )
261  {
262  if( ',' == m_buf[m_bufpos] )
263  {
264  // the comma is a special instance of blank space
265  ++m_bufpos;
266  return true;
267  }
268 
269  if( '{' == m_buf[m_bufpos] || '}' == m_buf[m_bufpos]
270  || '[' == m_buf[m_bufpos] || ']' == m_buf[m_bufpos] )
271  return true;
272 
273  aGlob.append( 1, m_buf[m_bufpos++] );
274  }
275 
276  return true;
277 }
unsigned int m_bufpos
Definition: wrlproc.h:47
LINE_READER * m_file
Definition: wrlproc.h:43
std::string m_error
Definition: wrlproc.h:50
std::string m_buf
Definition: wrlproc.h:44
bool EatSpace(void)
Definition: wrlproc.cpp:182

References EatSpace(), m_buf, m_bufpos, m_error, and m_file.

Referenced by DiscardList(), DiscardNode(), WRL2BASE::ReadNode(), ReadSFBool(), ReadSFFloat(), ReadSFInt(), ReadSFRotation(), ReadSFVec2f(), ReadSFVec3f(), and ReadString().

◆ ReadMFColor()

bool WRLPROC::ReadMFColor ( std::vector< WRLVEC3F > &  aMFColor)

Definition at line 1264 of file wrlproc.cpp.

1265 {
1266  aMFColor.clear();
1267  size_t fileline = m_fileline;
1268  size_t linepos = m_bufpos;
1269 
1270  if( !m_file )
1271  {
1272  m_error = "no open file";
1273  return false;
1274  }
1275 
1276  WRLVEC3F lcolor;
1277 
1278  while( true )
1279  {
1280  if( !EatSpace() )
1281  return false;
1282 
1283  // if the text is the start of a comment block, clear the buffer and loop
1284  if( '#' == m_buf[m_bufpos] )
1285  m_buf.clear();
1286  else
1287  break;
1288  }
1289 
1290  if( m_buf[m_bufpos] != '[' )
1291  {
1292  if( !ReadSFColor( lcolor ) )
1293  {
1294  std::ostringstream ostr;
1295  ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
1296  ostr << " * [INFO] failed on file '" << m_filename << "'\n";
1297  ostr << " * [INFO] line " << fileline << ", char " << linepos << " -- ";
1298  ostr << "line " << m_fileline << ", char " << m_bufpos << "\n";
1299  ostr << " * [INFO] " << m_error;
1300  m_error = ostr.str();
1301 
1302  return false;
1303  }
1304 
1305  if( !EatSpace() )
1306  {
1307  std::ostringstream ostr;
1308  ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
1309  ostr << " * [INFO] failed on file '" << m_filename << "'\n";
1310  ostr << " * [INFO] line " << fileline << ", char " << linepos << " -- ";
1311  ostr << "line " << m_fileline << ", char " << m_bufpos << "\n";
1312  ostr << " * [INFO] could not check characters after the string";
1313  m_error = ostr.str();
1314 
1315  return false;
1316  }
1317 
1318  if( ',' == m_buf[m_bufpos] )
1319  Pop();
1320 
1321  aMFColor.push_back( lcolor );
1322  return true;
1323  }
1324 
1325  ++m_bufpos;
1326 
1327  while( true )
1328  {
1329  if( !EatSpace() )
1330  return false;
1331 
1332  if( ']' == m_buf[m_bufpos] )
1333  break;
1334 
1335  if( !ReadSFColor( lcolor ) )
1336  {
1337  std::ostringstream ostr;
1338  ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
1339  ostr << " * [INFO] failed on file '" << m_filename << "'\n";
1340  ostr << " * [INFO] line " << fileline << ", char " << linepos << " -- ";
1341  ostr << "line " << m_fileline << ", char " << m_bufpos << "\n";
1342  ostr << " * [INFO] " << m_error;
1343  m_error = ostr.str();
1344 
1345  return false;
1346  }
1347 
1348  aMFColor.push_back( lcolor );
1349 
1350  if( !EatSpace() )
1351  {
1352  std::ostringstream ostr;
1353  ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
1354  ostr << " * [INFO] failed on file '" << m_filename << "'\n";
1355  ostr << " * [INFO] line " << fileline << ", char " << linepos << " -- ";
1356  ostr << "line " << m_fileline << ", char " << m_bufpos << "\n";
1357  ostr << " * [INFO] could not check characters after the string";
1358  m_error = ostr.str();
1359 
1360  return false;
1361  }
1362 
1363  if( ']' == m_buf[m_bufpos] )
1364  break;
1365 
1366  if( ',' == m_buf[m_bufpos] )
1367  Pop();
1368 
1369  }
1370 
1371  ++m_bufpos;
1372  return true;
1373 }
void Pop(void)
Definition: wrlproc.cpp:2007
glm::vec3 WRLVEC3F
Definition: wrltypes.h:185
unsigned int m_bufpos
Definition: wrlproc.h:47
LINE_READER * m_file
Definition: wrlproc.h:43
unsigned int m_fileline
Definition: wrlproc.h:46
std::string m_error
Definition: wrlproc.h:50
std::string m_buf
Definition: wrlproc.h:44
std::string m_filename
Definition: wrlproc.h:52
bool ReadSFColor(WRLVEC3F &aSFColor)
Definition: wrlproc.cpp:757
bool EatSpace(void)
Definition: wrlproc.cpp:182

References EatSpace(), m_buf, m_bufpos, m_error, m_file, m_fileline, m_filename, Pop(), and ReadSFColor().

◆ ReadMFFloat()

bool WRLPROC::ReadMFFloat ( std::vector< float > &  aMFFloat)

Definition at line 1376 of file wrlproc.cpp.

1377 {
1378  aMFFloat.clear();
1379  size_t fileline = m_fileline;
1380  size_t linepos = m_bufpos;
1381 
1382  if( !m_file )
1383  {
1384  m_error = "no open file";
1385  return false;
1386  }
1387 
1388  float temp;
1389 
1390  while( true )
1391  {
1392  if( !EatSpace() )
1393  return false;
1394 
1395  // if the text is the start of a comment block, clear the buffer and loop
1396  if( '#' == m_buf[m_bufpos] )
1397  m_buf.clear();
1398  else
1399  break;
1400  }
1401 
1402  if( m_buf[m_bufpos] != '[' )
1403  {
1404  if( !ReadSFFloat( temp ) )
1405  {
1406  std::ostringstream ostr;
1407  ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
1408  ostr << " * [INFO] failed on file '" << m_filename << "'\n";
1409  ostr << " * [INFO] line " << fileline << ", char " << linepos << " -- ";
1410  ostr << "line " << m_fileline << ", char " << m_bufpos << "\n";
1411  ostr << " * [INFO] " << m_error;
1412  m_error = ostr.str();
1413 
1414  return false;
1415  }
1416 
1417  if( !EatSpace() )
1418  {
1419  std::ostringstream ostr;
1420  ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
1421  ostr << " * [INFO] failed on file '" << m_filename << "'\n";
1422  ostr << " * [INFO] line " << fileline << ", char " << linepos << " -- ";
1423  ostr << "line " << m_fileline << ", char " << m_bufpos << "\n";
1424  ostr << " * [INFO] could not check characters after the string";
1425  m_error = ostr.str();
1426 
1427  return false;
1428  }
1429 
1430  if( ',' == m_buf[m_bufpos] )
1431  Pop();
1432 
1433  aMFFloat.push_back( temp );
1434  return true;
1435  }
1436 
1437  ++m_bufpos;
1438 
1439  while( true )
1440  {
1441  if( !EatSpace() )
1442  return false;
1443 
1444  if( ']' == m_buf[m_bufpos] )
1445  break;
1446 
1447  if( !ReadSFFloat( temp ) )
1448  {
1449  std::ostringstream ostr;
1450  ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
1451  ostr << " * [INFO] failed on file '" << m_filename << "'\n";
1452  ostr << " * [INFO] line " << fileline << ", char " << linepos << " -- ";
1453  ostr << "line " << m_fileline << ", char " << m_bufpos << "\n";
1454  ostr << " * [INFO] " << m_error;
1455  m_error = ostr.str();
1456 
1457  return false;
1458  }
1459 
1460  aMFFloat.push_back( temp );
1461 
1462  if( !EatSpace() )
1463  {
1464  std::ostringstream ostr;
1465  ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
1466  ostr << " * [INFO] failed on file '" << m_filename << "'\n";
1467  ostr << " * [INFO] line " << fileline << ", char " << linepos << " -- ";
1468  ostr << "line " << m_fileline << ", char " << m_bufpos << "\n";
1469  ostr << " * [INFO] could not check characters after the string";
1470  m_error = ostr.str();
1471 
1472  return false;
1473  }
1474 
1475  if( ']' == m_buf[m_bufpos] )
1476  break;
1477 
1478  if( ',' == m_buf[m_bufpos] )
1479  Pop();
1480 
1481  }
1482 
1483  ++m_bufpos;
1484  return true;
1485 }
void Pop(void)
Definition: wrlproc.cpp:2007
unsigned int m_bufpos
Definition: wrlproc.h:47
LINE_READER * m_file
Definition: wrlproc.h:43
unsigned int m_fileline
Definition: wrlproc.h:46
std::string m_error
Definition: wrlproc.h:50
std::string m_buf
Definition: wrlproc.h:44
bool ReadSFFloat(float &aSFFloat)
Definition: wrlproc.cpp:789
std::string m_filename
Definition: wrlproc.h:52
bool EatSpace(void)
Definition: wrlproc.cpp:182

References EatSpace(), m_buf, m_bufpos, m_error, m_file, m_fileline, m_filename, Pop(), and ReadSFFloat().

Referenced by WRL1MATERIAL::Read().

◆ ReadMFInt()

bool WRLPROC::ReadMFInt ( std::vector< int > &  aMFInt32)

Definition at line 1488 of file wrlproc.cpp.

1489 {
1490  aMFInt32.clear();
1491  size_t fileline = m_fileline;
1492  size_t linepos = m_bufpos;
1493 
1494  if( !m_file )
1495  {
1496  m_error = "no open file";
1497  return false;
1498  }
1499 
1500  int temp;
1501 
1502  while( true )
1503  {
1504  if( !EatSpace() )
1505  return false;
1506 
1507  // if the text is the start of a comment block, clear the buffer and loop
1508  if( '#' == m_buf[m_bufpos] )
1509  m_buf.clear();
1510  else
1511  break;
1512  }
1513 
1514  if( m_buf[m_bufpos] != '[' )
1515  {
1516  if( !ReadSFInt( temp ) )
1517  {
1518  std::ostringstream ostr;
1519  ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
1520  ostr << " * [INFO] failed on file '" << m_filename << "'\n";
1521  ostr << " * [INFO] line " << fileline << ", char " << linepos << " -- ";
1522  ostr << "line " << m_fileline << ", char " << m_bufpos << "\n";
1523  ostr << " * [INFO] " << m_error;
1524  m_error = ostr.str();
1525 
1526  return false;
1527  }
1528 
1529  if( !EatSpace() )
1530  {
1531  std::ostringstream ostr;
1532  ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
1533  ostr << " * [INFO] failed on file '" << m_filename << "'\n";
1534  ostr << " * [INFO] line " << fileline << ", char " << linepos << " -- ";
1535  ostr << "line " << m_fileline << ", char " << m_bufpos << "\n";
1536  ostr << " * [INFO] could not check characters after the string";
1537  m_error = ostr.str();
1538 
1539  return false;
1540  }
1541 
1542  if( ',' == m_buf[m_bufpos] )
1543  Pop();
1544 
1545  aMFInt32.push_back( temp );
1546  return true;
1547  }
1548 
1549  ++m_bufpos;
1550 
1551  while( true )
1552  {
1553  if( !EatSpace() )
1554  return false;
1555 
1556  if( ']' == m_buf[m_bufpos] )
1557  break;
1558 
1559  if( !ReadSFInt( temp ) )
1560  {
1561  std::ostringstream ostr;
1562  ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
1563  ostr << " * [INFO] failed on file '" << m_filename << "'\n";
1564  ostr << " * [INFO] line " << fileline << ", char " << linepos << " -- ";
1565  ostr << "line " << m_fileline << ", char " << m_bufpos << "\n";
1566  ostr << " * [INFO] " << m_error;
1567  m_error = ostr.str();
1568 
1569  return false;
1570  }
1571 
1572  aMFInt32.push_back( temp );
1573 
1574  if( !EatSpace() )
1575  {
1576  std::ostringstream ostr;
1577  ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
1578  ostr << " * [INFO] failed on file '" << m_filename << "'\n";
1579  ostr << " * [INFO] line " << fileline << ", char " << linepos << " -- ";
1580  ostr << "line " << m_fileline << ", char " << m_bufpos << "\n";
1581  ostr << " * [INFO] could not check characters after the string";
1582  m_error = ostr.str();
1583 
1584  return false;
1585  }
1586 
1587  if( ']' == m_buf[m_bufpos] )
1588  break;
1589 
1590  if( ',' == m_buf[m_bufpos] )
1591  Pop();
1592 
1593  }
1594 
1595  ++m_bufpos;
1596  return true;
1597 }
void Pop(void)
Definition: wrlproc.cpp:2007
unsigned int m_bufpos
Definition: wrlproc.h:47
LINE_READER * m_file
Definition: wrlproc.h:43
unsigned int m_fileline
Definition: wrlproc.h:46
std::string m_error
Definition: wrlproc.h:50
std::string m_buf
Definition: wrlproc.h:44
std::string m_filename
Definition: wrlproc.h:52
bool ReadSFInt(int &aSFInt32)
Definition: wrlproc.cpp:850
bool EatSpace(void)
Definition: wrlproc.cpp:182

References EatSpace(), m_buf, m_bufpos, m_error, m_file, m_fileline, m_filename, Pop(), and ReadSFInt().

Referenced by WRL1FACESET::Read(), WRL2LINESET::Read(), and WRL2FACESET::Read().

◆ ReadMFRotation()

bool WRLPROC::ReadMFRotation ( std::vector< WRLROTATION > &  aMFRotation)

Definition at line 1600 of file wrlproc.cpp.

1601 {
1602  aMFRotation.clear();
1603  size_t fileline = m_fileline;
1604  size_t linepos = m_bufpos;
1605 
1606  if( !m_file )
1607  {
1608  m_error = "no open file";
1609  return false;
1610  }
1611 
1612  WRLROTATION lrot;
1613 
1614  while( true )
1615  {
1616  if( !EatSpace() )
1617  return false;
1618 
1619  // if the text is the start of a comment block, clear the buffer and loop
1620  if( '#' == m_buf[m_bufpos] )
1621  m_buf.clear();
1622  else
1623  break;
1624  }
1625 
1626  if( m_buf[m_bufpos] != '[' )
1627  {
1628  if( !ReadSFRotation( lrot ) )
1629  {
1630  std::ostringstream ostr;
1631  ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
1632  ostr << " * [INFO] failed on file '" << m_filename << "'\n";
1633  ostr << " * [INFO] line " << fileline << ", char " << linepos << " -- ";
1634  ostr << "line " << m_fileline << ", char " << m_bufpos << "\n";
1635  ostr << " * [INFO] " << m_error;
1636  m_error = ostr.str();
1637 
1638  return false;
1639  }
1640 
1641  if( !EatSpace() )
1642  {
1643  std::ostringstream ostr;
1644  ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
1645  ostr << " * [INFO] failed on file '" << m_filename << "'\n";
1646  ostr << " * [INFO] line " << fileline << ", char " << linepos << " -- ";
1647  ostr << "line " << m_fileline << ", char " << m_bufpos << "\n";
1648  ostr << " * [INFO] could not check characters after the string";
1649  m_error = ostr.str();
1650 
1651  return false;
1652  }
1653 
1654  if( ',' == m_buf[m_bufpos] )
1655  Pop();
1656 
1657  aMFRotation.push_back( lrot );
1658  return true;
1659  }
1660 
1661  ++m_bufpos;
1662 
1663  while( true )
1664  {
1665  if( !EatSpace() )
1666  return false;
1667 
1668  if( ']' == m_buf[m_bufpos] )
1669  break;
1670 
1671  if( !ReadSFRotation( lrot ) )
1672  {
1673  std::ostringstream ostr;
1674  ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
1675  ostr << " * [INFO] failed on file '" << m_filename << "'\n";
1676  ostr << " * [INFO] line " << fileline << ", char " << linepos << " -- ";
1677  ostr << "line " << m_fileline << ", char " << m_bufpos << "\n";
1678  ostr << " * [INFO] " << m_error;
1679  m_error = ostr.str();
1680 
1681  return false;
1682  }
1683 
1684  aMFRotation.push_back( lrot );
1685 
1686  if( !EatSpace() )
1687  {
1688  std::ostringstream ostr;
1689  ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
1690  ostr << " * [INFO] failed on file '" << m_filename << "'\n";
1691  ostr << " * [INFO] line " << fileline << ", char " << linepos << " -- ";
1692  ostr << "line " << m_fileline << ", char " << m_bufpos << "\n";
1693  ostr << " * [INFO] could not check characters after the string";
1694  m_error = ostr.str();
1695 
1696  return false;
1697  }
1698 
1699  if( ']' == m_buf[m_bufpos] )
1700  break;
1701 
1702  if( ',' == m_buf[m_bufpos] )
1703  Pop();
1704 
1705  }
1706 
1707  ++m_bufpos;
1708  return true;
1709 }
bool ReadSFRotation(WRLROTATION &aSFRotation)
Definition: wrlproc.cpp:920
void Pop(void)
Definition: wrlproc.cpp:2007
unsigned int m_bufpos
Definition: wrlproc.h:47
glm::vec4 WRLROTATION
Definition: wrltypes.h:186
LINE_READER * m_file
Definition: wrlproc.h:43
unsigned int m_fileline
Definition: wrlproc.h:46
std::string m_error
Definition: wrlproc.h:50
std::string m_buf
Definition: wrlproc.h:44
std::string m_filename
Definition: wrlproc.h:52
bool EatSpace(void)
Definition: wrlproc.cpp:182

References EatSpace(), m_buf, m_bufpos, m_error, m_file, m_fileline, m_filename, Pop(), and ReadSFRotation().

◆ ReadMFString()

bool WRLPROC::ReadMFString ( std::vector< std::string > &  aMFString)

Definition at line 1145 of file wrlproc.cpp.

1146 {
1147  aMFString.clear();
1148  size_t fileline = m_fileline;
1149  size_t linepos = m_bufpos;
1150 
1151  if( !m_file )
1152  {
1153  m_error = "no open file";
1154  return false;
1155  }
1156 
1157  while( true )
1158  {
1159  if( !EatSpace() )
1160  return false;
1161 
1162  // if the text is the start of a comment block, clear the buffer and loop
1163  if( '#' == m_buf[m_bufpos] )
1164  m_buf.clear();
1165  else
1166  break;
1167  }
1168 
1169  std::string lstr;
1170 
1171  if( m_buf[m_bufpos] != '[' )
1172  {
1173  if( !ReadString( lstr ) )
1174  {
1175  std::ostringstream ostr;
1176  ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
1177  ostr << " * [INFO] failed on file '" << m_filename << "'\n";
1178  ostr << " * [INFO] line " << fileline << ", char " << linepos << " -- ";
1179  ostr << "line " << m_fileline << ", char " << m_bufpos << "\n";
1180  ostr << " * [INFO] " << m_error;
1181  m_error = ostr.str();
1182 
1183  return false;
1184  }
1185 
1186  if( m_bufpos >= m_buf.size() && !EatSpace() )
1187  {
1188  std::ostringstream ostr;
1189  ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
1190  ostr << " * [INFO] failed on file '" << m_filename << "'\n";
1191  ostr << " * [INFO] line " << fileline << ", char " << linepos << " -- ";
1192  ostr << "line " << m_fileline << ", char " << m_bufpos << "\n";
1193  ostr << " * [INFO] could not check characters after the string";
1194  m_error = ostr.str();
1195 
1196  return false;
1197  }
1198 
1199  if( ',' == m_buf[m_bufpos] )
1200  Pop();
1201 
1202  aMFString.push_back( lstr );
1203  return true;
1204  }
1205 
1206  ++m_bufpos;
1207 
1208  while( true )
1209  {
1210  if( !ReadString( lstr ) )
1211  {
1212  std::ostringstream ostr;
1213  ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
1214  ostr << " * [INFO] failed on file '" << m_filename << "'\n";
1215  ostr << " * [INFO] line " << fileline << ", char " << linepos << " -- ";
1216  ostr << "line " << m_fileline << ", char " << m_bufpos << "\n";
1217  ostr << " * [INFO] " << m_error;
1218  m_error = ostr.str();
1219 
1220  return false;
1221  }
1222 
1223  if( !EatSpace() )
1224  {
1225  std::ostringstream ostr;
1226  ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
1227  ostr << " * [INFO] failed on file '" << m_filename << "'\n";
1228  ostr << " * [INFO] line " << fileline << ", char " << linepos << " -- ";
1229  ostr << "line " << m_fileline << ", char " << m_bufpos << "\n";
1230  ostr << " * [INFO] could not check characters after the string";
1231  m_error = ostr.str();
1232 
1233  return false;
1234  }
1235 
1236  if( ',' == m_buf[m_bufpos] )
1237  Pop();
1238 
1239  aMFString.push_back( lstr );
1240 
1241  if( !EatSpace() )
1242  {
1243  std::ostringstream ostr;
1244  ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
1245  ostr << " * [INFO] failed on file '" << m_filename << "'\n";
1246  ostr << " * [INFO] line " << fileline << ", char " << linepos << " -- ";
1247  ostr << "line " << m_fileline << ", char " << m_bufpos << "\n";
1248  ostr << " * [INFO] problems encountered while reading list";
1249  m_error = ostr.str();
1250 
1251  return false;
1252  }
1253 
1254  if( ']' == m_buf[m_bufpos] )
1255  break;
1256 
1257  }
1258 
1259  ++m_bufpos;
1260  return true;
1261 }
void Pop(void)
Definition: wrlproc.cpp:2007
unsigned int m_bufpos
Definition: wrlproc.h:47
LINE_READER * m_file
Definition: wrlproc.h:43
unsigned int m_fileline
Definition: wrlproc.h:46
std::string m_error
Definition: wrlproc.h:50
std::string m_buf
Definition: wrlproc.h:44
std::string m_filename
Definition: wrlproc.h:52
bool ReadString(std::string &aSFString)
Definition: wrlproc.cpp:603
bool EatSpace(void)
Definition: wrlproc.cpp:182

References EatSpace(), m_buf, m_bufpos, m_error, m_file, m_fileline, m_filename, Pop(), and ReadString().

Referenced by WRL2INLINE::Read().

◆ ReadMFVec2f()

bool WRLPROC::ReadMFVec2f ( std::vector< WRLVEC2F > &  aMFVec2f)

Definition at line 1712 of file wrlproc.cpp.

1713 {
1714  aMFVec2f.clear();
1715  size_t fileline = m_fileline;
1716  size_t linepos = m_bufpos;
1717 
1718  if( !m_file )
1719  {
1720  m_error = "no open file";
1721  return false;
1722  }
1723 
1724  WRLVEC2F lvec2f;
1725 
1726  while( true )
1727  {
1728  if( !EatSpace() )
1729  return false;
1730 
1731  // if the text is the start of a comment block, clear the buffer and loop
1732  if( '#' == m_buf[m_bufpos] )
1733  m_buf.clear();
1734  else
1735  break;
1736  }
1737 
1738  if( m_buf[m_bufpos] != '[' )
1739  {
1740  if( !ReadSFVec2f( lvec2f ) )
1741  {
1742  std::ostringstream ostr;
1743  ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
1744  ostr << " * [INFO] failed on file '" << m_filename << "'\n";
1745  ostr << " * [INFO] line " << fileline << ", char " << linepos << " -- ";
1746  ostr << "line " << m_fileline << ", char " << m_bufpos << "\n";
1747  ostr << " * [INFO] " << m_error;
1748  m_error = ostr.str();
1749 
1750  return false;
1751  }
1752 
1753  if( !EatSpace() )
1754  {
1755  std::ostringstream ostr;
1756  ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
1757  ostr << " * [INFO] failed on file '" << m_filename << "'\n";
1758  ostr << " * [INFO] line " << fileline << ", char " << linepos << " -- ";
1759  ostr << "line " << m_fileline << ", char " << m_bufpos << "\n";
1760  ostr << " * [INFO] could not check characters after the string";
1761  m_error = ostr.str();
1762 
1763  return false;
1764  }
1765 
1766  if( ',' == m_buf[m_bufpos] )
1767  Pop();
1768 
1769  aMFVec2f.push_back( lvec2f );
1770  return true;
1771  }
1772 
1773  ++m_bufpos;
1774 
1775  while( true )
1776  {
1777  if( !EatSpace() )
1778  return false;
1779 
1780  if( ']' == m_buf[m_bufpos] )
1781  break;
1782 
1783  if( !ReadSFVec2f( lvec2f ) )
1784  {
1785  std::ostringstream ostr;
1786  ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
1787  ostr << " * [INFO] failed on file '" << m_filename << "'\n";
1788  ostr << " * [INFO] line " << fileline << ", char " << linepos << " -- ";
1789  ostr << "line " << m_fileline << ", char " << m_bufpos << "\n";
1790  ostr << " * [INFO] " << m_error;
1791  m_error = ostr.str();
1792 
1793  return false;
1794  }
1795 
1796  aMFVec2f.push_back( lvec2f );
1797 
1798  if( !EatSpace() )
1799  {
1800  std::ostringstream ostr;
1801  ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
1802  ostr << " * [INFO] failed on file '" << m_filename << "'\n";
1803  ostr << " * [INFO] line " << fileline << ", char " << linepos << " -- ";
1804  ostr << "line " << m_fileline << ", char " << m_bufpos << "\n";
1805  ostr << " * [INFO] could not check characters after the string";
1806  m_error = ostr.str();
1807 
1808  return false;
1809  }
1810 
1811  if( ']' == m_buf[m_bufpos] )
1812  break;
1813 
1814  if( ',' == m_buf[m_bufpos] )
1815  Pop();
1816 
1817  }
1818 
1819  ++m_bufpos;
1820  return true;
1821 }
void Pop(void)
Definition: wrlproc.cpp:2007
unsigned int m_bufpos
Definition: wrlproc.h:47
glm::vec2 WRLVEC2F
Definition: wrltypes.h:184
LINE_READER * m_file
Definition: wrlproc.h:43
unsigned int m_fileline
Definition: wrlproc.h:46
std::string m_error
Definition: wrlproc.h:50
std::string m_buf
Definition: wrlproc.h:44
std::string m_filename
Definition: wrlproc.h:52
bool ReadSFVec2f(WRLVEC2F &aSFVec2f)
Definition: wrlproc.cpp:994
bool EatSpace(void)
Definition: wrlproc.cpp:182

References EatSpace(), m_buf, m_bufpos, m_error, m_file, m_fileline, m_filename, Pop(), and ReadSFVec2f().

◆ ReadMFVec3f()

bool WRLPROC::ReadMFVec3f ( std::vector< WRLVEC3F > &  aMFVec3f)

Definition at line 1824 of file wrlproc.cpp.

1825 {
1826  aMFVec3f.clear();
1827  size_t fileline = m_fileline;
1828  size_t linepos = m_bufpos;
1829 
1830  if( !m_file )
1831  {
1832  m_error = "no open file";
1833  return false;
1834  }
1835 
1836  WRLVEC3F lvec3f;
1837 
1838  while( true )
1839  {
1840  if( !EatSpace() )
1841  return false;
1842 
1843  // if the text is the start of a comment block, clear the buffer and loop
1844  if( '#' == m_buf[m_bufpos] )
1845  m_buf.clear();
1846  else
1847  break;
1848  }
1849 
1850  if( m_buf[m_bufpos] != '[' )
1851  {
1852  if( !ReadSFVec3f( lvec3f ) )
1853  {
1854  std::ostringstream ostr;
1855  ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
1856  ostr << " * [INFO] failed on file '" << m_filename << "'\n";
1857  ostr << " * [INFO] line " << fileline << ", char " << linepos << " -- ";
1858  ostr << "line " << m_fileline << ", char " << m_bufpos << "\n";
1859  ostr << " * [INFO] " << m_error;
1860  m_error = ostr.str();
1861 
1862  return false;
1863  }
1864 
1865  if( !EatSpace() )
1866  {
1867  std::ostringstream ostr;
1868  ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
1869  ostr << " * [INFO] failed on file '" << m_filename << "'\n";
1870  ostr << " * [INFO] line " << fileline << ", char " << linepos << " -- ";
1871  ostr << "line " << m_fileline << ", char " << m_bufpos << "\n";
1872  ostr << " * [INFO] could not check characters after the string";
1873  m_error = ostr.str();
1874 
1875  return false;
1876  }
1877 
1878  if( ',' == m_buf[m_bufpos] )
1879  Pop();
1880 
1881  aMFVec3f.push_back( lvec3f );
1882  return true;
1883  }
1884 
1885  ++m_bufpos;
1886 
1887  while( true )
1888  {
1889  if( !EatSpace() )
1890  return false;
1891 
1892  if( ']' == m_buf[m_bufpos] )
1893  break;
1894 
1895  if( !ReadSFVec3f( lvec3f ) )
1896  {
1897  std::ostringstream ostr;
1898  ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
1899  ostr << " * [INFO] failed on file '" << m_filename << "'\n";
1900  ostr << " * [INFO] line " << fileline << ", char " << linepos << " -- ";
1901  ostr << "line " << m_fileline << ", char " << m_bufpos << "\n";
1902  ostr << " * [INFO] " << m_error;
1903  m_error = ostr.str();
1904 
1905  return false;
1906  }
1907 
1908  aMFVec3f.push_back( lvec3f );
1909 
1910  if( !EatSpace() )
1911  {
1912  std::ostringstream ostr;
1913  ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
1914  ostr << " * [INFO] failed on file '" << m_filename << "'\n";
1915  ostr << " * [INFO] line " << fileline << ", char " << linepos << " -- ";
1916  ostr << "line " << m_fileline << ", char " << m_bufpos << "\n";
1917  ostr << " * [INFO] could not check characters after the string";
1918  m_error = ostr.str();
1919 
1920  return false;
1921  }
1922 
1923  if( !EatSpace() )
1924  return false;
1925 
1926  if( ']' == m_buf[m_bufpos] )
1927  break;
1928 
1929  if( ',' == m_buf[m_bufpos] )
1930  Pop();
1931 
1932  }
1933 
1934  ++m_bufpos;
1935  return true;
1936 }
void Pop(void)
Definition: wrlproc.cpp:2007
glm::vec3 WRLVEC3F
Definition: wrltypes.h:185
bool ReadSFVec3f(WRLVEC3F &aSFVec3f)
Definition: wrlproc.cpp:1065
unsigned int m_bufpos
Definition: wrlproc.h:47
LINE_READER * m_file
Definition: wrlproc.h:43
unsigned int m_fileline
Definition: wrlproc.h:46
std::string m_error
Definition: wrlproc.h:50
std::string m_buf
Definition: wrlproc.h:44
std::string m_filename
Definition: wrlproc.h:52
bool EatSpace(void)
Definition: wrlproc.cpp:182

References EatSpace(), m_buf, m_bufpos, m_error, m_file, m_fileline, m_filename, Pop(), and ReadSFVec3f().

Referenced by WRL1COORDS::Read(), WRL2NORMS::Read(), WRL2COORDS::Read(), WRL2COLOR::Read(), and WRL1MATERIAL::Read().

◆ ReadName()

bool WRLPROC::ReadName ( std::string &  aName)

Definition at line 280 of file wrlproc.cpp.

281 {
282  aName.clear();
283 
284  if( !m_file )
285  {
286  m_error = "no open file";
287  return false;
288  }
289 
290  while( true )
291  {
292  if( !EatSpace() )
293  return false;
294 
295  // if the text is the start of a comment block, clear the buffer and loop
296  if( '#' == m_buf[m_bufpos] )
297  m_buf.clear();
298  else
299  break;
300  }
301 
302  size_t ssize = m_buf.size();
303 
304  while( m_bufpos < ssize && m_buf[m_bufpos] > 0x20 )
305  {
306  if( '[' == m_buf[m_bufpos] || '{' == m_buf[m_bufpos]
307  || ']' == m_buf[m_bufpos] || '}' == m_buf[m_bufpos]
308  || '.' == m_buf[m_bufpos] || '#' == m_buf[m_bufpos]
309  || ',' == m_buf[m_bufpos] )
310  {
311  if( !aName.empty() )
312  {
313  return true;
314  }
315  else
316  {
317  std::ostringstream ostr;
318  ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
319  ostr << " * [INFO] failed on file '" << m_filename << "'\n";
320  ostr << " * [INFO] line " << m_fileline << ", column " << m_bufpos;
321  ostr << " -- invalid name";
322  m_error = ostr.str();
323 
324  return false;
325  }
326  }
327 
328  if( m_badchars.find( m_buf[m_bufpos] ) != std::string::npos )
329  {
330  std::ostringstream ostr;
331  ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
332  ostr << " * [INFO] failed on file '" << m_filename << "'\n";
333  ostr << " * [INFO] line " << m_fileline << ", column " << m_bufpos;
334  ostr << " -- invalid character in name";
335  m_error = ostr.str();
336 
337  return false;
338  }
339 
340  if( aName.empty() && m_buf[m_bufpos] >= '0' && m_buf[m_bufpos] <= '9' )
341  {
342  std::ostringstream ostr;
343  ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
344  ostr << " * [INFO] failed on file '" << m_filename << "'\n";
345  ostr << " * [INFO] line " << m_fileline << ", column " << m_bufpos;
346  ostr << " -- name must not start with a digit";
347  m_error = ostr.str();
348 
349  return false;
350  }
351 
352  aName.append( 1, m_buf[m_bufpos++] );
353  }
354 
355  return true;
356 }
unsigned int m_bufpos
Definition: wrlproc.h:47
LINE_READER * m_file
Definition: wrlproc.h:43
unsigned int m_fileline
Definition: wrlproc.h:46
std::string m_badchars
Definition: wrlproc.h:51
std::string m_error
Definition: wrlproc.h:50
std::string m_buf
Definition: wrlproc.h:44
std::string m_filename
Definition: wrlproc.h:52
bool EatSpace(void)
Definition: wrlproc.cpp:182

References EatSpace(), m_badchars, m_buf, m_bufpos, m_error, m_file, m_fileline, and m_filename.

Referenced by WRL1BASE::implementDef(), WRL2BASE::implementDef(), WRL1BASE::implementUse(), WRL2BASE::implementUse(), WRL1SWITCH::Read(), WRL1MATBINDING::Read(), WRL1SHAPEHINTS::Read(), WRL1COORDS::Read(), WRL1TRANSFORM::Read(), WRL1FACESET::Read(), WRL2BOX::Read(), WRL2COLOR::Read(), WRL2COORDS::Read(), WRL2NORMS::Read(), WRL2INLINE::Read(), WRL2SWITCH::Read(), WRL2MATERIAL::Read(), WRL1MATERIAL::Read(), WRL2TRANSFORM::Read(), WRL2SHAPE::Read(), WRL2APPEARANCE::Read(), WRL2POINTSET::Read(), WRL2LINESET::Read(), WRL2FACESET::Read(), WRL1BASE::ReadNode(), and WRL2BASE::ReadNode().

◆ ReadSFBool()

bool WRLPROC::ReadSFBool ( bool &  aSFBool)

Definition at line 720 of file wrlproc.cpp.

721 {
722  if( !EatSpace() )
723  return false;
724 
725  size_t fileline = m_fileline;
726  size_t linepos = m_bufpos;
727  std::string tmp;
728 
729  if( !ReadGlob( tmp ) )
730  return false;
731 
732  if( !tmp.compare( "0" ) )
733  aSFBool = false;
734  else if( !tmp.compare( "1" ) )
735  aSFBool = true;
736  else if( !tmp.compare( "TRUE" ) )
737  aSFBool = true;
738  else if( !tmp.compare( "FALSE" ) )
739  aSFBool = false;
740  else
741  {
742  std::ostringstream ostr;
743  ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
744  ostr << " * [INFO] failed on file '" << m_filename << "'\n";
745  ostr << " * [INFO] line " << fileline << ", char " << linepos << " -- ";
746  ostr << "line " << m_fileline << ", char " << m_bufpos << "\n";
747  ostr << " * [INFO] expected one of 0, 1, TRUE, FALSE but got '" << tmp << "'\n";
748  m_error = ostr.str();
749 
750  return false;
751  }
752 
753  return true;
754 }
unsigned int m_bufpos
Definition: wrlproc.h:47
bool ReadGlob(std::string &aGlob)
Definition: wrlproc.cpp:236
unsigned int m_fileline
Definition: wrlproc.h:46
std::string m_error
Definition: wrlproc.h:50
std::string m_filename
Definition: wrlproc.h:52
bool EatSpace(void)
Definition: wrlproc.cpp:182

References EatSpace(), m_bufpos, m_error, m_fileline, m_filename, and ReadGlob().

Referenced by WRL2LINESET::Read(), and WRL2FACESET::Read().

◆ ReadSFColor()

bool WRLPROC::ReadSFColor ( WRLVEC3F aSFColor)

Definition at line 757 of file wrlproc.cpp.

758 {
759  if( !m_file )
760  {
761  m_error = "no open file";
762  return false;
763  }
764 
765  size_t fileline = m_fileline;
766  size_t linepos = m_bufpos;
767 
768  if( !ReadSFVec3f( aSFColor ) )
769  return false;
770 
771  if( aSFColor.x < 0.0 || aSFColor.x > 1.0 || aSFColor.y < 0.0 || aSFColor.y > 1.0
772  || aSFColor.z < 0.0 || aSFColor.z > 1.0 )
773  {
774  std::ostringstream ostr;
775  ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
776  ostr << " * [INFO] failed on file '" << m_filename << "'\n";
777  ostr << " * [INFO] line " << fileline << ", char " << linepos << " -- ";
778  ostr << "line " << m_fileline << ", char " << m_bufpos << "\n";
779  ostr << " * [INFO] invalid RGB value in color triplet";
780  m_error = ostr.str();
781 
782  return false;
783  }
784 
785  return true;
786 }
bool ReadSFVec3f(WRLVEC3F &aSFVec3f)
Definition: wrlproc.cpp:1065
unsigned int m_bufpos
Definition: wrlproc.h:47
LINE_READER * m_file
Definition: wrlproc.h:43
unsigned int m_fileline
Definition: wrlproc.h:46
std::string m_error
Definition: wrlproc.h:50
std::string m_filename
Definition: wrlproc.h:52

References m_bufpos, m_error, m_file, m_fileline, m_filename, and ReadSFVec3f().

Referenced by ReadMFColor().

◆ ReadSFFloat()

bool WRLPROC::ReadSFFloat ( float &  aSFFloat)

Definition at line 789 of file wrlproc.cpp.

790 {
791  if( !m_file )
792  {
793  m_error = "no open file";
794  return false;
795  }
796 
797  aSFFloat = 0.0;
798 
799  size_t fileline = m_fileline;
800  size_t linepos = m_bufpos;
801 
802  while( true )
803  {
804  if( !EatSpace() )
805  return false;
806 
807  // if the text is the start of a comment block, clear the buffer and loop
808  if( '#' == m_buf[m_bufpos] )
809  m_buf.clear();
810  else
811  break;
812  }
813 
814  std::string tmp;
815 
816  if( !ReadGlob( tmp ) )
817  {
818  std::ostringstream ostr;
819  ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
820  ostr << " * [INFO] failed on file '" << m_filename << "'\n";
821  ostr << " * [INFO] line " << fileline << ", char " << linepos << " -- ";
822  ostr << "line " << m_fileline << ", char " << m_bufpos << "\n";
823  ostr << " * [INFO] " << m_error;
824  m_error = ostr.str();
825 
826  return false;
827  }
828 
829  std::istringstream istr;
830  istr.str( tmp );
831  istr >> aSFFloat;
832 
833  if( istr.fail() || !istr.eof() )
834  {
835  std::ostringstream ostr;
836  ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
837  ostr << " * [INFO] failed on file '" << m_filename << "'\n";
838  ostr << " * [INFO] line " << fileline << ", char " << linepos << " -- ";
839  ostr << "line " << m_fileline << ", char " << m_bufpos << "\n";
840  ostr << " * [INFO] invalid character in SFFloat";
841  m_error = ostr.str();
842 
843  return false;
844  }
845 
846  return true;
847 }
unsigned int m_bufpos
Definition: wrlproc.h:47
bool ReadGlob(std::string &aGlob)
Definition: wrlproc.cpp:236
LINE_READER * m_file
Definition: wrlproc.h:43
unsigned int m_fileline
Definition: wrlproc.h:46
std::string m_error
Definition: wrlproc.h:50
std::string m_buf
Definition: wrlproc.h:44
std::string m_filename
Definition: wrlproc.h:52
bool EatSpace(void)
Definition: wrlproc.cpp:182

References EatSpace(), m_buf, m_bufpos, m_error, m_file, m_fileline, m_filename, and ReadGlob().

Referenced by WRL1SHAPEHINTS::Read(), WRL2MATERIAL::Read(), WRL2FACESET::Read(), and ReadMFFloat().

◆ ReadSFInt()

bool WRLPROC::ReadSFInt ( int &  aSFInt32)

Definition at line 850 of file wrlproc.cpp.

851 {
852  if( !m_file )
853  {
854  m_error = "no open file";
855  return false;
856  }
857 
858  aSFInt32 = 0;
859  size_t fileline = m_fileline;
860  size_t linepos = m_bufpos;
861 
862  while( true )
863  {
864  if( !EatSpace() )
865  return false;
866 
867  // if the text is the start of a comment block, clear the buffer and loop
868  if( '#' == m_buf[m_bufpos] )
869  m_buf.clear();
870  else
871  break;
872  }
873 
874  std::string tmp;
875 
876  if( !ReadGlob( tmp ) )
877  {
878  std::ostringstream ostr;
879  ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
880  ostr << " * [INFO] failed on file '" << m_filename << "'\n";
881  ostr << " * [INFO] line " << fileline<< ", char " << linepos << " -- ";
882  ostr << "line " << m_fileline << ", char " << m_bufpos << "\n";
883  ostr << " * [INFO] " << m_error;
884  m_error = ostr.str();
885 
886  return false;
887  }
888 
889  if( std::string::npos != tmp.find( "0x" ) )
890  {
891  // Rules: "0x" + "0-9, A-F" - VRML is case sensitive but in
892  // this instance we do no enforce case.
893  std::stringstream sstr;
894  sstr << std::hex << tmp;
895  sstr >> aSFInt32;
896  return true;
897  }
898 
899  std::istringstream istr;
900  istr.str( tmp );
901  istr >> aSFInt32;
902 
903  if( istr.fail() || !istr.eof() )
904  {
905  std::ostringstream ostr;
906  ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
907  ostr << " * [INFO] failed on file '" << m_filename << "'\n";
908  ostr << " * [INFO] line " << fileline << ", char " << linepos << " -- ";
909  ostr << "line " << m_fileline << ", char " << m_bufpos << "\n";
910  ostr << " * [INFO] invalid character in SFInt";
911  m_error = ostr.str();
912 
913  return false;
914  }
915 
916  return true;
917 }
unsigned int m_bufpos
Definition: wrlproc.h:47
bool ReadGlob(std::string &aGlob)
Definition: wrlproc.cpp:236
LINE_READER * m_file
Definition: wrlproc.h:43
unsigned int m_fileline
Definition: wrlproc.h:46
std::string m_error
Definition: wrlproc.h:50
std::string m_buf
Definition: wrlproc.h:44
std::string m_filename
Definition: wrlproc.h:52
bool EatSpace(void)
Definition: wrlproc.cpp:182

References EatSpace(), m_buf, m_bufpos, m_error, m_file, m_fileline, m_filename, and ReadGlob().

Referenced by WRL1SWITCH::Read(), WRL2SWITCH::Read(), and ReadMFInt().

◆ ReadSFRotation()

bool WRLPROC::ReadSFRotation ( WRLROTATION aSFRotation)

Definition at line 920 of file wrlproc.cpp.

921 {
922  if( !m_file )
923  {
924  m_error = "no open file";
925  return false;
926  }
927 
928  aSFRotation.x = 0.0;
929  aSFRotation.y = 0.0;
930  aSFRotation.z = 1.0;
931  aSFRotation.w = 0.0;
932 
933  size_t fileline = m_fileline;
934  size_t linepos = m_bufpos;
935 
936  while( true )
937  {
938  if( !EatSpace() )
939  return false;
940 
941  // if the text is the start of a comment block, clear the buffer and loop
942  if( '#' == m_buf[m_bufpos] )
943  m_buf.clear();
944  else
945  break;
946  }
947 
948  std::string tmp;
949  float trot[4];
950 
951  for( int i = 0; i < 4; ++i )
952  {
953  if( !ReadGlob( tmp ) )
954  {
955  std::ostringstream ostr;
956  ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
957  ostr << " * [INFO] failed on file '" << m_filename << "'\n";
958  ostr << " * [INFO] line " << fileline << ", char " << linepos << " -- ";
959  ostr << "line " << m_fileline << ", char " << m_bufpos << "\n";
960  ostr << " * [INFO] " << m_error;
961  m_error = ostr.str();
962 
963  return false;
964  }
965 
966  std::istringstream istr;
967  istr.str( tmp );
968  istr >> trot[i];
969 
970  if( istr.fail() || !istr.eof() )
971  {
972  std::ostringstream ostr;
973  ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
974  ostr << " * [INFO] failed on file '" << m_filename << "'\n";
975  ostr << " * [INFO] line " << fileline << ", char " << linepos << " -- ";
976  ostr << "line " << m_fileline << ", char " << m_bufpos << "\n";
977  ostr << " * [INFO] invalid character in space delimited quartet";
978  m_error = ostr.str();
979 
980  return false;
981  }
982 
983  }
984 
985  aSFRotation.x = trot[0];
986  aSFRotation.y = trot[1];
987  aSFRotation.z = trot[2];
988  aSFRotation.w = trot[3];
989 
990  return true;
991 }
unsigned int m_bufpos
Definition: wrlproc.h:47
bool ReadGlob(std::string &aGlob)
Definition: wrlproc.cpp:236
LINE_READER * m_file
Definition: wrlproc.h:43
unsigned int m_fileline
Definition: wrlproc.h:46
std::string m_error
Definition: wrlproc.h:50
std::string m_buf
Definition: wrlproc.h:44
std::string m_filename
Definition: wrlproc.h:52
bool EatSpace(void)
Definition: wrlproc.cpp:182

References EatSpace(), m_buf, m_bufpos, m_error, m_file, m_fileline, m_filename, and ReadGlob().

Referenced by WRL1TRANSFORM::Read(), WRL2TRANSFORM::Read(), and ReadMFRotation().

◆ ReadSFVec2f()

bool WRLPROC::ReadSFVec2f ( WRLVEC2F aSFVec2f)

Definition at line 994 of file wrlproc.cpp.

995 {
996  if( !m_file )
997  {
998  m_error = "no open file";
999  return false;
1000  }
1001 
1002  aSFVec2f.x = 0.0;
1003  aSFVec2f.y = 0.0;
1004 
1005  size_t fileline = m_fileline;
1006  size_t linepos = m_bufpos;
1007 
1008  while( true )
1009  {
1010  if( !EatSpace() )
1011  return false;
1012 
1013  // if the text is the start of a comment block, clear the buffer and loop
1014  if( '#' == m_buf[m_bufpos] )
1015  m_buf.clear();
1016  else
1017  break;
1018  }
1019 
1020  std::string tmp;
1021 
1022  float tcol[2];
1023 
1024  for( int i = 0; i < 2; ++i )
1025  {
1026  if( !ReadGlob( tmp ) )
1027  {
1028  std::ostringstream ostr;
1029  ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
1030  ostr << " * [INFO] failed on file '" << m_filename << "'\n";
1031  ostr << " * [INFO] line " << fileline << ", char " << linepos << " -- ";
1032  ostr << "line " << m_fileline << ", char " << m_bufpos << "\n";
1033  ostr << " * [INFO] " << m_error;
1034  m_error = ostr.str();
1035 
1036  return false;
1037  }
1038 
1039  std::istringstream istr;
1040  istr.str( tmp );
1041  istr >> tcol[i];
1042 
1043  if( istr.fail() || !istr.eof() )
1044  {
1045  std::ostringstream ostr;
1046  ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
1047  ostr << " * [INFO] failed on file '" << m_filename << "'\n";
1048  ostr << " * [INFO] line " << fileline << ", char " << linepos << " -- ";
1049  ostr << "line " << m_fileline << ", char " << m_bufpos << "\n";
1050  ostr << " * [INFO] invalid character in space delimited pair";
1051  m_error = ostr.str();
1052 
1053  return false;
1054  }
1055 
1056  }
1057 
1058  aSFVec2f.x = tcol[0];
1059  aSFVec2f.y = tcol[1];
1060 
1061  return true;
1062 }
unsigned int m_bufpos
Definition: wrlproc.h:47
bool ReadGlob(std::string &aGlob)
Definition: wrlproc.cpp:236
LINE_READER * m_file
Definition: wrlproc.h:43
unsigned int m_fileline
Definition: wrlproc.h:46
std::string m_error
Definition: wrlproc.h:50
std::string m_buf
Definition: wrlproc.h:44
std::string m_filename
Definition: wrlproc.h:52
bool EatSpace(void)
Definition: wrlproc.cpp:182

References EatSpace(), m_buf, m_bufpos, m_error, m_file, m_fileline, m_filename, and ReadGlob().

Referenced by ReadMFVec2f().

◆ ReadSFVec3f()

bool WRLPROC::ReadSFVec3f ( WRLVEC3F aSFVec3f)

Definition at line 1065 of file wrlproc.cpp.

1066 {
1067  if( !m_file )
1068  {
1069  m_error = "no open file";
1070  return false;
1071  }
1072 
1073  aSFVec3f.x = 0.0;
1074  aSFVec3f.y = 0.0;
1075  aSFVec3f.z = 0.0;
1076 
1077  size_t fileline = m_fileline;
1078  size_t linepos = m_bufpos;
1079 
1080  while( true )
1081  {
1082  if( !EatSpace() )
1083  return false;
1084 
1085  // if the text is the start of a comment block, clear the buffer and loop
1086  if( '#' == m_buf[m_bufpos] )
1087  m_buf.clear();
1088  else
1089  break;
1090  }
1091 
1092  std::string tmp;
1093 
1094  float tcol[3];
1095 
1096  for( int i = 0; i < 3; ++i )
1097  {
1098  if( !ReadGlob( tmp ) )
1099  {
1100  std::ostringstream ostr;
1101  ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
1102  ostr << " * [INFO] failed on file '" << m_filename << "'\n";
1103  ostr << " * [INFO] line " << fileline << ", char " << linepos << " -- ";
1104  ostr << "line " << m_fileline << ", char " << m_bufpos << "\n";
1105  ostr << " * [INFO] " << m_error;
1106  m_error = ostr.str();
1107 
1108  return false;
1109  }
1110 
1111  // ignore any commas
1112  if( !EatSpace() )
1113  return false;
1114 
1115  if( ',' == m_buf[m_bufpos] )
1116  Pop();
1117 
1118  std::istringstream istr;
1119  istr.str( tmp );
1120  istr >> tcol[i];
1121 
1122  if( istr.fail() || !istr.eof() )
1123  {
1124  std::ostringstream ostr;
1125  ostr << __FILE__ << ":" << __FUNCTION__ << ":" << __LINE__ << "\n";
1126  ostr << " * [INFO] failed on file '" << m_filename << "'\n";
1127  ostr << " * [INFO] line " << fileline << ", char " << linepos << " -- ";
1128  ostr << "line " << m_fileline << ", char " << m_bufpos << "\n";
1129  ostr << " * [INFO] invalid character in space delimited triplet";
1130  m_error = ostr.str();
1131 
1132  return false;
1133  }
1134 
1135  }
1136 
1137  aSFVec3f.x = tcol[0];
1138  aSFVec3f.y = tcol[1];
1139  aSFVec3f.z = tcol[2];
1140 
1141  return true;
1142 }
void Pop(void)
Definition: wrlproc.cpp:2007
unsigned int m_bufpos
Definition: wrlproc.h:47
bool ReadGlob(std::string &aGlob)
Definition: wrlproc.cpp:236
LINE_READER * m_file
Definition: wrlproc.h:43
unsigned int m_fileline
Definition: wrlproc.h:46
std::string m_error
Definition: wrlproc.h:50
std::string m_buf
Definition: wrlproc.h:44
std::string m_filename
Definition: wrlproc.h:52
bool EatSpace(void)
Definition: wrlproc.cpp:182

References EatSpace(), m_buf, m_bufpos, m_error, m_file, m_fileline, m_filename, Pop(), and ReadGlob().

Referenced by WRL1TRANSFORM::Read(), WRL2BOX::Read(), WRL2INLINE::Read(), WRL2MATERIAL::Read(), WRL2TRANSFORM::Read(), ReadMFVec3f(), and ReadSFColor().

◆ ReadString()

bool WRLPROC::ReadString ( std::string &  aSFString)

Definition at line 603 of file wrlproc.cpp.

604 {
605  // In VRML1 a string may be unquoted provided there are no space characters
606  // In VRML2 all strings must be quoted
607  aSFString.clear();
608 
609  if( !m_file )
610  {
611  m_error = "no open file";
612  return false;
613  }
614 
615  // remember the line number in case of errors
616  size_t ifline = m_fileline;
617 
618  while( true )
619  {
620  if( !EatSpace() )
621  {
622  std::ostringstream ostr;
623  ostr << "invalid VRML file; expecting string at line " << ifline << " but found nothing";
624  m_error = ostr.str();
625 
626  return false;
627  }
628 
629  // if the text is the start of a comment block, clear the buffer and loop
630  if( '#' == m_buf[m_bufpos] )
631  m_buf.clear();
632  else
633  break;
634  }
635 
636  if( VRML_V2 == m_fileVersion && '"' != m_buf[m_bufpos] )
637  {
638  m_error = "invalid VRML2 file (string not quoted)";
639  return false;
640  }
641 
642  ifline = m_fileline;
643 
644  if( '"' != m_buf[m_bufpos] )
645  {
646  if( !ReadGlob( aSFString ) )
647  {
648  std::ostringstream ostr;
649  ostr << "invalid VRML1 file at lines " << ifline << "--" << m_fileline;
650 
651  if( !m_error.empty() )
652  ostr << " : " << m_error;
653 
654  m_error = ostr.str();
655 
656  return false;
657  }
658 
659  return true;
660  }
661 
662  bool isesc = false; // true if an escape character was found
663 
664  while( true )
665  {
666  ++m_bufpos;
667 
668  if( m_bufpos >= m_buf.size() )
669  {
670  aSFString.append( 1, '\n' );
671 
672  if( !getRawLine() )
673  {
674  std::ostringstream ostr;
675  ostr << "invalid VRML1 file at lines " << ifline << "--" << m_fileline;
676  ostr << "; could not find end of string\n";
677  m_error = ostr.str();
678 
679  return false;
680 
681  }
682  }
683 
684  if( '\\' == m_buf[m_bufpos] )
685  {
686  if( isesc )
687  {
688  aSFString.append( 1, '\n' );
689  isesc = false;
690  }
691  else
692  {
693  isesc = true;
694  }
695 
696  continue;
697  }
698  else if( '"' == m_buf[m_bufpos] )
699  {
700  if( isesc )
701  aSFString.append( 1, '"' );
702  else
703  break;
704  }
705  else
706  {
707  aSFString.append( 1, m_buf[m_bufpos] );
708  }
709 
710  // ensure that the backslash escape cannot extend beyond the first character
711  isesc = false;
712  }
713 
714  ++m_bufpos;
715 
716  return true;
717 }
unsigned int m_bufpos
Definition: wrlproc.h:47
bool ReadGlob(std::string &aGlob)
Definition: wrlproc.cpp:236
LINE_READER * m_file
Definition: wrlproc.h:43
unsigned int m_fileline
Definition: wrlproc.h:46
std::string m_error
Definition: wrlproc.h:50
std::string m_buf
Definition: wrlproc.h:44
bool EatSpace(void)
Definition: wrlproc.cpp:182
bool getRawLine(void)
Definition: wrlproc.cpp:133
WRLVERSION m_fileVersion
Definition: wrlproc.h:49

References EatSpace(), getRawLine(), m_buf, m_bufpos, m_error, m_file, m_fileline, m_fileVersion, ReadGlob(), and VRML_V2.

Referenced by DiscardList(), DiscardNode(), and ReadMFString().

Member Data Documentation

◆ m_badchars

std::string WRLPROC::m_badchars
private

Definition at line 51 of file wrlproc.h.

Referenced by ReadName(), and WRLPROC().

◆ m_buf

◆ m_bufpos

◆ m_eof

bool WRLPROC::m_eof
private

Definition at line 45 of file wrlproc.h.

Referenced by EatSpace(), eof(), getRawLine(), and WRLPROC().

◆ m_error

◆ m_file

◆ m_filedir

std::string WRLPROC::m_filedir
private

Definition at line 53 of file wrlproc.h.

Referenced by GetParentDir(), and WRLPROC().

◆ m_fileline

◆ m_filename

◆ m_fileVersion

WRLVERSION WRLPROC::m_fileVersion
private

Definition at line 49 of file wrlproc.h.

Referenced by getRawLine(), GetVRMLType(), ReadString(), and WRLPROC().


The documentation for this class was generated from the following files: