KiCad PCB EDA Suite
filename_resolver.cpp File Reference
#include <sstream>
#include <fstream>
#include <wx/filename.h>
#include <wx/log.h>
#include <wx/msgdlg.h>
#include <pgm_base.h>
#include <trace_helpers.h>
#include "common.h"
#include "filename_resolver.h"

Go to the source code of this file.

Macros

#define CFGFILE_VERSION   1
 
#define RESOLVER_CONFIG   wxT( "3Dresolver.cfg" )
 
#define ERRFLG_ALIAS   (1)
 
#define ERRFLG_RELPATH   (2)
 
#define ERRFLG_ENVPATH   (4)
 
#define MASK_3D_RESOLVER   "3D_RESOLVER"
 

Functions

static bool getHollerith (const std::string &aString, size_t &aIndex, wxString &aResult)
 

Variables

static wxCriticalSection lock_resolver
 

Macro Definition Documentation

#define CFGFILE_VERSION   1
#define ERRFLG_ALIAS   (1)

Definition at line 41 of file filename_resolver.cpp.

Referenced by FILENAME_RESOLVER::ResolvePath().

#define ERRFLG_ENVPATH   (4)

Definition at line 43 of file filename_resolver.cpp.

Referenced by FILENAME_RESOLVER::ResolvePath().

#define ERRFLG_RELPATH   (2)

Definition at line 42 of file filename_resolver.cpp.

Referenced by FILENAME_RESOLVER::ResolvePath().

#define RESOLVER_CONFIG   wxT( "3Dresolver.cfg" )

Function Documentation

static bool getHollerith ( const std::string &  aString,
size_t &  aIndex,
wxString &  aResult 
)
static

Definition at line 877 of file filename_resolver.cpp.

References MASK_3D_RESOLVER.

Referenced by FILENAME_RESOLVER::readPathList().

878 {
879  aResult.clear();
880 
881  if( aIndex >= aString.size() )
882  {
883  std::ostringstream ostr;
884  ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
885  wxString errmsg = "bad Hollerith string on line";
886  ostr << " * " << errmsg.ToUTF8() << "\n'" << aString << "'";
887  wxLogTrace( MASK_3D_RESOLVER, "%s\n", ostr.str().c_str() );
888 
889  return false;
890  }
891 
892  size_t i2 = aString.find( '"', aIndex );
893 
894  if( std::string::npos == i2 )
895  {
896  std::ostringstream ostr;
897  ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
898  wxString errmsg = "missing opening quote mark in config file";
899  ostr << " * " << errmsg.ToUTF8() << "\n'" << aString << "'";
900  wxLogTrace( MASK_3D_RESOLVER, "%s\n", ostr.str().c_str() );
901 
902  return false;
903  }
904 
905  ++i2;
906 
907  if( i2 >= aString.size() )
908  {
909  std::ostringstream ostr;
910  ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
911  wxString errmsg = "invalid entry (unexpected end of line)";
912  ostr << " * " << errmsg.ToUTF8() << "\n'" << aString << "'";
913  wxLogTrace( MASK_3D_RESOLVER, "%s\n", ostr.str().c_str() );
914 
915  return false;
916  }
917 
918  std::string tnum;
919 
920  while( aString[i2] >= '0' && aString[i2] <= '9' )
921  tnum.append( 1, aString[i2++] );
922 
923  if( tnum.empty() || aString[i2++] != ':' )
924  {
925  std::ostringstream ostr;
926  ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
927  wxString errmsg = "bad Hollerith string on line";
928  ostr << " * " << errmsg.ToUTF8() << "\n'" << aString << "'";
929  wxLogTrace( MASK_3D_RESOLVER, "%s\n", ostr.str().c_str() );
930 
931  return false;
932  }
933 
934  std::istringstream istr;
935  istr.str( tnum );
936  size_t nchars;
937  istr >> nchars;
938 
939  if( (i2 + nchars) >= aString.size() )
940  {
941  std::ostringstream ostr;
942  ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
943  wxString errmsg = "invalid entry (unexpected end of line)";
944  ostr << " * " << errmsg.ToUTF8() << "\n'" << aString << "'";
945  wxLogTrace( MASK_3D_RESOLVER, "%s\n", ostr.str().c_str() );
946 
947  return false;
948  }
949 
950  if( nchars > 0 )
951  {
952  aResult = aString.substr( i2, nchars );
953  i2 += nchars;
954  }
955 
956  if( aString[i2] != '"' )
957  {
958  std::ostringstream ostr;
959  ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
960  wxString errmsg = "missing closing quote mark in config file";
961  ostr << " * " << errmsg.ToUTF8() << "\n'" << aString << "'";
962  wxLogTrace( MASK_3D_RESOLVER, "%s\n", ostr.str().c_str() );
963 
964  return false;
965  }
966 
967  aIndex = i2 + 1;
968  return true;
969 }
#define MASK_3D_RESOLVER

Variable Documentation

wxCriticalSection lock_resolver
static