KiCad PCB EDA Suite
Loading...
Searching...
No Matches
wrlproc.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2015-2016 Cirilo Bernardo <[email protected]>
5 * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
31#ifndef WRLPROC_H
32#define WRLPROC_H
33
34#include <fstream>
35#include <string>
36#include <vector>
37
38#include "richio.h"
39#include "wrltypes.h"
40
42{
43public:
44 WRLPROC( LINE_READER* aLineReader );
45 ~WRLPROC();
46
47 bool eof( void );
48
49 // return the VRML Version
50 WRLVERSION GetVRMLType( void );
51
52 // return the parent directory of the current file
53 const char* GetParentDir( void );
54
55 // helper routines
56 std::string GetError( void );
57 bool GetFilePosData( size_t& line, size_t& column );
58 std::string GetFilePosition() const;
59 std::string GetFileName( void );
60
61 // eatSpace discards all leading white space from the current m_linepos
62 // and continues until a non-empty line is found which contains non-blank
63 // characters
64 bool EatSpace( void );
65
66 // Peek returns the next non-white char in the file or '\0' on failure
67 char Peek( void );
68
69 // Pop removes the current char from the buffer
70 void Pop( void );
71
72 // read up to the next whitespace or comma
73 bool ReadGlob( std::string& aGlob );
74
75 // read a VRML name; is similar to ReadGlob except that it enforces
76 // name checking rules, does not allow a comma at the end, and
77 // stops when a left/right brace or bracket is found.
78 bool ReadName( std::string& aName );
79 bool DiscardNode( void ); // discard node data in a matched '{}' set
80 bool DiscardList( void ); // discard list data in a matched '[]' set
81
82 // single variable readers
83 bool ReadString( std::string& aSFString ); // read a VRML string
84 bool ReadSFBool( bool& aSFBool );
85 bool ReadSFColor( WRLVEC3F& aSFColor );
86 bool ReadSFFloat( float& aSFFloat );
87 bool ReadSFInt( int& aSFInt32 );
88 bool ReadSFRotation( WRLROTATION& aSFRotation );
89 bool ReadSFVec2f( WRLVEC2F& aSFVec2f );
90 bool ReadSFVec3f( WRLVEC3F& aSFVec3f );
91
92 // array readers
93 bool ReadMFString( std::vector< std::string >& aMFString );
94 bool ReadMFColor( std::vector< WRLVEC3F >& aMFColor );
95 bool ReadMFFloat( std::vector< float >& aMFFloat );
96 bool ReadMFInt( std::vector< int >& aMFInt32 );
97 bool ReadMFRotation( std::vector< WRLROTATION >& aMFRotation );
98 bool ReadMFVec2f( std::vector< WRLVEC2F >& aMFVec2f );
99 bool ReadMFVec3f( std::vector< WRLVEC3F >& aMFVec3f );
100
101 // getRawLine reads a single non-blank line and in the case of a VRML1 file
102 // it checks for invalid characters (bit 8 set). If m_buf is not empty and
103 // not completely parsed the function returns 'true'. The file position
104 // parameters are updated as appropriate.
105 bool getRawLine( void );
106
107private:
109 std::string m_buf; // string being parsed
110 bool m_eof;
111 unsigned int m_fileline;
112 unsigned int m_bufpos;
113
114 WRLVERSION m_fileVersion; // VRML file version
115 std::string m_error; // error message
116 std::string m_badchars; // characters forbidden in VRML{1|2} names
117 std::string m_filename; // current file
118 std::string m_filedir; // parent directory of the file
119};
120
121#endif // WRLPROC_H
An abstract class from which implementation specific LINE_READERs may be derived to read single lines...
Definition: richio.h:93
WRLVERSION m_fileVersion
Definition: wrlproc.h:114
bool DiscardList(void)
Definition: wrlproc.cpp:491
bool ReadGlob(std::string &aGlob)
Definition: wrlproc.cpp:245
bool ReadSFInt(int &aSFInt32)
Definition: wrlproc.cpp:867
bool ReadMFString(std::vector< std::string > &aMFString)
Definition: wrlproc.cpp:1162
bool ReadString(std::string &aSFString)
Definition: wrlproc.cpp:612
unsigned int m_fileline
Definition: wrlproc.h:111
std::string m_error
Definition: wrlproc.h:115
void Pop(void)
Definition: wrlproc.cpp:2035
bool ReadSFFloat(float &aSFFloat)
Definition: wrlproc.cpp:806
char Peek(void)
Definition: wrlproc.cpp:2007
std::string GetFileName(void)
Definition: wrlproc.cpp:1995
bool EatSpace(void)
Definition: wrlproc.cpp:191
bool ReadSFColor(WRLVEC3F &aSFColor)
Definition: wrlproc.cpp:774
bool ReadSFVec2f(WRLVEC2F &aSFVec2f)
Definition: wrlproc.cpp:1011
WRLVERSION GetVRMLType(void)
Definition: wrlproc.cpp:230
bool ReadMFInt(std::vector< int > &aMFInt32)
Definition: wrlproc.cpp:1504
std::string m_filename
Definition: wrlproc.h:117
const char * GetParentDir(void)
Definition: wrlproc.cpp:236
bool ReadMFFloat(std::vector< float > &aMFFloat)
Definition: wrlproc.cpp:1393
bool GetFilePosData(size_t &line, size_t &column)
Definition: wrlproc.cpp:1966
bool getRawLine(void)
Definition: wrlproc.cpp:142
std::string GetError(void)
Definition: wrlproc.cpp:1960
bool ReadMFVec2f(std::vector< WRLVEC2F > &aMFVec2f)
Definition: wrlproc.cpp:1728
std::string m_badchars
Definition: wrlproc.h:116
bool ReadSFBool(bool &aSFBool)
Definition: wrlproc.cpp:729
std::string m_filedir
Definition: wrlproc.h:118
LINE_READER * m_file
Definition: wrlproc.h:108
unsigned int m_bufpos
Definition: wrlproc.h:112
bool eof(void)
Definition: wrlproc.cpp:1954
bool ReadMFRotation(std::vector< WRLROTATION > &aMFRotation)
Definition: wrlproc.cpp:1616
bool ReadMFVec3f(std::vector< WRLVEC3F > &aMFVec3f)
Definition: wrlproc.cpp:1839
bool ReadName(std::string &aName)
Definition: wrlproc.cpp:289
bool m_eof
Definition: wrlproc.h:110
std::string GetFilePosition() const
Definition: wrlproc.cpp:1982
bool DiscardNode(void)
Definition: wrlproc.cpp:368
bool ReadMFColor(std::vector< WRLVEC3F > &aMFColor)
Definition: wrlproc.cpp:1281
~WRLPROC()
Definition: wrlproc.cpp:137
std::string m_buf
Definition: wrlproc.h:109
bool ReadSFRotation(WRLROTATION &aSFRotation)
Definition: wrlproc.cpp:937
bool ReadSFVec3f(WRLVEC3F &aSFVec3f)
Definition: wrlproc.cpp:1082
declares some compound types used for VRML
WRLVERSION
Definition: wrltypes.h:44
glm::vec4 WRLROTATION
Definition: wrltypes.h:189
glm::vec2 WRLVEC2F
Definition: wrltypes.h:187
glm::vec3 WRLVEC3F
Definition: wrltypes.h:188