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 The 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, see <https://www.gnu.org/licenses/>.
19 */
20
25
26
27#ifndef WRLPROC_H
28#define WRLPROC_H
29
30#include <fstream>
31#include <string>
32#include <vector>
33
34#include "richio.h"
35#include "wrltypes.h"
36
38{
39public:
40 WRLPROC( LINE_READER* aLineReader );
41 ~WRLPROC();
42
43 bool eof( void );
44
45 // return the VRML Version
46 WRLVERSION GetVRMLType( void );
47
48 // return the parent directory of the current file
49 const char* GetParentDir( void );
50
51 // helper routines
52 std::string GetError( void );
53 bool GetFilePosData( size_t& line, size_t& column );
54 std::string GetFilePosition() const;
55 std::string GetFileName( void );
56
57 // eatSpace discards all leading white space from the current m_linepos
58 // and continues until a non-empty line is found which contains non-blank
59 // characters
60 bool EatSpace( void );
61
62 // Peek returns the next non-white char in the file or '\0' on failure
63 char Peek( void );
64
65 // Pop removes the current char from the buffer
66 void Pop( void );
67
68 // read up to the next whitespace or comma
69 bool ReadGlob( std::string& aGlob );
70
71 // read a VRML name; is similar to ReadGlob except that it enforces
72 // name checking rules, does not allow a comma at the end, and
73 // stops when a left/right brace or bracket is found.
74 bool ReadName( std::string& aName );
75 bool DiscardNode( void ); // discard node data in a matched '{}' set
76 bool DiscardList( void ); // discard list data in a matched '[]' set
77
78 // single variable readers
79 bool ReadString( std::string& aSFString ); // read a VRML string
80 bool ReadSFBool( bool& aSFBool );
81 bool ReadSFColor( WRLVEC3F& aSFColor );
82 bool ReadSFFloat( float& aSFFloat );
83 bool ReadSFInt( int& aSFInt32 );
84 bool ReadSFRotation( WRLROTATION& aSFRotation );
85 bool ReadSFVec2f( WRLVEC2F& aSFVec2f );
86 bool ReadSFVec3f( WRLVEC3F& aSFVec3f );
87
88 // array readers
89 bool ReadMFString( std::vector< std::string >& aMFString );
90 bool ReadMFColor( std::vector< WRLVEC3F >& aMFColor );
91 bool ReadMFFloat( std::vector< float >& aMFFloat );
92 bool ReadMFInt( std::vector< int >& aMFInt32 );
93 bool ReadMFRotation( std::vector< WRLROTATION >& aMFRotation );
94 bool ReadMFVec2f( std::vector< WRLVEC2F >& aMFVec2f );
95 bool ReadMFVec3f( std::vector< WRLVEC3F >& aMFVec3f );
96
97 // getRawLine reads a single non-blank line and in the case of a VRML1 file
98 // it checks for invalid characters (bit 8 set). If m_buf is not empty and
99 // not completely parsed the function returns 'true'. The file position
100 // parameters are updated as appropriate.
101 bool getRawLine( void );
102
103private:
105 std::string m_buf; // string being parsed
106 bool m_eof;
107 unsigned int m_fileline;
108 unsigned int m_bufpos;
109
110 WRLVERSION m_fileVersion; // VRML file version
111 std::string m_error; // error message
112 std::string m_badchars; // characters forbidden in VRML{1|2} names
113 std::string m_filename; // current file
114 std::string m_filedir; // parent directory of the file
115};
116
117#endif // WRLPROC_H
An abstract class from which implementation specific LINE_READERs may be derived to read single lines...
Definition richio.h:62
WRLVERSION m_fileVersion
Definition wrlproc.h:110
bool DiscardList(void)
Definition wrlproc.cpp:487
bool ReadGlob(std::string &aGlob)
Definition wrlproc.cpp:241
bool ReadSFInt(int &aSFInt32)
Definition wrlproc.cpp:863
bool ReadMFString(std::vector< std::string > &aMFString)
Definition wrlproc.cpp:1158
bool ReadString(std::string &aSFString)
Definition wrlproc.cpp:608
unsigned int m_fileline
Definition wrlproc.h:107
std::string m_error
Definition wrlproc.h:111
void Pop(void)
Definition wrlproc.cpp:2031
bool ReadSFFloat(float &aSFFloat)
Definition wrlproc.cpp:802
char Peek(void)
Definition wrlproc.cpp:2003
std::string GetFileName(void)
Definition wrlproc.cpp:1991
bool EatSpace(void)
Definition wrlproc.cpp:187
bool ReadSFColor(WRLVEC3F &aSFColor)
Definition wrlproc.cpp:770
bool ReadSFVec2f(WRLVEC2F &aSFVec2f)
Definition wrlproc.cpp:1007
WRLVERSION GetVRMLType(void)
Definition wrlproc.cpp:226
bool ReadMFInt(std::vector< int > &aMFInt32)
Definition wrlproc.cpp:1500
std::string m_filename
Definition wrlproc.h:113
const char * GetParentDir(void)
Definition wrlproc.cpp:232
bool ReadMFFloat(std::vector< float > &aMFFloat)
Definition wrlproc.cpp:1389
bool GetFilePosData(size_t &line, size_t &column)
Definition wrlproc.cpp:1962
bool getRawLine(void)
Definition wrlproc.cpp:138
std::string GetError(void)
Definition wrlproc.cpp:1956
bool ReadMFVec2f(std::vector< WRLVEC2F > &aMFVec2f)
Definition wrlproc.cpp:1724
std::string m_badchars
Definition wrlproc.h:112
bool ReadSFBool(bool &aSFBool)
Definition wrlproc.cpp:725
std::string m_filedir
Definition wrlproc.h:114
LINE_READER * m_file
Definition wrlproc.h:104
unsigned int m_bufpos
Definition wrlproc.h:108
bool eof(void)
Definition wrlproc.cpp:1950
bool ReadMFRotation(std::vector< WRLROTATION > &aMFRotation)
Definition wrlproc.cpp:1612
bool ReadMFVec3f(std::vector< WRLVEC3F > &aMFVec3f)
Definition wrlproc.cpp:1835
bool ReadName(std::string &aName)
Definition wrlproc.cpp:285
bool m_eof
Definition wrlproc.h:106
std::string GetFilePosition() const
Definition wrlproc.cpp:1978
bool DiscardNode(void)
Definition wrlproc.cpp:364
bool ReadMFColor(std::vector< WRLVEC3F > &aMFColor)
Definition wrlproc.cpp:1277
std::string m_buf
Definition wrlproc.h:105
bool ReadSFRotation(WRLROTATION &aSFRotation)
Definition wrlproc.cpp:933
WRLPROC(LINE_READER *aLineReader)
Definition wrlproc.cpp:57
bool ReadSFVec3f(WRLVEC3F &aSFVec3f)
Definition wrlproc.cpp:1078
declares some compound types used for VRML
WRLVERSION
Definition wrltypes.h:40
glm::vec4 WRLROTATION
Definition wrltypes.h:185
glm::vec2 WRLVEC2F
Definition wrltypes.h:183
glm::vec3 WRLVEC3F
Definition wrltypes.h:184