KiCad PCB EDA Suite
3d_filename_resolver.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 <cirilo.bernardo@gmail.com>
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, you may find one here:
18  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19  * or you may search the http://www.gnu.org website for the version 2 license,
20  * or you may write to the Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22  */
23 
33 #ifndef FILENAME_RESOLVER_3D_H
34 #define FILENAME_RESOLVER_3D_H
35 
36 #include <list>
37 #include <map>
38 #include <vector>
39 #include <wx/string.h>
40 #include "str_rsort.h"
41 
42 class PGM_BASE;
43 
44 struct S3D_ALIAS
45 {
46  wxString m_alias; // alias to the base path
47  wxString m_pathvar; // base path as stored in the config file
48  wxString m_pathexp; // expanded base path
49  wxString m_description; // description of the aliased path
50 };
51 
53 {
54 private:
55  wxString m_ConfigDir; // 3D configuration directory
56  std::list< S3D_ALIAS > m_Paths; // list of base paths to search from
59  wxString m_curProjDir;
60 
70  bool createPathList( void );
71 
79  bool addPath( const S3D_ALIAS& aPath );
80 
88  bool readPathList( void );
89 
97  bool writePathList( void );
98 
105  void checkEnvVarPath( const wxString& aPath );
106 
107 public:
109 
118  bool Set3DConfigDir( const wxString& aConfigDir );
119 
130  bool SetProjectDir( const wxString& aProjDir, bool* flgChanged = NULL );
131  wxString GetProjectDir( void );
132 
138  void SetProgramBase( PGM_BASE* aBase );
139 
140 
146  bool UpdatePathList( std::vector< S3D_ALIAS >& aPathList );
147 
156  wxString ResolvePath( const wxString& aFileName );
157 
167  wxString ShortenPath( const wxString& aFullPathName );
168 
178  const std::list< S3D_ALIAS >* GetPaths( void );
179 
186  bool SplitAlias( const wxString& aFileName, wxString& anAlias, wxString& aRelPath );
187 
193  bool ValidateFileName( const wxString& aFileName, bool& hasAlias );
194 
201  bool GetKicadPaths( std::list< wxString >& paths );
202 };
203 
204 #endif // FILENAME_RESOLVER_3D_H
wxString m_pathvar
Class PGM_BASE keeps program (whole process) data for KiCad programs.
Definition: pgm_base.h:107
provides a wxString sorting functino which works from the end of the string towards the beginning ...
std::list< S3D_ALIAS > m_Paths
wxString m_pathexp
wxString m_description