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 "wrltypes.h"
35
37
39{
40public:
41 WRLPROC( VRML_LINE_READER* aLineReader );
42 ~WRLPROC();
43
44 bool eof( void );
45
46 // return the VRML Version
47 WRLVERSION GetVRMLType( void );
48
49 // return the parent directory of the current file
50 const char* GetParentDir( void );
51
52 // helper routines
53 std::string GetError( void );
54 bool GetFilePosData( size_t& line, size_t& column );
55 std::string GetFilePosition() const;
56 std::string GetFileName( void );
57
58 // eatSpace discards all leading white space from the current m_linepos
59 // and continues until a non-empty line is found which contains non-blank
60 // characters
61 bool EatSpace( void );
62
63 // Peek returns the next non-white char in the file or '\0' on failure
64 char Peek( void );
65
66 // Pop removes the current char from the buffer
67 void Pop( void );
68
69 // read up to the next whitespace or comma
70 bool ReadGlob( std::string& aGlob );
71
72 // read a VRML name; is similar to ReadGlob except that it enforces
73 // name checking rules, does not allow a comma at the end, and
74 // stops when a left/right brace or bracket is found.
75 bool ReadName( std::string& aName );
76 bool DiscardNode( void ); // discard node data in a matched '{}' set
77 bool DiscardList( void ); // discard list data in a matched '[]' set
78
79 // single variable readers
80 bool ReadString( std::string& aSFString ); // read a VRML string
81 bool ReadSFBool( bool& aSFBool );
82 bool ReadSFColor( WRLVEC3F& aSFColor );
83 bool ReadSFFloat( float& aSFFloat );
84 bool ReadSFInt( int& aSFInt32 );
85 bool ReadSFRotation( WRLROTATION& aSFRotation );
86 bool ReadSFVec2f( WRLVEC2F& aSFVec2f );
87 bool ReadSFVec3f( WRLVEC3F& aSFVec3f );
88
89 // array readers
90 bool ReadMFString( std::vector< std::string >& aMFString );
91 bool ReadMFColor( std::vector< WRLVEC3F >& aMFColor );
92 bool ReadMFFloat( std::vector< float >& aMFFloat );
93 bool ReadMFInt( std::vector< int >& aMFInt32 );
94 bool ReadMFRotation( std::vector< WRLROTATION >& aMFRotation );
95 bool ReadMFVec2f( std::vector< WRLVEC2F >& aMFVec2f );
96 bool ReadMFVec3f( std::vector< WRLVEC3F >& aMFVec3f );
97
98 // getRawLine reads a single non-blank line and in the case of a VRML1 file
99 // it checks for invalid characters (bit 8 set). If m_buf is not empty and
100 // not completely parsed the function returns 'true'. The file position
101 // parameters are updated as appropriate.
102 bool getRawLine( void );
103
104private:
106 std::string m_buf; // string being parsed
107 bool m_eof;
108 unsigned int m_fileline;
109 unsigned int m_bufpos;
110
111 WRLVERSION m_fileVersion; // VRML file version
112 std::string m_error; // error message
113 std::string m_badchars; // characters forbidden in VRML{1|2} names
114 std::string m_filename; // current file
115 std::string m_filedir; // parent directory of the file
116};
117
118#endif // WRLPROC_H
WRLVERSION m_fileVersion
Definition wrlproc.h:111
bool DiscardList(void)
Definition wrlproc.cpp:493
bool ReadGlob(std::string &aGlob)
Definition wrlproc.cpp:247
bool ReadSFInt(int &aSFInt32)
Definition wrlproc.cpp:869
bool ReadMFString(std::vector< std::string > &aMFString)
Definition wrlproc.cpp:1164
bool ReadString(std::string &aSFString)
Definition wrlproc.cpp:614
unsigned int m_fileline
Definition wrlproc.h:108
std::string m_error
Definition wrlproc.h:112
void Pop(void)
Definition wrlproc.cpp:2037
bool ReadSFFloat(float &aSFFloat)
Definition wrlproc.cpp:808
char Peek(void)
Definition wrlproc.cpp:2009
std::string GetFileName(void)
Definition wrlproc.cpp:1997
bool EatSpace(void)
Definition wrlproc.cpp:193
WRLPROC(VRML_LINE_READER *aLineReader)
Definition wrlproc.cpp:63
bool ReadSFColor(WRLVEC3F &aSFColor)
Definition wrlproc.cpp:776
bool ReadSFVec2f(WRLVEC2F &aSFVec2f)
Definition wrlproc.cpp:1013
WRLVERSION GetVRMLType(void)
Definition wrlproc.cpp:232
bool ReadMFInt(std::vector< int > &aMFInt32)
Definition wrlproc.cpp:1506
VRML_LINE_READER * m_file
Definition wrlproc.h:105
std::string m_filename
Definition wrlproc.h:114
const char * GetParentDir(void)
Definition wrlproc.cpp:238
bool ReadMFFloat(std::vector< float > &aMFFloat)
Definition wrlproc.cpp:1395
bool GetFilePosData(size_t &line, size_t &column)
Definition wrlproc.cpp:1968
bool getRawLine(void)
Definition wrlproc.cpp:144
std::string GetError(void)
Definition wrlproc.cpp:1962
bool ReadMFVec2f(std::vector< WRLVEC2F > &aMFVec2f)
Definition wrlproc.cpp:1730
std::string m_badchars
Definition wrlproc.h:113
bool ReadSFBool(bool &aSFBool)
Definition wrlproc.cpp:731
std::string m_filedir
Definition wrlproc.h:115
unsigned int m_bufpos
Definition wrlproc.h:109
bool eof(void)
Definition wrlproc.cpp:1956
bool ReadMFRotation(std::vector< WRLROTATION > &aMFRotation)
Definition wrlproc.cpp:1618
bool ReadMFVec3f(std::vector< WRLVEC3F > &aMFVec3f)
Definition wrlproc.cpp:1841
bool ReadName(std::string &aName)
Definition wrlproc.cpp:291
bool m_eof
Definition wrlproc.h:107
std::string GetFilePosition() const
Definition wrlproc.cpp:1984
bool DiscardNode(void)
Definition wrlproc.cpp:370
bool ReadMFColor(std::vector< WRLVEC3F > &aMFColor)
Definition wrlproc.cpp:1283
std::string m_buf
Definition wrlproc.h:106
bool ReadSFRotation(WRLROTATION &aSFRotation)
Definition wrlproc.cpp:939
bool ReadSFVec3f(WRLVEC3F &aSFVec3f)
Definition wrlproc.cpp:1084
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