Header clean up round 4.
This commit is contained in:
parent
6e4b1fe8d4
commit
96c935673e
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2014 CERN
|
||||
* Copyright (C) 2004-2013 KiCad Developers, see change_log.txt for contributors.
|
||||
* Copyright (C) 2004-2020 KiCad Developers, see change_log.txt for contributors.
|
||||
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
|
@ -31,10 +31,9 @@
|
|||
#include <type_traits>
|
||||
|
||||
/**
|
||||
* Function IsA()
|
||||
*
|
||||
* Checks if the type of aObject is T.
|
||||
* @param aObject object for type check
|
||||
*
|
||||
* @param aObject the object for type check.
|
||||
* @return true, if aObject type equals T.
|
||||
*/
|
||||
template <class T, class I>
|
||||
|
@ -50,11 +49,12 @@ bool IsA( const I& aObject )
|
|||
}
|
||||
|
||||
/**
|
||||
* Function dyn_cast()
|
||||
* A lightweight dynamic downcast.
|
||||
*
|
||||
* A lightweight dynamic downcast. Casts aObject to type Casted*.
|
||||
* Uses EDA_ITEM::Type() and EDA_ITEM::ClassOf() to check if type matches.
|
||||
* @param aObject object to be casted
|
||||
* Cast \a aObject to type Casted*. Uses #EDA_ITEM::Type() and #EDA_ITEM::ClassOf() to
|
||||
* check if type matches.
|
||||
*
|
||||
* @param aObject object to be casted.
|
||||
* @return down-casted object or NULL if type doesn't match Casted.
|
||||
*/
|
||||
template<class Casted, class From>
|
||||
|
@ -72,8 +72,7 @@ class EDA_ITEM;
|
|||
|
||||
|
||||
/**
|
||||
* Enum KICAD_T
|
||||
* is the set of class identification values, stored in EDA_ITEM::m_structType
|
||||
* The set of class identification values stored in #EDA_ITEM::m_structType
|
||||
*/
|
||||
enum KICAD_T
|
||||
{
|
||||
|
@ -225,10 +224,13 @@ enum KICAD_T
|
|||
};
|
||||
|
||||
/**
|
||||
* Returns the underlying type of the given type. This is useful for finding the
|
||||
* element type given one of the "non-type" types such as SCH_LINE_LOCATE_WIRE_T
|
||||
* @param aType Given type to resolve
|
||||
* @return Base type
|
||||
* Returns the underlying type of the given type.
|
||||
*
|
||||
* This is useful for finding the element type given one of the "non-type" types such as
|
||||
* SCH_LINE_LOCATE_WIRE_T.
|
||||
*
|
||||
* @param aType Given type to resolve.
|
||||
* @return Base type.
|
||||
*/
|
||||
constexpr KICAD_T BaseType( const KICAD_T aType )
|
||||
{
|
||||
|
|
|
@ -147,8 +147,8 @@ public:
|
|||
*/
|
||||
|
||||
/**
|
||||
* Function OnPgmInit
|
||||
* this is the first executed function (like main() )
|
||||
* This is the first executed function (like main() ).
|
||||
*
|
||||
* @return true if the application can be started.
|
||||
*/
|
||||
virtual bool OnPgmInit() = 0; // call this from wxApp::OnInit()
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Copyright (C) 2018 CERN
|
||||
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Author: Maciej Suminski <maciej.suminski@cern.ch>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
|
@ -25,8 +26,7 @@ class APP_SETTINGS_BASE;
|
|||
class COLOR_SETTINGS;
|
||||
|
||||
/**
|
||||
* PRINT_PARAMETERS
|
||||
* handles the parameters used to print a board drawing.
|
||||
* Handle the parameters used to print a board drawing.
|
||||
*/
|
||||
struct PRINTOUT_SETTINGS
|
||||
{
|
||||
|
@ -46,8 +46,15 @@ struct PRINTOUT_SETTINGS
|
|||
}
|
||||
|
||||
virtual void Save( APP_SETTINGS_BASE* aConfig );
|
||||
|
||||
virtual void Load( APP_SETTINGS_BASE* aConfig );
|
||||
|
||||
/**
|
||||
* Returns true if the drawing border and title block should be printed.
|
||||
*/
|
||||
bool PrintBorderAndTitleBlock() const { return m_titleBlock; }
|
||||
|
||||
|
||||
double m_scale; ///< Printing scale
|
||||
bool m_titleBlock; ///< Print frame and title block
|
||||
bool m_blackWhite; ///< Print in B&W or Color
|
||||
|
@ -57,11 +64,6 @@ struct PRINTOUT_SETTINGS
|
|||
|
||||
/// The color settings to be used for printing
|
||||
COLOR_SETTINGS* m_colorSettings;
|
||||
|
||||
/**
|
||||
* Returns true if the drawing border and title block should be printed.
|
||||
*/
|
||||
bool PrintBorderAndTitleBlock() const { return m_titleBlock; }
|
||||
};
|
||||
|
||||
#endif /* PRINTOUT_H */
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2013 CERN
|
||||
* Copyright (C) 2019-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
|
||||
* 2019 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -37,7 +37,8 @@
|
|||
#include <iomanip>
|
||||
|
||||
/**
|
||||
* The class PROF_COUNTER is a small class to help profiling.
|
||||
* A small class to help profiling.
|
||||
*
|
||||
* It allows the calculation of the elapsed time (in milliseconds) between
|
||||
* its creation (or the last call to Start() ) and the last call to Stop()
|
||||
*/
|
||||
|
@ -45,9 +46,10 @@ class PROF_COUNTER
|
|||
{
|
||||
public:
|
||||
/**
|
||||
* Creates a PROF_COUNTER for measuring an elapsed time in milliseconds
|
||||
* @param aName = a string that will be printed in message.
|
||||
* @param aAutostart = true (default) to immediately start the timer
|
||||
* Create a PROF_COUNTER for measuring an elapsed time in milliseconds.
|
||||
*
|
||||
* @param aName a string that will be printed in message.
|
||||
* @param aAutostart true (default) to immediately start the timer
|
||||
*/
|
||||
PROF_COUNTER( const std::string& aName, bool aAutostart = true ) :
|
||||
m_name( aName ), m_running( false )
|
||||
|
@ -57,7 +59,8 @@ public:
|
|||
}
|
||||
|
||||
/**
|
||||
* Creates a PROF_COUNTER for measuring an elapsed time in milliseconds
|
||||
* Create a PROF_COUNTER for measuring an elapsed time in milliseconds
|
||||
*
|
||||
* The counter is started and the string to print in message is left empty.
|
||||
*/
|
||||
PROF_COUNTER()
|
||||
|
@ -66,7 +69,7 @@ public:
|
|||
}
|
||||
|
||||
/**
|
||||
* Starts or restarts the counter
|
||||
* Start or restart the counter.
|
||||
*/
|
||||
void Start()
|
||||
{
|
||||
|
@ -77,7 +80,7 @@ public:
|
|||
|
||||
|
||||
/**
|
||||
* save the time when this function was called, and set the counter stane to stop
|
||||
* Save the time when this function was called, and set the counter stane to stop.
|
||||
*/
|
||||
void Stop()
|
||||
{
|
||||
|
@ -121,9 +124,9 @@ public:
|
|||
}
|
||||
|
||||
/**
|
||||
* @return the time since the timer was started. If the timer is stopped,
|
||||
* the duration is from the start time to the time it was stopped, else it
|
||||
* is to the current time.
|
||||
* @return the time since the timer was started. If the timer is stopped, the duration
|
||||
* is from the start time to the time it was stopped, else it is to the current
|
||||
* time.
|
||||
*/
|
||||
template <typename DURATION>
|
||||
DURATION SinceStart( bool aSinceLast = false )
|
||||
|
@ -137,7 +140,7 @@ public:
|
|||
}
|
||||
|
||||
/**
|
||||
* @param aSinceLast: only get the time since the last time the time was read
|
||||
* @param aSinceLast only get the time since the last time the time was read.
|
||||
* @return the elapsed time in ms since the timer was started.
|
||||
*/
|
||||
double msecs( bool aSinceLast = false )
|
||||
|
@ -199,10 +202,10 @@ private:
|
|||
|
||||
|
||||
/**
|
||||
* Function GetRunningMicroSecs
|
||||
* An alternate way to calculate an elapset time (in microsecondes) to class PROF_COUNTER
|
||||
* @return an ever increasing indication of elapsed microseconds.
|
||||
* Use this by computing differences between two calls.
|
||||
*
|
||||
* @return an ever increasing indication of elapsed microseconds. Use this by computing
|
||||
* differences between two calls.
|
||||
* @author Dick Hollenbeck
|
||||
*/
|
||||
unsigned GetRunningMicroSecs();
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* This program source code file is part of KICAD, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2016 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
||||
* Copyright (C) 2016 Kicad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2016-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -27,14 +27,11 @@
|
|||
|
||||
|
||||
/**
|
||||
* PROPERTIES
|
||||
* is a name/value tuple with unique names and optional values. The names
|
||||
* A name/value tuple with unique names and optional values. The names
|
||||
* may be iterated alphabetically.
|
||||
*/
|
||||
class PROPERTIES : public std::map< std::string, UTF8 >
|
||||
{
|
||||
// alphabetical tuple of name and value hereby defined.
|
||||
|
||||
public:
|
||||
bool Clear( const std::string& aProperty )
|
||||
{
|
||||
|
@ -47,15 +44,17 @@ public:
|
|||
}
|
||||
|
||||
/**
|
||||
* Function Value
|
||||
* fetches a property by aName and returns true if that property was found, else false.
|
||||
* If not found, aFetchedValue is not touched.
|
||||
* Fetch a property by \a aName and returns true if that property was found, else false.
|
||||
* If not found, \a aFetchedValue is not touched.
|
||||
*
|
||||
* @param aName is the property or option to look for.
|
||||
* @param aFetchedValue is where to put the value of the property if it
|
||||
* exists and aFetchedValue is not NULL.
|
||||
* @return bool - true if property is found, else false.
|
||||
* @param aFetchedValue is where to put the value of the property if it exists and
|
||||
* \a aFetchedValue is not NULL.
|
||||
* @return true if property is found, else false.
|
||||
*/
|
||||
bool Value( const char* aName, UTF8* aFetchedValue = NULL ) const;
|
||||
bool Value( const char* aName, UTF8* aFetchedValue = nullptr ) const;
|
||||
};
|
||||
|
||||
#endif // _PROPERTIES_H_
|
||||
|
||||
// LocalWords: aName aFetchedValue
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2020 CERN
|
||||
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
|
||||
* @author Maciej Suminski <maciej.suminski@cern.ch>
|
||||
*
|
||||
|
@ -167,10 +168,6 @@ public:
|
|||
|
||||
class PROPERTY_BASE
|
||||
{
|
||||
private:
|
||||
///> Used to generate unique IDs
|
||||
size_t nextId = 0;
|
||||
|
||||
public:
|
||||
PROPERTY_BASE( const wxString& aName, PROPERTY_DISPLAY aDisplay = DEFAULT ) :
|
||||
m_id( nextId ),
|
||||
|
@ -293,6 +290,9 @@ private:
|
|||
///> Condition that determines whether the property is available
|
||||
std::function<bool(INSPECTABLE*)> m_availFunc;
|
||||
|
||||
///> Used to generate unique IDs
|
||||
size_t nextId = 0;
|
||||
|
||||
friend class INSPECTABLE;
|
||||
};
|
||||
|
||||
|
@ -572,45 +572,44 @@ private:
|
|||
|
||||
|
||||
// Helper macros to handle enum types
|
||||
#define DECLARE_ENUM_TO_WXANY(type)\
|
||||
template<>\
|
||||
class wxAnyValueTypeImpl<type> : public wxAnyValueTypeImplBase<type>\
|
||||
{\
|
||||
WX_DECLARE_ANY_VALUE_TYPE(wxAnyValueTypeImpl<type>)\
|
||||
public:\
|
||||
wxAnyValueTypeImpl() : wxAnyValueTypeImplBase<type>() {}\
|
||||
virtual ~wxAnyValueTypeImpl() {}\
|
||||
virtual bool ConvertValue( const wxAnyValueBuffer& src,\
|
||||
wxAnyValueType* dstType, wxAnyValueBuffer& dst ) const override\
|
||||
{\
|
||||
type value = GetValue(src);\
|
||||
ENUM_MAP<type>& conv = ENUM_MAP<type>::Instance();\
|
||||
if( dstType->CheckType<wxString>() )\
|
||||
{\
|
||||
wxAnyValueTypeImpl<wxString>::SetValue( conv.ToString( value ), dst );\
|
||||
return true;\
|
||||
}\
|
||||
if( dstType->CheckType<int>() )\
|
||||
{\
|
||||
wxAnyValueTypeImpl<int>::SetValue( static_cast<int>(value), dst );\
|
||||
return true;\
|
||||
}\
|
||||
else\
|
||||
{\
|
||||
return false;\
|
||||
}\
|
||||
}\
|
||||
#define DECLARE_ENUM_TO_WXANY( type ) \
|
||||
template <> \
|
||||
class wxAnyValueTypeImpl<type> : public wxAnyValueTypeImplBase<type> \
|
||||
{ \
|
||||
WX_DECLARE_ANY_VALUE_TYPE( wxAnyValueTypeImpl<type> ) \
|
||||
public: \
|
||||
wxAnyValueTypeImpl() : wxAnyValueTypeImplBase<type>() {} \
|
||||
virtual ~wxAnyValueTypeImpl() {} \
|
||||
virtual bool ConvertValue( const wxAnyValueBuffer& src, wxAnyValueType* dstType, \
|
||||
wxAnyValueBuffer& dst ) const override \
|
||||
{ \
|
||||
type value = GetValue( src ); \
|
||||
ENUM_MAP<type>& conv = ENUM_MAP<type>::Instance(); \
|
||||
if( dstType->CheckType<wxString>() ) \
|
||||
{ \
|
||||
wxAnyValueTypeImpl<wxString>::SetValue( conv.ToString( value ), dst ); \
|
||||
return true; \
|
||||
} \
|
||||
if( dstType->CheckType<int>() ) \
|
||||
{ \
|
||||
wxAnyValueTypeImpl<int>::SetValue( static_cast<int>( value ), dst ); \
|
||||
return true; \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
return false; \
|
||||
} \
|
||||
} \
|
||||
};
|
||||
|
||||
#define IMPLEMENT_ENUM_TO_WXANY(type)\
|
||||
WX_IMPLEMENT_ANY_VALUE_TYPE(wxAnyValueTypeImpl<type>)
|
||||
#define IMPLEMENT_ENUM_TO_WXANY( type ) WX_IMPLEMENT_ANY_VALUE_TYPE( wxAnyValueTypeImpl<type> )
|
||||
|
||||
#define ENUM_TO_WXANY(type)\
|
||||
DECLARE_ENUM_TO_WXANY(type)\
|
||||
IMPLEMENT_ENUM_TO_WXANY(type)
|
||||
#define ENUM_TO_WXANY( type ) \
|
||||
DECLARE_ENUM_TO_WXANY( type ) \
|
||||
IMPLEMENT_ENUM_TO_WXANY( type )
|
||||
|
||||
///> Macro to define read-only fields (no setter method available)
|
||||
#define NO_SETTER(owner, type) ((void (owner::*)(type))nullptr)
|
||||
#define NO_SETTER( owner, type ) ( ( void ( owner::* )( type ) ) nullptr )
|
||||
|
||||
/*
|
||||
#define DECLARE_PROPERTY(owner,type,name,getter,setter) \
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2013 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
||||
* Copyright (C) 2013 KiCad Developers, see CHANGELOG.TXT for contributors.
|
||||
* Copyright (C) 2013-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -26,8 +26,7 @@
|
|||
#define PTREE_H_
|
||||
|
||||
/*
|
||||
|
||||
Implement "KiCad s-epression" support for boost::property_tree's ptree, the 8
|
||||
Implement "KiCad s-expression" support for boost::property_tree's ptree, the 8
|
||||
bit string version of property_tree. The ram resident structure of the ptree is
|
||||
mostly compatible with one created using the xml_parser from
|
||||
boost::property_tree, with slight differences in the way atoms are stored. The
|
||||
|
@ -43,7 +42,6 @@ portion of a much larger document. If so, then using the ptree will likely be a
|
|||
the boost website and there are a number of examples in the
|
||||
pcbnew/eagle_plugin.cpp file in this project. Powerful path navigation support
|
||||
makes it easy to extract a subset of a ptree.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
@ -56,13 +54,13 @@ typedef const PTREE CPTREE;
|
|||
typedef boost::property_tree::ptree_error PTREE_ERROR;
|
||||
|
||||
/**
|
||||
* Function Scan
|
||||
* fills an empty PTREE with information from a KiCad s-expresion stream. Use
|
||||
* a DSNLEXER with an empty keyword table as @a aLexer. Useful for parsing
|
||||
* s-expression files or strings of arbitrary grammars, say from a file or clipboard.
|
||||
* The s-expression must be "KiCad compatible". See Documentation/s-expressions.txt
|
||||
* for this KiCad compatible definition (it is the non-specctra mode).
|
||||
* And also see in tools/property_tree.cpp for example usage.
|
||||
* Fill an empty #PTREE with information from a KiCad s-expression stream.
|
||||
*
|
||||
* Use a #DSNLEXER with an empty keyword table as @a aLexer. Useful for parsing s-expression
|
||||
* files or strings of arbitrary grammars, say from a file or clipboard. The s-expression
|
||||
* must be "KiCad compatible". See Documentation/s-expressions.txt for this KiCad compatible
|
||||
* definition (it is the non-specctra mode). And also see in tools/property_tree.cpp for
|
||||
* example usage.
|
||||
*
|
||||
* <code>
|
||||
*
|
||||
|
@ -87,8 +85,7 @@ typedef boost::property_tree::ptree_error PTREE_ERROR;
|
|||
void Scan( PTREE* aTree, DSNLEXER* aLexer );
|
||||
|
||||
/**
|
||||
* Function Format
|
||||
* outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
|
||||
* Output a #PTREE into s-expression format via an #OUTPUTFORMATTER derivative.
|
||||
*/
|
||||
void Format( OUTPUTFORMATTER* out, int aNestLevel, int aCtl, const CPTREE& aTree );
|
||||
|
||||
|
|
|
@ -74,16 +74,6 @@ class RC_ITEM
|
|||
public:
|
||||
typedef std::vector<KIID> KIIDS;
|
||||
|
||||
protected:
|
||||
int m_errorCode; ///< The error code's numeric value
|
||||
wxString m_errorMessage; ///< A message describing the details of this specific error
|
||||
wxString m_errorTitle; ///< The string describing the type of error
|
||||
wxString m_settingsKey; ///< The key used to describe this type of error in settings
|
||||
MARKER_BASE* m_parent; ///< The marker this item belongs to, if any
|
||||
|
||||
KIIDS m_ids;
|
||||
|
||||
public:
|
||||
RC_ITEM() :
|
||||
m_errorCode( 0 ),
|
||||
m_parent( nullptr )
|
||||
|
@ -181,6 +171,16 @@ public:
|
|||
* Format a coordinate or position to text.
|
||||
*/
|
||||
static wxString ShowCoord( EDA_UNITS aUnits, const wxPoint& aPos );
|
||||
|
||||
protected:
|
||||
int m_errorCode; ///< The error code's numeric value
|
||||
wxString m_errorMessage; ///< A message describing the details of this specific error
|
||||
wxString m_errorTitle; ///< The string describing the type of error
|
||||
wxString m_settingsKey; ///< The key used to describe this type of error in settings
|
||||
MARKER_BASE* m_parent; ///< The marker this item belongs to, if any
|
||||
|
||||
KIIDS m_ids;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -224,8 +224,6 @@ public:
|
|||
|
||||
static KIID ToUUID( wxDataViewItem aItem );
|
||||
|
||||
|
||||
public:
|
||||
RC_TREE_MODEL( EDA_DRAW_FRAME* aParentFrame, wxDataViewCtrl* aView );
|
||||
|
||||
~RC_TREE_MODEL();
|
||||
|
@ -292,7 +290,6 @@ private:
|
|||
void rebuildModel( RC_ITEMS_PROVIDER* aProvider, int aSeverities );
|
||||
void onSizeView( wxSizeEvent& aEvent );
|
||||
|
||||
private:
|
||||
EDA_DRAW_FRAME* m_editFrame;
|
||||
wxDataViewCtrl* m_view;
|
||||
int m_severities;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2019 KiCad Developers, see CHANGELOG.TXT for contributors.
|
||||
* Copyright (C) 2019-2020 KiCad Developers, see CHANGELOG.TXT for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -40,13 +40,15 @@ namespace KIGFX
|
|||
class VIEW_ITEM;
|
||||
|
||||
/**
|
||||
* RENDER_SETTINGS
|
||||
* Contains all the knowledge about how graphical objects are drawn on any output
|
||||
* surface/device. This includes:
|
||||
* - color/transparency settings
|
||||
* - highlighting and high contrast mode control
|
||||
* - drawing quality control (sketch/outline mode)
|
||||
* - text processing flags
|
||||
* Container for all the knowledge about how graphical objects are drawn on any output
|
||||
* surface/device.
|
||||
*
|
||||
* This includes:
|
||||
* - color/transparency settings
|
||||
* - highlighting and high contrast mode control
|
||||
* - drawing quality control (sketch/outline mode)
|
||||
* - text processing flags
|
||||
*
|
||||
* The class acts as an interface between the PAINTER object and the GUI (i.e. Layers/Items
|
||||
* widget or display options dialog).
|
||||
*/
|
||||
|
@ -59,8 +61,8 @@ public:
|
|||
virtual void LoadColors( const COLOR_SETTINGS* aSettings ) { }
|
||||
|
||||
/**
|
||||
* Function SetLayerIsHighContrast
|
||||
* Sets the specified layer as high-contrast.
|
||||
* Set the specified layer as high-contrast.
|
||||
*
|
||||
* @param aLayerId is a layer number that should be displayed in a specific mode.
|
||||
* @param aEnabled is the new layer state ( true = active or false = not active).
|
||||
*/
|
||||
|
@ -73,8 +75,8 @@ public:
|
|||
}
|
||||
|
||||
/**
|
||||
* Function GetLayerIsHighContrast
|
||||
* Returns information whether the queried layer is marked as high-contrast.
|
||||
* Return information whether the queried layer is marked as high-contrast.
|
||||
*
|
||||
* @return True if the queried layer is marked as active.
|
||||
*/
|
||||
inline bool GetLayerIsHighContrast( int aLayerId ) const
|
||||
|
@ -83,7 +85,6 @@ public:
|
|||
}
|
||||
|
||||
/**
|
||||
* Function GetHighContrastLayers()
|
||||
* Returns the set of currently high-contrast layers.
|
||||
*/
|
||||
const std::set<unsigned int> GetHighContrastLayers() const
|
||||
|
@ -92,9 +93,10 @@ public:
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the board layer which is in high-contrast. There should only be one
|
||||
* board layer which is high-contrast at any given time, although there might be
|
||||
* many high-contrast synthetic (GAL) layers.
|
||||
* Return the board layer which is in high-contrast mode.
|
||||
*
|
||||
* There should only be one board layer which is high-contrast at any given time, although
|
||||
* there might be many high-contrast synthetic (GAL) layers.
|
||||
*/
|
||||
PCB_LAYER_ID GetPrimaryHighContrastLayer() const
|
||||
{
|
||||
|
@ -111,8 +113,7 @@ public:
|
|||
void SetActiveLayer( PCB_LAYER_ID aLayer ) { m_activeLayer = aLayer; }
|
||||
|
||||
/**
|
||||
* Function ClearHighContrastLayers
|
||||
* Clears the list of active layers.
|
||||
* Clear the list of active layers.
|
||||
*/
|
||||
inline void ClearHighContrastLayers()
|
||||
{
|
||||
|
@ -120,8 +121,8 @@ public:
|
|||
}
|
||||
|
||||
/**
|
||||
* Function IsHighlightEnabled
|
||||
* Returns current highlight setting.
|
||||
* Return current highlight setting.
|
||||
*
|
||||
* @return True if highlight is enabled, false otherwise.
|
||||
*/
|
||||
inline bool IsHighlightEnabled() const
|
||||
|
@ -130,8 +131,8 @@ public:
|
|||
}
|
||||
|
||||
/**
|
||||
* Function GetHighlightNetCode
|
||||
* Returns netcode of currently highlighted net.
|
||||
* Return the netcode of currently highlighted net.
|
||||
*
|
||||
* @return Netcode of currently highlighted net.
|
||||
*/
|
||||
inline const std::set<int>& GetHighlightNetCodes() const
|
||||
|
@ -140,11 +141,13 @@ public:
|
|||
}
|
||||
|
||||
/**
|
||||
* Function SetHighlight
|
||||
* Turns on/off highlighting - it may be done for the active layer or the specified net(s).
|
||||
* Turns on/off highlighting.
|
||||
*
|
||||
* It may be done for the active layer or the specified net(s)..
|
||||
*
|
||||
* @param aEnabled tells if highlighting should be enabled.
|
||||
* @param aNetcode is optional and if specified, turns on higlighting only for the net with
|
||||
* number given as the parameter.
|
||||
* @param aNetcode is optional and if specified, turns on highlighting only for the net with
|
||||
* number given as the parameter.
|
||||
*/
|
||||
inline void SetHighlight( bool aEnabled, int aNetcode = -1, bool aMulti = false )
|
||||
{
|
||||
|
@ -162,7 +165,6 @@ public:
|
|||
}
|
||||
|
||||
/**
|
||||
* Function SetHighContrast
|
||||
* Turns on/off high contrast display mode.
|
||||
*/
|
||||
void SetHighContrast( bool aEnabled ) { m_hiContrastEnabled = aEnabled; }
|
||||
|
@ -171,6 +173,7 @@ public:
|
|||
/**
|
||||
* Returns the color that should be used to draw the specific VIEW_ITEM on the specific layer
|
||||
* using currently used render settings.
|
||||
*
|
||||
* @param aItem is the VIEW_ITEM.
|
||||
* @param aLayer is the layer.
|
||||
* @return The color.
|
||||
|
@ -189,31 +192,28 @@ public:
|
|||
void SetShowPageLimits( bool aDraw ) { m_showPageLimits = aDraw; }
|
||||
|
||||
/**
|
||||
* Function GetBackgroundColor
|
||||
* Returns current background color settings.
|
||||
* Return current background color settings.
|
||||
*/
|
||||
virtual const COLOR4D& GetBackgroundColor() = 0;
|
||||
|
||||
/**
|
||||
* Sets the background color.
|
||||
* Set the background color.
|
||||
*/
|
||||
virtual void SetBackgroundColor( const COLOR4D& aColor ) = 0;
|
||||
|
||||
/**
|
||||
* Function GetGridColor
|
||||
* Returns current grid color settings.
|
||||
* Return current grid color settings.
|
||||
*/
|
||||
virtual const COLOR4D& GetGridColor() = 0;
|
||||
|
||||
/**
|
||||
* Function GetCursorColor
|
||||
* Returns current cursor color settings.
|
||||
* Return current cursor color settings.
|
||||
*/
|
||||
virtual const COLOR4D& GetCursorColor() = 0;
|
||||
|
||||
/**
|
||||
* Function GetLayerColor
|
||||
* Returns the color used to draw a layer.
|
||||
* Return the color used to draw a layer.
|
||||
*
|
||||
* @param aLayer is the layer number.
|
||||
*/
|
||||
inline const COLOR4D& GetLayerColor( int aLayer ) const
|
||||
|
@ -222,8 +222,8 @@ public:
|
|||
}
|
||||
|
||||
/**
|
||||
* Function SetLayerColor
|
||||
* Changes the color used to draw a layer.
|
||||
* Change the color used to draw a layer.
|
||||
*
|
||||
* @param aLayer is the layer number.
|
||||
* @param aColor is the new color.
|
||||
*/
|
||||
|
@ -259,7 +259,6 @@ public:
|
|||
|
||||
protected:
|
||||
/**
|
||||
* Function update
|
||||
* Precalculates extra colors for layers (e.g. highlighted, darkened and any needed version
|
||||
* of base colors).
|
||||
*/
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2013 Wayne Stambaugh <stambaughw@verizon.net>
|
||||
* Copyright (C) 1992-2013 KiCad Developers, see change_log.txt for contributors.
|
||||
* Copyright (C) 2013-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -43,8 +43,7 @@ class WX_INFOBAR;
|
|||
|
||||
|
||||
/**
|
||||
* REPORTER
|
||||
* is a pure virtual class used to derive REPORTER objects from.
|
||||
* A pure virtual class used to derive REPORTER objects from.
|
||||
*
|
||||
* The purpose of the REPORTER object is to offer a way for a procedural function
|
||||
* to report multiple errors without having to:
|
||||
|
@ -53,16 +52,17 @@ class WX_INFOBAR;
|
|||
* <li> stop after the first error </li>
|
||||
* </ul>
|
||||
* the reporter has 4 severity levels (flags) tagging the messages:
|
||||
* - information
|
||||
* - warning
|
||||
* - error
|
||||
* - action (i.e. indication of changes - add component, change footprint, etc. )
|
||||
* - information
|
||||
* - warning
|
||||
* - error
|
||||
* - action (i.e. indication of changes - add component, change footprint, etc. )
|
||||
*
|
||||
* They are indicators for the message formatting and displaying code,
|
||||
* filtering is not made here.
|
||||
*/
|
||||
|
||||
class REPORTER {
|
||||
|
||||
class REPORTER
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Location where the message is to be reported.
|
||||
|
@ -77,30 +77,30 @@ public:
|
|||
};
|
||||
|
||||
/**
|
||||
* Function Report
|
||||
* is a pure virtual function to override in the derived object.
|
||||
* Report a string with a given severity.
|
||||
*
|
||||
* @param aText is the string to report.
|
||||
* @param aSeverity is an indicator ( RPT_UNDEFINED, RPT_INFO, RPT_WARNING,
|
||||
* RPT_ERROR, RPT_ACTION ) used to filter and format messages
|
||||
* @param aSeverity is an indicator ( RPT_UNDEFINED, RPT_INFO, RPT_WARNING, RPT_ERROR,
|
||||
* RPT_ACTION ) used to filter and format messages
|
||||
*/
|
||||
|
||||
virtual REPORTER& Report( const wxString& aText, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) = 0;
|
||||
virtual REPORTER& Report( const wxString& aText,
|
||||
SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) = 0;
|
||||
|
||||
/**
|
||||
* Function ReportTail
|
||||
* Places the report at the end of the list, for objects that support report ordering
|
||||
*/
|
||||
virtual REPORTER& ReportTail( const wxString& aText, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED )
|
||||
virtual REPORTER& ReportTail( const wxString& aText,
|
||||
SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED )
|
||||
{
|
||||
return Report( aText, aSeverity );
|
||||
}
|
||||
|
||||
/**
|
||||
* Function ReportHead
|
||||
* Places the report at the beginning of the list for objects that support ordering
|
||||
* Places the report at the beginning of the list for objects that support ordering.
|
||||
*/
|
||||
virtual REPORTER& ReportHead( const wxString& aText, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED )
|
||||
virtual REPORTER& ReportHead( const wxString& aText,
|
||||
SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED )
|
||||
{
|
||||
return Report( aText, aSeverity );
|
||||
}
|
||||
|
@ -113,7 +113,6 @@ public:
|
|||
REPORTER& operator <<( const char* aText ) { return Report( aText ); }
|
||||
|
||||
/**
|
||||
* Function HasMessage
|
||||
* Returns true if the reporter client is non-empty.
|
||||
*/
|
||||
virtual bool HasMessage() const = 0;
|
||||
|
@ -130,8 +129,7 @@ public:
|
|||
|
||||
|
||||
/**
|
||||
* WX_TEXT_CTRL_REPORTER
|
||||
* is wrapper for reporting to a wxTextCtrl object.
|
||||
* A wrapper for reporting to a wxTextCtrl object.
|
||||
*/
|
||||
class WX_TEXT_CTRL_REPORTER : public REPORTER
|
||||
{
|
||||
|
@ -148,15 +146,15 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
REPORTER& Report( const wxString& aText, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
|
||||
REPORTER& Report( const wxString& aText,
|
||||
SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
|
||||
|
||||
bool HasMessage() const override;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* WX_STRING_REPORTER
|
||||
* is a wrapper for reporting to a wxString object.
|
||||
* A wrapper for reporting to a wxString object.
|
||||
*/
|
||||
class WX_STRING_REPORTER : public REPORTER
|
||||
{
|
||||
|
@ -180,8 +178,7 @@ public:
|
|||
|
||||
|
||||
/**
|
||||
* WX_HTML_PANEL_REPORTER
|
||||
* is a wrapper for reporting to a wx HTML window
|
||||
* A wrapper for reporting to a wx HTML window.
|
||||
*/
|
||||
class WX_HTML_PANEL_REPORTER : public REPORTER
|
||||
{
|
||||
|
@ -198,21 +195,23 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
REPORTER& Report( const wxString& aText, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
|
||||
REPORTER& Report( const wxString& aText,
|
||||
SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
|
||||
|
||||
REPORTER& ReportTail( const wxString& aText, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
|
||||
REPORTER& ReportTail( const wxString& aText,
|
||||
SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
|
||||
|
||||
REPORTER& ReportHead( const wxString& aText, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
|
||||
REPORTER& ReportHead( const wxString& aText,
|
||||
SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
|
||||
|
||||
bool HasMessage() const override;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* NULL_REPORTER
|
||||
* A singleton reporter that reports to nowhere.
|
||||
*
|
||||
* A singleton reporter that reports to nowhere. Used as to simplify code by
|
||||
* avoiding the reportee to check for a non-NULL reporter object.
|
||||
* Used as to simplify code by avoiding the reportee to check for a non-NULL reporter object.
|
||||
*/
|
||||
class NULL_REPORTER : public REPORTER
|
||||
{
|
||||
|
@ -227,15 +226,14 @@ public:
|
|||
|
||||
static REPORTER& GetInstance();
|
||||
|
||||
REPORTER& Report( const wxString& aText, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
|
||||
REPORTER& Report( const wxString& aText,
|
||||
SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
|
||||
|
||||
bool HasMessage() const override { return false; }
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* STDOUT_REPORTER
|
||||
*
|
||||
* Debug type reporter, forwarding messages to std::cout.
|
||||
*/
|
||||
class STDOUT_REPORTER : public REPORTER
|
||||
|
@ -251,37 +249,38 @@ public:
|
|||
|
||||
static REPORTER& GetInstance();
|
||||
|
||||
REPORTER& Report( const wxString& aText, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
|
||||
REPORTER& Report( const wxString& aText,
|
||||
SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
|
||||
|
||||
bool HasMessage() const override { return false; }
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* STATUSBAR_REPORTER
|
||||
* is a wrapper for reporting to a specific text location in a statusbar
|
||||
* A wrapper for reporting to a specific text location in a statusbar.
|
||||
*/
|
||||
class STATUSBAR_REPORTER : public REPORTER
|
||||
{
|
||||
private:
|
||||
wxStatusBar* m_statusBar;
|
||||
int m_position;
|
||||
|
||||
public:
|
||||
STATUSBAR_REPORTER( wxStatusBar* aStatusBar, int aPosition = 0 )
|
||||
: REPORTER(), m_statusBar( aStatusBar ), m_position( aPosition )
|
||||
: REPORTER(),
|
||||
m_statusBar( aStatusBar ),
|
||||
m_position( aPosition )
|
||||
{
|
||||
}
|
||||
|
||||
REPORTER& Report( const wxString& aText, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
|
||||
|
||||
bool HasMessage() const override;
|
||||
|
||||
private:
|
||||
wxStatusBar* m_statusBar;
|
||||
int m_position;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* INFOBAR_REPORTER
|
||||
* is a wrapper for reporting to a WX_INFOBAR UI element.
|
||||
* A wrapper for reporting to a #WX_INFOBAR UI element.
|
||||
*
|
||||
* The infobar is not updated until the @c Finalize() method is called. That method will
|
||||
* queue either a show message or a dismiss event for the infobar - so this reporter is
|
||||
|
@ -291,12 +290,6 @@ public:
|
|||
*/
|
||||
class INFOBAR_REPORTER : public REPORTER
|
||||
{
|
||||
private:
|
||||
bool m_messageSet;
|
||||
WX_INFOBAR* m_infoBar;
|
||||
wxString m_message;
|
||||
SEVERITY m_severity;
|
||||
|
||||
public:
|
||||
INFOBAR_REPORTER( WX_INFOBAR* aInfoBar )
|
||||
: REPORTER(),
|
||||
|
@ -307,7 +300,8 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
REPORTER& Report( const wxString& aText, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
|
||||
REPORTER& Report( const wxString& aText,
|
||||
SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
|
||||
|
||||
bool HasMessage() const override;
|
||||
|
||||
|
@ -315,6 +309,12 @@ public:
|
|||
* Update the infobar with the reported text.
|
||||
*/
|
||||
void Finalize();
|
||||
|
||||
private:
|
||||
bool m_messageSet;
|
||||
WX_INFOBAR* m_infoBar;
|
||||
wxString m_message;
|
||||
SEVERITY m_severity;
|
||||
};
|
||||
|
||||
#endif // _REPORTER_H_
|
||||
|
|
397
include/richio.h
397
include/richio.h
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2007-2010 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
||||
* Copyright (C) 2016 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2016-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -42,13 +42,12 @@
|
|||
|
||||
|
||||
/**
|
||||
* Function StrPrintf
|
||||
* is like sprintf() but the output is appended to a std::string instead of to a
|
||||
* This is like sprintf() but the output is appended to a std::string instead of to a
|
||||
* character array.
|
||||
*
|
||||
* @param aResult is the string to append to, previous text is not clear()ed.
|
||||
* @param aFormat is a printf() style format string.
|
||||
* @return int - the count of bytes appended to the result string, no terminating
|
||||
* nul is included.
|
||||
* @return the count of bytes appended to the result string, no terminating nul is included.
|
||||
*/
|
||||
int
|
||||
#if defined(__GNUG__)
|
||||
|
@ -58,9 +57,9 @@ int
|
|||
|
||||
|
||||
/**
|
||||
* Function StrPrintf
|
||||
* is like sprintf() but the output is returned in a std::string instead of to a
|
||||
* This is like sprintf() but the output is returned in a std::string instead of to a
|
||||
* character array.
|
||||
*
|
||||
* @param format is a printf() style format string.
|
||||
* @return std::string - the result of the sprintf().
|
||||
*/
|
||||
|
@ -75,13 +74,84 @@ std::string
|
|||
#define LINE_READER_LINE_INITIAL_SIZE 5000
|
||||
|
||||
/**
|
||||
* LINE_READER
|
||||
* is an abstract class from which implementation specific LINE_READERs may
|
||||
* be derived to read single lines of text and manage a line number counter.
|
||||
* An abstract class from which implementation specific LINE_READERs may be derived to
|
||||
* read single lines of text and manage a line number counter.
|
||||
*/
|
||||
class LINE_READER
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Build a line reader and fixes the length of the maximum supported line length
|
||||
* to @a aMaxLineLength.
|
||||
*/
|
||||
LINE_READER( unsigned aMaxLineLength = LINE_READER_LINE_DEFAULT_MAX );
|
||||
|
||||
virtual ~LINE_READER();
|
||||
|
||||
/**
|
||||
* Read a line of text into the buffer and increments the line number counter.
|
||||
*
|
||||
* If the line is larger than the maximum length passed to the constructor, then an
|
||||
* exception is thrown. The line is nul terminated.
|
||||
*
|
||||
* @return The beginning of the read line, or NULL if EOF.
|
||||
* @throw IO_ERROR when a line is too long.
|
||||
*/
|
||||
virtual char* ReadLine() = 0;
|
||||
|
||||
/**
|
||||
* Returns the name of the source of the lines in an abstract sense.
|
||||
*
|
||||
* This may be a file or it may be the clipboard or any other source of lines of text.
|
||||
* The returned string is useful for reporting error messages.
|
||||
*/
|
||||
virtual const wxString& GetSource() const
|
||||
{
|
||||
return m_source;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a pointer to the last line that was read in.
|
||||
*/
|
||||
char* Line() const
|
||||
{
|
||||
return m_line;
|
||||
}
|
||||
|
||||
/**
|
||||
* A casting operator that returns a char* pointer to the start of the line buffer.
|
||||
*/
|
||||
operator char* () const
|
||||
{
|
||||
return Line();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the line number of the last line read from this LINE_READER.
|
||||
*
|
||||
* Lines start from 1.
|
||||
*/
|
||||
virtual unsigned LineNumber() const
|
||||
{
|
||||
return m_lineNum;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the number of bytes in the last line read from this LINE_READER.
|
||||
*/
|
||||
unsigned Length() const
|
||||
{
|
||||
return m_length;
|
||||
}
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Will expand the capacity of @a line up to maxLineLength but not greater, so
|
||||
* be careful about making assumptions of @a capacity after calling this.
|
||||
*/
|
||||
void expandCapacity( unsigned aNewsize );
|
||||
|
||||
unsigned m_length; ///< no. bytes in line before trailing nul.
|
||||
unsigned m_lineNum;
|
||||
|
||||
|
@ -91,127 +161,37 @@ protected:
|
|||
unsigned m_maxLineLength; ///< maximum allowed capacity using resizing.
|
||||
|
||||
wxString m_source; ///< origin of text lines, e.g. filename or "clipboard"
|
||||
|
||||
/**
|
||||
* Function expandCapacity
|
||||
* will expand the capacity of @a line up to maxLineLength but not greater, so
|
||||
* be careful about making assumptions of @a capacity after calling this.
|
||||
*/
|
||||
void expandCapacity( unsigned aNewsize );
|
||||
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor LINE_READER
|
||||
* builds a line reader and fixes the length of the maximum supported
|
||||
* line length to @a aMaxLineLength.
|
||||
*/
|
||||
LINE_READER( unsigned aMaxLineLength = LINE_READER_LINE_DEFAULT_MAX );
|
||||
|
||||
virtual ~LINE_READER();
|
||||
|
||||
/**
|
||||
* Function ReadLine
|
||||
* reads a line of text into the buffer and increments the line number
|
||||
* counter. If the line is larger than aMaxLineLength passed to the
|
||||
* constructor, then an exception is thrown. The line is nul terminated.
|
||||
* @return char* - The beginning of the read line, or NULL if EOF.
|
||||
* @throw IO_ERROR when a line is too long.
|
||||
*/
|
||||
virtual char* ReadLine() = 0;
|
||||
|
||||
/**
|
||||
* Function GetSource
|
||||
* returns the name of the source of the lines in an abstract sense.
|
||||
* This may be a file or it may be the clipboard or any other source
|
||||
* of lines of text. The returned string is useful for reporting error
|
||||
* messages.
|
||||
*/
|
||||
virtual const wxString& GetSource() const
|
||||
{
|
||||
return m_source;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function Line
|
||||
* returns a pointer to the last line that was read in.
|
||||
*/
|
||||
char* Line() const
|
||||
{
|
||||
return m_line;
|
||||
}
|
||||
|
||||
/**
|
||||
* Operator char*
|
||||
* is a casting operator that returns a char* pointer to the start of the
|
||||
* line buffer.
|
||||
*/
|
||||
operator char* () const
|
||||
{
|
||||
return Line();
|
||||
}
|
||||
|
||||
/**
|
||||
* Function Line Number
|
||||
* returns the line number of the last line read from this LINE_READER. Lines
|
||||
* start from 1.
|
||||
*/
|
||||
virtual unsigned LineNumber() const
|
||||
{
|
||||
return m_lineNum;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function Length
|
||||
* returns the number of bytes in the last line read from this LINE_READER.
|
||||
*/
|
||||
unsigned Length() const
|
||||
{
|
||||
return m_length;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* FILE_LINE_READER
|
||||
* is a LINE_READER that reads from an open file. File must be already open
|
||||
* so that this class can exist without any UI policy.
|
||||
* A LINE_READER that reads from an open file.
|
||||
*
|
||||
* File must be already open so that this class can exist without any UI policy.
|
||||
*/
|
||||
class FILE_LINE_READER : public LINE_READER
|
||||
{
|
||||
protected:
|
||||
|
||||
bool m_iOwn; ///< if I own the file, I'll promise to close it, else not.
|
||||
FILE* m_fp; ///< I may own this file, but might not.
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor FILE_LINE_READER
|
||||
* takes @a aFileName and the size of the desired line buffer and opens
|
||||
* the file and assumes the obligation to close it.
|
||||
* Take @a aFileName and the size of the desired line buffer and opens the file and
|
||||
* assumes the obligation to close it.
|
||||
*
|
||||
* @param aFileName is the name of the file to open and to use for error reporting purposes.
|
||||
*
|
||||
* @param aStartingLineNumber is the initial line number to report on error, and is
|
||||
* accessible here for the case where multiple DSNLEXERs are reading from the
|
||||
* same file in sequence, all from the same open file (with @a doOwn = false).
|
||||
* Internally it is incremented by one after each ReadLine(), so the first
|
||||
* reported line number will always be one greater than what is provided here.
|
||||
*
|
||||
* @param aMaxLineLength is the number of bytes to use in the line buffer.
|
||||
*
|
||||
* @throw IO_ERROR if @a aFileName cannot be opened.
|
||||
*/
|
||||
FILE_LINE_READER( const wxString& aFileName,
|
||||
unsigned aStartingLineNumber = 0,
|
||||
unsigned aMaxLineLength = LINE_READER_LINE_DEFAULT_MAX );
|
||||
FILE_LINE_READER( const wxString& aFileName, unsigned aStartingLineNumber = 0,
|
||||
unsigned aMaxLineLength = LINE_READER_LINE_DEFAULT_MAX );
|
||||
|
||||
/**
|
||||
* Constructor FILE_LINE_READER
|
||||
* takes an open FILE and the size of the desired line buffer and takes
|
||||
* ownership of the open file, i.e. assumes the obligation to close it.
|
||||
* Take an open FILE and the size of the desired line buffer and takes ownership of
|
||||
* the open file, i.e. assumes the obligation to close it.
|
||||
*
|
||||
* @param aFile is an open file.
|
||||
* @param aFileName is the name of the file for error reporting purposes.
|
||||
|
@ -224,33 +204,35 @@ public:
|
|||
* @param aMaxLineLength is the number of bytes to use in the line buffer.
|
||||
*/
|
||||
FILE_LINE_READER( FILE* aFile, const wxString& aFileName, bool doOwn = true,
|
||||
unsigned aStartingLineNumber = 0,
|
||||
unsigned aMaxLineLength = LINE_READER_LINE_DEFAULT_MAX );
|
||||
unsigned aStartingLineNumber = 0,
|
||||
unsigned aMaxLineLength = LINE_READER_LINE_DEFAULT_MAX );
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
* may or may not close the open file, depending on @a doOwn in constructor.
|
||||
* May or may not close the open file, depending on @a doOwn in constructor.
|
||||
*/
|
||||
~FILE_LINE_READER();
|
||||
|
||||
char* ReadLine() override;
|
||||
|
||||
/**
|
||||
* Function Rewind
|
||||
* rewinds the file and resets the line number back to zero. Line number
|
||||
* will go to 1 on first ReadLine().
|
||||
* Rewind the file and resets the line number back to zero.
|
||||
*
|
||||
* Line number will go to 1 on first ReadLine().
|
||||
*/
|
||||
void Rewind()
|
||||
{
|
||||
rewind( m_fp );
|
||||
m_lineNum = 0;
|
||||
}
|
||||
|
||||
protected:
|
||||
bool m_iOwn; ///< if I own the file, I'll promise to close it, else not.
|
||||
FILE* m_fp; ///< I may own this file, but might not.
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* STRING_LINE_READER
|
||||
* is a LINE_READER that reads from a multiline 8 bit wide std::string
|
||||
* Is a #LINE_READER that reads from a multiline 8 bit wide std::string
|
||||
*/
|
||||
class STRING_LINE_READER : public LINE_READER
|
||||
{
|
||||
|
@ -261,22 +243,21 @@ protected:
|
|||
public:
|
||||
|
||||
/**
|
||||
* Constructor STRING_LINE_READER( const std::string&, const wxString& )
|
||||
* Construct a string line reader.
|
||||
*
|
||||
* @param aString is a source string consisting of one or more lines
|
||||
* of text, where multiple lines are separated with a '\n' character.
|
||||
* The last line does not necessarily need a trailing '\n'.
|
||||
*
|
||||
* @param aSource describes the source of aString for error reporting purposes
|
||||
* can be anything meaninful, such as wxT( "clipboard" ).
|
||||
* can be anything meaningful, such as wxT( "clipboard" ).
|
||||
*/
|
||||
STRING_LINE_READER( const std::string& aString, const wxString& aSource );
|
||||
|
||||
/**
|
||||
* Constructor STRING_LINE_READER( const STRING_LINE_READER& )
|
||||
* allows for a continuation of the reading of a stream started by another
|
||||
* Construct a string line reader.
|
||||
*
|
||||
* Allows for a continuation of the reading of a stream started by another
|
||||
* STRING_LINE_READER. Any stream offset and source name are used from
|
||||
* @a aStartingPoint.
|
||||
*/
|
||||
STRING_LINE_READER( const STRING_LINE_READER& aStartingPoint );
|
||||
|
||||
|
@ -285,18 +266,13 @@ public:
|
|||
|
||||
|
||||
/**
|
||||
* INPUTSTREAM_LINE_READER
|
||||
* is a LINE_READER that reads from a wxInputStream object.
|
||||
* A #LINE_READER that reads from a wxInputStream object.
|
||||
*/
|
||||
class INPUTSTREAM_LINE_READER : public LINE_READER
|
||||
{
|
||||
protected:
|
||||
wxInputStream* m_stream; //< The input stream to read. No ownership of this pointer.
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor WXINPUTSTREAM_LINE_READER
|
||||
* Construct a #LINE_READER from a wxInputStream object.
|
||||
*
|
||||
* @param aStream A pointer to a wxInputStream object to read.
|
||||
* @param aSource The name of the stream source, for error reporting purposes.
|
||||
|
@ -304,36 +280,31 @@ public:
|
|||
INPUTSTREAM_LINE_READER( wxInputStream* aStream, const wxString& aSource );
|
||||
|
||||
char* ReadLine() override;
|
||||
|
||||
protected:
|
||||
wxInputStream* m_stream; //< The input stream to read. No ownership of this pointer.
|
||||
};
|
||||
|
||||
|
||||
#define OUTPUTFMTBUFZ 500 ///< default buffer size for any OUTPUT_FORMATTER
|
||||
|
||||
/**
|
||||
* OUTPUTFORMATTER
|
||||
* is an important interface (abstract class) used to output 8 bit text in
|
||||
* a convenient way. The primary interface is "printf() - like" but
|
||||
* with support for indentation control. The destination of the 8 bit
|
||||
* wide text is up to the implementer.
|
||||
* An interface used to output 8 bit text in a convenient way.
|
||||
*
|
||||
* The primary interface is "printf() - like" but with support for indentation control. The
|
||||
* destination of the 8 bit wide text is up to the implementer.
|
||||
* <p>
|
||||
* The implementer only has to implement the write() function, but can
|
||||
* also optionally re-implement GetQuoteChar().
|
||||
* The implementer only has to implement the write() function, but can also optionally
|
||||
* re-implement GetQuoteChar().
|
||||
* <p>
|
||||
* If you want to output a wxString, then use TO_UTF8() on it
|
||||
* before passing it as an argument to Print().
|
||||
* If you want to output a wxString, then use TO_UTF8() on it before passing it as an
|
||||
* argument to Print().
|
||||
* <p>
|
||||
* Since this is an abstract interface, only classes derived from
|
||||
* this one may actually be used.
|
||||
* Since this is an abstract interface, only classes derived from this one may actually be
|
||||
* used.
|
||||
*/
|
||||
class OUTPUTFORMATTER
|
||||
{
|
||||
std::vector<char> m_buffer;
|
||||
char quoteChar[2];
|
||||
|
||||
int sprint( const char* fmt, ... );
|
||||
int vprint( const char* fmt, va_list ap );
|
||||
|
||||
|
||||
protected:
|
||||
OUTPUTFORMATTER( int aReserve = OUTPUTFMTBUFZ, char aQuoteChar = '"' ) :
|
||||
m_buffer( aReserve, '\0' )
|
||||
|
@ -345,22 +316,19 @@ protected:
|
|||
virtual ~OUTPUTFORMATTER() {}
|
||||
|
||||
/**
|
||||
* Function GetQuoteChar
|
||||
* performs quote character need determination according to the Specctra DSN
|
||||
* specification.
|
||||
* Perform quote character need determination according to the Specctra DSN specification.
|
||||
|
||||
* @param wrapee A string that might need wrapping on each end.
|
||||
* @param quote_char A single character C string which provides the current
|
||||
* quote character, should it be needed by the wrapee.
|
||||
* quote character, should it be needed by the wrapee.
|
||||
*
|
||||
* @return const char* - the quote_char as a single character string, or ""
|
||||
* if the wrapee does not need to be wrapped.
|
||||
* @return the quote_char as a single character string, or "" if the wrapee does not need
|
||||
* to be wrapped.
|
||||
*/
|
||||
static const char* GetQuoteChar( const char* wrapee, const char* quote_char );
|
||||
|
||||
/**
|
||||
* Function write
|
||||
* should be coded in the interface implementation (derived) classes.
|
||||
* Should be coded in the interface implementation (derived) classes.
|
||||
*
|
||||
* @param aOutBuf is the start of a byte buffer to write.
|
||||
* @param aCount tells how many bytes to write.
|
||||
|
@ -374,19 +342,14 @@ protected:
|
|||
// so increase the STRING-INDEX and FIRST-TO_CHECK by one.
|
||||
// See http://docs.freebsd.org/info/gcc/gcc.info.Function_Attributes.html
|
||||
// Then to get format checking during the compile, compile with -Wall or -Wformat
|
||||
#define PRINTF_FUNC __attribute__ ((format (printf, 3, 4)))
|
||||
|
||||
#define PRINTF_FUNC __attribute__( ( format( printf, 3, 4 ) ) )
|
||||
#else
|
||||
#define PRINTF_FUNC // nothing
|
||||
#endif
|
||||
|
||||
public:
|
||||
|
||||
//-----<interface functions>------------------------------------------
|
||||
|
||||
/**
|
||||
* Function Print
|
||||
* formats and writes text to the output stream.
|
||||
* Format and write text to the output stream.
|
||||
*
|
||||
* @param nestLevel The multiple of spaces to precede the output with.
|
||||
* @param fmt A printf() style format string.
|
||||
|
@ -398,35 +361,31 @@ public:
|
|||
int PRINTF_FUNC Print( int nestLevel, const char* fmt, ... );
|
||||
|
||||
/**
|
||||
* Function GetQuoteChar
|
||||
* performs quote character need determination.
|
||||
* It returns the quote character as a single character string for a given
|
||||
* input wrapee string. If the wrappee does not need to be quoted,
|
||||
* the return value is "" (the null string), such as when there are no
|
||||
* delimiters in the input wrapee string. If you want the quote_char
|
||||
* to be assuredly not "", then pass in "(" as the wrappee.
|
||||
* Perform quote character need determination.
|
||||
*
|
||||
* It returns the quote character as a single character string for a given input wrapee
|
||||
* string. If the wrappee does not need to be quoted, the return value is "" (the null
|
||||
* string), such as when there are no delimiters in the input wrapee string. If you want
|
||||
* the quote_char to be assuredly not "", then pass in "(" as the wrappee.
|
||||
* <p>
|
||||
* Implementations are free to override the default behavior, which is to
|
||||
* call the static function of the same name.
|
||||
|
||||
* Implementations are free to override the default behavior, which is to call the static
|
||||
* function of the same name.
|
||||
*
|
||||
* @param wrapee A string that might need wrapping on each end.
|
||||
* @return const char* - the quote_char as a single character string, or ""
|
||||
* if the wrapee does not need to be wrapped.
|
||||
* @return the quote_char as a single character string, or "" if the wrapee does not need
|
||||
* to be wrapped.
|
||||
*/
|
||||
virtual const char* GetQuoteChar( const char* wrapee );
|
||||
|
||||
/**
|
||||
* Function Quotes
|
||||
* checks \a aWrapee input string for a need to be quoted
|
||||
* (e.g. contains a ')' character or a space), and for \" double quotes
|
||||
* within the string that need to be escaped such that the DSNLEXER
|
||||
* will correctly parse the string from a file later.
|
||||
* Check \a aWrapee input string for a need to be quoted (e.g. contains a ')' character
|
||||
* or a space), and for \" double quotes within the string that need to be escaped such
|
||||
* that the DSNLEXER will correctly parse the string from a file later.
|
||||
*
|
||||
* @param aWrapee is a string that might need wraping in double quotes,
|
||||
* and it might need to have its internal content escaped, or not.
|
||||
*
|
||||
* @return std::string - whose c_str() function can be called for passing
|
||||
* to printf() style functions that output UTF8 encoded s-expression streams.
|
||||
* @param aWrapee is a string that might need wrapping in double quotes, and it might need
|
||||
* to have its internal content escaped, or not.
|
||||
* @return a std::string- whose c_str() function can be called for passing to printf()
|
||||
* style functions that output UTF8 encoded s-expression streams.
|
||||
*
|
||||
* @throw IO_ERROR, if there is any kind of problem with the input string.
|
||||
*/
|
||||
|
@ -434,24 +393,26 @@ public:
|
|||
|
||||
std::string Quotew( const wxString& aWrapee );
|
||||
|
||||
//-----</interface functions>-----------------------------------------
|
||||
private:
|
||||
std::vector<char> m_buffer;
|
||||
char quoteChar[2];
|
||||
|
||||
int sprint( const char* fmt, ... );
|
||||
int vprint( const char* fmt, va_list ap );
|
||||
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* STRING_FORMATTER
|
||||
* implements OUTPUTFORMATTER to a memory buffer. After Print()ing the
|
||||
* string is available through GetString()
|
||||
*/
|
||||
* Implement an #OUTPUTFORMATTER to a memory buffer.
|
||||
*
|
||||
* After Print()ing the string is available through GetString()
|
||||
*/
|
||||
class STRING_FORMATTER : public OUTPUTFORMATTER
|
||||
{
|
||||
std::string m_mystring;
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor STRING_FORMATTER
|
||||
* reserves space in the buffer
|
||||
* Reserve space in the buffer.
|
||||
*/
|
||||
STRING_FORMATTER( int aReserve = OUTPUTFMTBUFZ, char aQuoteChar = '"' ) :
|
||||
OUTPUTFORMATTER( aReserve, aQuoteChar )
|
||||
|
@ -459,8 +420,7 @@ public:
|
|||
}
|
||||
|
||||
/**
|
||||
* Function Clear
|
||||
* clears the buffer and empties the internal string.
|
||||
* Clear the buffer and empties the internal string.
|
||||
*/
|
||||
void Clear()
|
||||
{
|
||||
|
@ -468,8 +428,7 @@ public:
|
|||
}
|
||||
|
||||
/**
|
||||
* Function StripUseless
|
||||
* removes whitespace, '(', and ')' from the mystring.
|
||||
* Removes whitespace, '(', and ')' from the string.
|
||||
*/
|
||||
void StripUseless();
|
||||
|
||||
|
@ -479,40 +438,37 @@ public:
|
|||
}
|
||||
|
||||
protected:
|
||||
//-----<OUTPUTFORMATTER>------------------------------------------------
|
||||
void write( const char* aOutBuf, int aCount ) override;
|
||||
//-----</OUTPUTFORMATTER>-----------------------------------------------
|
||||
|
||||
private:
|
||||
std::string m_mystring;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* FILE_OUTPUTFORMATTER
|
||||
* may be used for text file output. It is about 8 times faster than
|
||||
* STREAM_OUTPUTFORMATTER for file streams.
|
||||
* Used for text file output.
|
||||
*
|
||||
* It is about 8 times faster than STREAM_OUTPUTFORMATTER for file streams.
|
||||
*/
|
||||
class FILE_OUTPUTFORMATTER : public OUTPUTFORMATTER
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param aFileName is the full filename to open and save to as a text file.
|
||||
* @param aMode is what you would pass to wxFopen()'s mode, defaults to wxT( "wt" )
|
||||
* for text files that are to be created here and now.
|
||||
* @param aQuoteChar is a char used for quoting problematic strings
|
||||
(with whitespace or special characters in them).
|
||||
* for text files that are to be created here and now.
|
||||
* @param aQuoteChar is a char used for quoting problematic strings (with whitespace or
|
||||
* special characters in them).
|
||||
* @throw IO_ERROR if the file cannot be opened.
|
||||
*/
|
||||
FILE_OUTPUTFORMATTER( const wxString& aFileName,
|
||||
const wxChar* aMode = wxT( "wt" ),
|
||||
char aQuoteChar = '"' );
|
||||
FILE_OUTPUTFORMATTER( const wxString& aFileName, const wxChar* aMode = wxT( "wt" ),
|
||||
char aQuoteChar = '"' );
|
||||
|
||||
~FILE_OUTPUTFORMATTER();
|
||||
|
||||
protected:
|
||||
//-----<OUTPUTFORMATTER>------------------------------------------------
|
||||
void write( const char* aOutBuf, int aCount ) override;
|
||||
//-----</OUTPUTFORMATTER>-----------------------------------------------
|
||||
|
||||
FILE* m_fp; ///< takes ownership
|
||||
wxString m_filename;
|
||||
|
@ -520,9 +476,9 @@ protected:
|
|||
|
||||
|
||||
/**
|
||||
* STREAM_OUTPUTFORMATTER
|
||||
* implements OUTPUTFORMATTER to a wxWidgets wxOutputStream. The stream is
|
||||
* neither opened nor closed by this class.
|
||||
* Implement an #OUTPUTFORMATTER to a wxWidgets wxOutputStream.
|
||||
*
|
||||
* The stream is neither opened nor closed by this class.
|
||||
*/
|
||||
class STREAM_OUTPUTFORMATTER : public OUTPUTFORMATTER
|
||||
{
|
||||
|
@ -530,9 +486,8 @@ class STREAM_OUTPUTFORMATTER : public OUTPUTFORMATTER
|
|||
|
||||
public:
|
||||
/**
|
||||
* Constructor STREAM_OUTPUTFORMATTER
|
||||
* can take any number of wxOutputStream derivations, so it can write
|
||||
* to a file, socket, or zip file.
|
||||
* This can take any number of wxOutputStream derivations, so it can write to a file,
|
||||
* socket, or zip file.
|
||||
*/
|
||||
STREAM_OUTPUTFORMATTER( wxOutputStream& aStream, char aQuoteChar = '"' ) :
|
||||
OUTPUTFORMATTER( OUTPUTFMTBUFZ, aQuoteChar ),
|
||||
|
@ -541,9 +496,7 @@ public:
|
|||
}
|
||||
|
||||
protected:
|
||||
//-----<OUTPUTFORMATTER>------------------------------------------------
|
||||
void write( const char* aOutBuf, int aCount ) override;
|
||||
//-----</OUTPUTFORMATTER>-----------------------------------------------
|
||||
};
|
||||
|
||||
#endif // RICHIO_H_
|
||||
|
|
|
@ -28,9 +28,7 @@
|
|||
#include <wx/stc/stc.h>
|
||||
|
||||
/**
|
||||
* SCINTILLA_TRICKS
|
||||
* is used to add cut/copy/paste, autocomplete and brace highlighting to a wxStyleTextCtrl
|
||||
* instance.
|
||||
* Add cut/copy/paste, autocomplete and brace highlighting to a wxStyleTextCtrl instance.
|
||||
*/
|
||||
class SCINTILLA_TRICKS : public wxEvtHandler
|
||||
{
|
||||
|
|
|
@ -25,9 +25,8 @@
|
|||
#define __SCOPED_SET_RESET_H
|
||||
|
||||
/**
|
||||
* @class SCOPED_SET_RESET
|
||||
* @brief RAII class that sets an value at construction and resets
|
||||
* it to the original value at destruction.
|
||||
* RAII class that sets an value at construction and resets it to the original value
|
||||
* at destruction.
|
||||
*
|
||||
* @note There is no type deduction for template classes until C++17, \
|
||||
* so you can't do this:
|
||||
|
@ -46,8 +45,7 @@ class SCOPED_SET_RESET
|
|||
{
|
||||
public:
|
||||
|
||||
SCOPED_SET_RESET( VAL_TYPE& target,
|
||||
VAL_TYPE value ):
|
||||
SCOPED_SET_RESET( VAL_TYPE& target, VAL_TYPE value ):
|
||||
m_target( target )
|
||||
{
|
||||
m_original = target;
|
||||
|
@ -55,10 +53,7 @@ public:
|
|||
}
|
||||
|
||||
/**
|
||||
* Function ~SCOPED_SET_RESET
|
||||
*
|
||||
* Destruct the class, and return the target to its original
|
||||
* value.
|
||||
* Destruct the class, and return the target to its original value.
|
||||
*/
|
||||
~SCOPED_SET_RESET()
|
||||
{
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2014 CERN
|
||||
* Copyright (C) 1992-2014 KiCad Developers, see CHANGELOG.TXT for contributors.
|
||||
* Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* @author Maciej Suminski <maciej.suminski@cern.ch>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
|
@ -32,16 +32,15 @@
|
|||
|
||||
|
||||
/**
|
||||
* SEARCH_STACK
|
||||
* looks for files in a number of places. Augments wxPathList.
|
||||
* I chose the name because it sounded like a stack of work, as a reminder
|
||||
* that anything you put in here means searching work at some point in time.
|
||||
* Look for files in a number of paths.
|
||||
*
|
||||
* Augments wxPathList. I chose the name because it sounded like a stack of work, as a
|
||||
* reminder that anything you put in here means searching work at some point in time.
|
||||
* (An alternative is to simply know where something is.)
|
||||
*/
|
||||
class SEARCH_STACK : public wxPathList, public PROJECT::_ELEM
|
||||
{
|
||||
public:
|
||||
|
||||
KICAD_T Type() override { return SEARCH_STACK_T; }
|
||||
|
||||
#if defined(DEBUG)
|
||||
|
@ -49,26 +48,24 @@ public:
|
|||
#endif
|
||||
|
||||
/**
|
||||
* Function FilenameWithRelativePathInSearchList
|
||||
* returns the shortest possible path which can be use later to find
|
||||
* a full path from this SEARCH_STACK.
|
||||
* <p>
|
||||
* If the library path is already in the library search paths list,
|
||||
* just add the library name to the list. Otherwise, add the library
|
||||
* name with the full or relative path. The relative path is preferable
|
||||
* because it preserves use of default libraries paths, when the path
|
||||
* is a sub path of these default paths. Note we accept only sub paths
|
||||
* not relative paths starting by ../ that are not subpaths and are
|
||||
* outside kicad libs paths
|
||||
* Return the shortest possible path which can be use later to find a full path from
|
||||
* this SEARCH_STACK.
|
||||
*
|
||||
* If the library path is already in the library search paths list, just add the library
|
||||
* name to the list. Otherwise, add the library name with the full or relative path.
|
||||
* The relative path is preferable because it preserves use of default libraries paths,
|
||||
* when the path is a sub path of these default paths. Note we accept only sub paths
|
||||
* not relative paths starting by ../ that are not subpaths and are outside KiCad library
|
||||
* paths
|
||||
*
|
||||
* @param aFullFilename The filename with path and extension.
|
||||
* @param aBaseDir The absolute path on which relative paths in this
|
||||
* SEARCH_STACK are based.
|
||||
* @param aBaseDir The absolute path on which relative paths in this SEARCH_STACK are
|
||||
* based.
|
||||
* @return a short filename (with extension) with only a relative path if
|
||||
* this filename can be found in library paths
|
||||
*/
|
||||
wxString FilenameWithRelativePathInSearchList(
|
||||
const wxString& aFullFilename, const wxString& aBaseDir );
|
||||
wxString FilenameWithRelativePathInSearchList( const wxString& aFullFilename,
|
||||
const wxString& aBaseDir );
|
||||
|
||||
wxString FindValidPath( const wxString& aFileName ) const
|
||||
{
|
||||
|
@ -82,44 +79,42 @@ public:
|
|||
}
|
||||
|
||||
/**
|
||||
* Function AddPaths
|
||||
* insert or append path(s)
|
||||
* Insert or append path(s).
|
||||
*
|
||||
* @param aPaths = path or path list to add. paths must be
|
||||
* separated by ";" on windows, or ":" | ";" on unix.
|
||||
*
|
||||
* @param aIndex = insertion point, -1 for append.
|
||||
* @param aPaths path or path list to add. paths must be separated by ";" on windows,
|
||||
* or ":" | ";" on unix.
|
||||
* @param aIndex insertion point, -1 for append.
|
||||
*/
|
||||
void AddPaths( const wxString& aPaths, int aIndex = -1 );
|
||||
|
||||
/**
|
||||
* Function RemovePaths
|
||||
* removes the given path(s) from the library path list
|
||||
* @param aPaths = path or list of paths to remove. If list, paths must be separated by
|
||||
* ";" on windows, or ":" | ";" on unix.
|
||||
* Remove the given path(s) from the library path list.
|
||||
*
|
||||
* @param aPaths path or list of paths to remove. If list, paths must be separated by
|
||||
* ";" on windows, or ":" | ";" on unix.
|
||||
*/
|
||||
void RemovePaths( const wxString& aPaths );
|
||||
|
||||
/**
|
||||
* Function Split
|
||||
* separates aPathString into individual paths.
|
||||
* Separate \a aPathString into individual paths.
|
||||
*
|
||||
* @param aResult is where to put the paths, it should be empty upon entry.
|
||||
* @param aPathString is concatonated string with interposing ';' or ':' separators.
|
||||
* @return int - the count of paths found in aPathString
|
||||
* @param aPathString is concatenated string with interposing ';' or ':' separators.
|
||||
* @return the count of paths found in \a aPathString
|
||||
*/
|
||||
static int Split( wxArrayString* aResult, const wxString& aPathString );
|
||||
|
||||
#if 1 // this function is so poorly designed it deserves not to exist.
|
||||
/**
|
||||
* Function LastVisitedPath
|
||||
* is a quirky function inherited from old code that seems to serve particular
|
||||
* needs in the UI. It returns what is called the last visited directory, or
|
||||
* if aSubPathToSearch is empty, the first path in this SEARCH_STACK
|
||||
* ( but not the CWD ).
|
||||
* A quirky function inherited from old code that seems to serve particular needs in
|
||||
* the UI.
|
||||
*
|
||||
* It returns what is called the last visited directory or if \a aSubPathToSearch is
|
||||
* empty, the first path in this SEARCH_STACK ( but not the CWD ).
|
||||
*
|
||||
* @todo add more here if you can figure it out.
|
||||
*
|
||||
* @param aSubPathToSearch is the preferred sub path to search in path list
|
||||
* @param aSubPathToSearch is the preferred sub path to search in path list.
|
||||
*/
|
||||
const wxString LastVisitedPath( const wxString& aSubPathToSearch = wxEmptyString );
|
||||
#endif
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2014-2015 CERN
|
||||
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
|
@ -36,8 +37,6 @@
|
|||
class EDA_DRAW_FRAME;
|
||||
|
||||
/**
|
||||
* STATUS_POPUP
|
||||
*
|
||||
* A tiny, headerless popup window used to display useful status (e.g. line length
|
||||
* tuning info) next to the mouse cursor.
|
||||
*/
|
||||
|
@ -54,7 +53,7 @@ public:
|
|||
virtual void Move( const VECTOR2I& aWhere );
|
||||
|
||||
/**
|
||||
* Hides the popup after a specified time.
|
||||
* Hide the popup after a specified time.
|
||||
*
|
||||
* @param aMsecs is the time expressed in milliseconds
|
||||
*/
|
||||
|
@ -75,9 +74,7 @@ protected:
|
|||
|
||||
|
||||
/**
|
||||
* STATUS_TEXT_POPUP
|
||||
*
|
||||
* Extension of STATUS_POPUP, displaying a single line text.
|
||||
* Extension of #STATUS_POPUP for displaying a single line text.
|
||||
*/
|
||||
class STATUS_TEXT_POPUP : public STATUS_POPUP
|
||||
{
|
||||
|
@ -87,12 +84,14 @@ public:
|
|||
|
||||
/**
|
||||
* Display a text.
|
||||
*
|
||||
* @param aText is the text to be displayed.
|
||||
*/
|
||||
void SetText( const wxString& aText );
|
||||
|
||||
/**
|
||||
* Change text color.
|
||||
*
|
||||
* @param aColor is the new text color.
|
||||
*/
|
||||
void SetTextColor( const wxColour& aColor );
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2017 Cirilo Bernardo <cirilo.bernardo@gmail.com>
|
||||
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
|
@ -28,90 +29,91 @@
|
|||
|
||||
|
||||
#if defined( _WIN32 ) && defined( __GNUC__ )
|
||||
#include <ext/stdio_filebuf.h>
|
||||
#include <ext/stdio_filebuf.h>
|
||||
|
||||
#define OSTREAM std::ostream
|
||||
#define OSTREAM std::ostream
|
||||
|
||||
#define OPEN_OSTREAM( var, name ) \
|
||||
kicad::stream var ## _BUF_; \
|
||||
std::ostream& var = *var ## _BUF_.Open( name, std::ios_base::out | std::ios_base::trunc | std::ios_base::binary )
|
||||
#define OPEN_OSTREAM( var, name ) \
|
||||
kicad::stream var##_BUF_; \
|
||||
std::ostream& var = *var##_BUF_.Open( name, std::ios_base::out | std::ios_base::trunc \
|
||||
| std::ios_base::binary )
|
||||
|
||||
#define OPEN_ISTREAM( var, name ) \
|
||||
kicad::stream var ## _BUF_; \
|
||||
std::istream& var = *var ## _BUF_.Open( name, std::ios_base::in | std::ios_base::binary )
|
||||
#define OPEN_ISTREAM( var, name ) \
|
||||
kicad::stream var##_BUF_; \
|
||||
std::istream& var = *var##_BUF_.Open( name, std::ios_base::in | std::ios_base::binary )
|
||||
|
||||
#define OPEN_IOSTREAM( var, name ) \
|
||||
kicad::stream var ## _BUF_; \
|
||||
std::iostream& var = *var ## _BUF_.Open( name, std::ios_base::out | std::ios_base::in | std::ios_base::binary )
|
||||
#define OPEN_IOSTREAM( var, name ) \
|
||||
kicad::stream var##_BUF_; \
|
||||
std::iostream& var = *var##_BUF_.Open( name, std::ios_base::out | std::ios_base::in \
|
||||
| std::ios_base::binary )
|
||||
|
||||
#define CLOSE_STREAM( var ) var ## _BUF_.Close()
|
||||
#define CLOSE_STREAM( var ) var##_BUF_.Close()
|
||||
|
||||
/**
|
||||
* \namespace kicad
|
||||
*/
|
||||
namespace kicad
|
||||
{
|
||||
/**
|
||||
* class stream is equivalent to std::stream, but accept UTF8 chars
|
||||
* in filenames
|
||||
*/
|
||||
class stream
|
||||
{
|
||||
private:
|
||||
__gnu_cxx::stdio_filebuf<char>* m_buf;
|
||||
std::iostream* m_stream;
|
||||
/**
|
||||
* \namespace kicad
|
||||
*/
|
||||
namespace kicad
|
||||
{
|
||||
/**
|
||||
* This is equivalent to std::stream but accepts UTF8 chars in filenames.
|
||||
*/
|
||||
class stream
|
||||
{
|
||||
private:
|
||||
__gnu_cxx::stdio_filebuf<char>* m_buf;
|
||||
std::iostream* m_stream;
|
||||
|
||||
public:
|
||||
stream();
|
||||
virtual ~stream();
|
||||
public:
|
||||
stream();
|
||||
virtual ~stream();
|
||||
|
||||
std::iostream* Open( const char* aFileName, std::ios_base::openmode aMode );
|
||||
void Close( void );
|
||||
std::iostream* Open( const char* aFileName, std::ios_base::openmode aMode );
|
||||
void Close( void );
|
||||
|
||||
std::iostream* GetStream( void );
|
||||
};
|
||||
}
|
||||
std::iostream* GetStream( void );
|
||||
};
|
||||
} // namespace kicad
|
||||
|
||||
|
||||
#elif defined( _MSC_VER ) // defined( _WIN32 ) && defined( __GNUC__ )
|
||||
#elif defined( _MSC_VER ) // defined( _WIN32 ) && defined( __GNUC__ )
|
||||
|
||||
#define OSTREAM std::ofstream
|
||||
#define OSTREAM std::ofstream
|
||||
|
||||
#define OPEN_OSTREAM( var, name ) \
|
||||
std::ofstream var; \
|
||||
var.open( wxString::FromUTF8Unchecked( name ).wc_str(), \
|
||||
std::ios_base::out | std::ios_base::trunc | std::ios_base::binary )
|
||||
#define OPEN_OSTREAM( var, name ) \
|
||||
std::ofstream var; \
|
||||
var.open( wxString::FromUTF8Unchecked( name ).wc_str(), \
|
||||
std::ios_base::out | std::ios_base::trunc | std::ios_base::binary )
|
||||
|
||||
#define OPEN_ISTREAM( var, name ) \
|
||||
std::ifstream var; \
|
||||
var.open( wxString::FromUTF8Unchecked( name ).wc_str(), \
|
||||
std::ios_base::in | std::ios_base::binary )
|
||||
#define OPEN_ISTREAM( var, name ) \
|
||||
std::ifstream var; \
|
||||
var.open( wxString::FromUTF8Unchecked( name ).wc_str(), \
|
||||
std::ios_base::in | std::ios_base::binary )
|
||||
|
||||
#define OPEN_IOSTREAM( var, name ) \
|
||||
std::fstream var; \
|
||||
var.open( wxString::FromUTF8Unchecked( name ).wc_str(), \
|
||||
std::ios_base::out | std::ios_base::in | std::ios_base::binary )
|
||||
#define OPEN_IOSTREAM( var, name ) \
|
||||
std::fstream var; \
|
||||
var.open( wxString::FromUTF8Unchecked( name ).wc_str(), \
|
||||
std::ios_base::out | std::ios_base::in | std::ios_base::binary )
|
||||
|
||||
#define CLOSE_STREAM( var ) var.close()
|
||||
#define CLOSE_STREAM( var ) var.close()
|
||||
|
||||
#else // defined( _WIN32 ) && defined( __GNUC__ )
|
||||
#else // defined( _WIN32 ) && defined( __GNUC__ )
|
||||
|
||||
#define OSTREAM std::ofstream
|
||||
#define OSTREAM std::ofstream
|
||||
|
||||
#define OPEN_OSTREAM( var, name ) \
|
||||
std::ofstream var; \
|
||||
var.open( name, std::ios_base::out | std::ios_base::trunc )
|
||||
#define OPEN_OSTREAM( var, name ) \
|
||||
std::ofstream var; \
|
||||
var.open( name, std::ios_base::out | std::ios_base::trunc )
|
||||
|
||||
#define OPEN_ISTREAM( var, name ) \
|
||||
std::ifstream var; \
|
||||
var.open( name, std::ios_base::in )
|
||||
#define OPEN_ISTREAM( var, name ) \
|
||||
std::ifstream var; \
|
||||
var.open( name, std::ios_base::in )
|
||||
|
||||
#define OPEN_IOSTREAM( var, name ) \
|
||||
std::fstream var; \
|
||||
var.open( name, std::ios_base::out | std::ios_base::in )
|
||||
#define OPEN_IOSTREAM( var, name ) \
|
||||
std::fstream var; \
|
||||
var.open( name, std::ios_base::out | std::ios_base::in )
|
||||
|
||||
#define CLOSE_STREAM( var ) var.close()
|
||||
#define CLOSE_STREAM( var ) var.close()
|
||||
|
||||
#endif // defined( _WIN32 ) && defined( __GNUC__ )
|
||||
#endif // defined( _WIN32 ) && defined( __GNUC__ )
|
||||
|
||||
#endif // STREAMWRAPPER_H
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2017 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2017-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
|
@ -27,13 +27,9 @@
|
|||
* Synchronized, locking queue. Safe for multiple producer/multiple consumer environments with
|
||||
* nontrivial data (though bear in mind data needs to be copied in and out).
|
||||
*/
|
||||
template <typename T> class SYNC_QUEUE
|
||||
template <typename T>
|
||||
class SYNC_QUEUE
|
||||
{
|
||||
typedef std::lock_guard<std::mutex> GUARD;
|
||||
|
||||
std::queue<T> m_queue;
|
||||
mutable std::mutex m_mutex;
|
||||
|
||||
public:
|
||||
SYNC_QUEUE()
|
||||
{
|
||||
|
@ -58,10 +54,11 @@ public:
|
|||
}
|
||||
|
||||
/**
|
||||
* Pop a value off the queue into the provided variable. If the queue is empty, the
|
||||
* variable is not touched.
|
||||
* Pop a value if the queue into the provided variable.
|
||||
*
|
||||
* @return true iff a value was popped.
|
||||
* If the queue is empty, the variable is not touched.
|
||||
*
|
||||
* @return true if a value was popped.
|
||||
*/
|
||||
bool pop( T& aReceiver )
|
||||
{
|
||||
|
@ -80,7 +77,7 @@ public:
|
|||
}
|
||||
|
||||
/**
|
||||
* Return true iff the queue is empty.
|
||||
* Return true if the queue is empty.
|
||||
*/
|
||||
bool empty() const
|
||||
{
|
||||
|
@ -109,6 +106,12 @@ public:
|
|||
m_queue.pop();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
typedef std::lock_guard<std::mutex> GUARD;
|
||||
|
||||
std::queue<T> m_queue;
|
||||
mutable std::mutex m_mutex;
|
||||
};
|
||||
|
||||
#endif // SYNC_QUEUE_H
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2017 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2017-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -32,10 +32,8 @@
|
|||
class SEARCH_STACK;
|
||||
|
||||
/**
|
||||
* Function SystemDirsAppend
|
||||
* appends system places to aSearchStack in a platform specific way, and pertinent
|
||||
* to KiCad programs. It seems to be a place to collect bad ideas and keep them
|
||||
* out of view.
|
||||
* Append system places to \a aSearchStack in a platform specific way and pertinent
|
||||
* to KiCad programs.
|
||||
*/
|
||||
void SystemDirsAppend( SEARCH_STACK* aSearchStack );
|
||||
|
||||
|
|
|
@ -33,12 +33,11 @@ class TEMPLATE_FIELDNAMES_LEXER;
|
|||
|
||||
|
||||
/**
|
||||
* Enum NumFieldType
|
||||
* is the set of all field indices assuming an array like sequence that a
|
||||
* SCH_COMPONENT or LIB_PART can hold.
|
||||
* The first fields are called fixed fields and the quantity of them is
|
||||
* given by MANDATORY_FIELDS. After that come an unlimited number of
|
||||
* user defined fields, only some of which have indices defined here.
|
||||
* The set of all field indices assuming an array like sequence that a SCH_COMPONENT or
|
||||
* LIB_PART can hold.
|
||||
*
|
||||
* The first fields are fixed fields and are defined by #MANDATORY_FIELDS. After that come
|
||||
* an unlimited number of user defined fields, only some of which have indices defined here.
|
||||
*/
|
||||
enum NumFieldType {
|
||||
REFERENCE_FIELD = 0, ///< Field Reference of part, i.e. "IC21"
|
||||
|
@ -62,17 +61,12 @@ enum NumFieldType {
|
|||
|
||||
|
||||
/**
|
||||
* Struct TEMPLATE_FIELDNAME
|
||||
* holds a name of a component's field, field value, and default visibility.
|
||||
* Template fieldnames are wanted fieldnames for use in the symbol/component
|
||||
* property editors.
|
||||
* Hold a name of a symbol's field, field value, and default visibility.
|
||||
*
|
||||
* Template fieldnames are wanted field names for use in the symbol property editors.
|
||||
*/
|
||||
struct TEMPLATE_FIELDNAME
|
||||
{
|
||||
wxString m_Name; // The field name
|
||||
bool m_Visible; // Field defaults to being visible in schematic.
|
||||
bool m_URL; // If field should have a browse button
|
||||
|
||||
TEMPLATE_FIELDNAME() :
|
||||
m_Visible( false ),
|
||||
m_URL( false )
|
||||
|
@ -94,34 +88,37 @@ struct TEMPLATE_FIELDNAME
|
|||
}
|
||||
|
||||
/**
|
||||
* Function Format
|
||||
* serializes this object out as text into the given OUTPUTFORMATTER.
|
||||
* Serialize this object out as text into the given #OUTPUTFORMATTER.
|
||||
*/
|
||||
void Format( OUTPUTFORMATTER* out, int nestLevel ) const ;
|
||||
|
||||
/**
|
||||
* Function Parse
|
||||
* fills this object from information in the input stream \a aSpec, which
|
||||
* is a TEMPLATE_FIELDNAMES_LEXER. The entire textual element spec is <br>
|
||||
* (field (name _yourfieldname_)(value _yourvalue_) visible)) <br>
|
||||
* The presence of value is optional, the presence of visible is optional.
|
||||
* When this function is called, the input token stream given by \a aSpec
|
||||
* is assumed to be positioned at the '^' in the following example, i.e. just after the
|
||||
* identifying keyword and before the content specifying stuff.<br>
|
||||
* (field ^ (....) )
|
||||
* Fill this object from information in the input stream \a aSpec, which is a
|
||||
* #TEMPLATE_FIELDNAMES_LEXER.
|
||||
*
|
||||
* The entire textual element spec is <br>(field (name _yourfieldname_)(value _yourvalue_)
|
||||
* visible))</br>. The presence of value is optional, the presence of visible is optional.
|
||||
* When this function is called, the input token stream given by \a aSpec is assumed to be
|
||||
* positioned at the '^' in the following example, i.e. just after the identifying keyword
|
||||
* and before the content specifying stuff.<br>(field ^ (....) )</br>.
|
||||
*
|
||||
* @param aSpec is the input token stream of keywords and symbols.
|
||||
*/
|
||||
void Parse( TEMPLATE_FIELDNAMES_LEXER* aSpec );
|
||||
|
||||
/**
|
||||
* Function GetDefaultFieldName
|
||||
* returns a default symbol field name for field \a aFieldNdx for all components.
|
||||
* These fieldnames are not modifiable, but template fieldnames are.
|
||||
* @param aFieldNdx The field number index, > 0
|
||||
* @param aTranslate If true, return the translated field name, else get the canonical name
|
||||
* Return a default symbol field name for field \a aFieldNdx for all components.
|
||||
*
|
||||
* These field names are not modifiable but template field names are.
|
||||
*
|
||||
* @param aFieldNdx The field number index, > 0.
|
||||
* @param aTranslate If true, return the translated field name, else get the canonical name.
|
||||
*/
|
||||
static const wxString GetDefaultFieldName( int aFieldNdx, bool aTranslate = true );
|
||||
|
||||
wxString m_Name; // The field name
|
||||
bool m_Visible; // Field defaults to being visible in schematic.
|
||||
bool m_URL; // If field should have a browse button
|
||||
};
|
||||
|
||||
typedef std::vector< TEMPLATE_FIELDNAME > TEMPLATE_FIELDNAMES;
|
||||
|
@ -129,6 +126,61 @@ typedef std::vector< TEMPLATE_FIELDNAME > TEMPLATE_FIELDNAMES;
|
|||
|
||||
class TEMPLATES
|
||||
{
|
||||
public:
|
||||
TEMPLATES() :
|
||||
m_resolvedDirty( true )
|
||||
{ }
|
||||
|
||||
/**
|
||||
* Serialize this object out as text into the given #OUTPUTFORMATTER.
|
||||
*/
|
||||
void Format( OUTPUTFORMATTER* out, int nestLevel, bool aGlobal ) const ;
|
||||
|
||||
/**
|
||||
* Fill this object from information in the input stream handled by
|
||||
* #TEMPLATE_FIELDNAMES_LEXER.
|
||||
*/
|
||||
void Parse( TEMPLATE_FIELDNAMES_LEXER* in, bool aGlobal );
|
||||
|
||||
|
||||
/**
|
||||
* Insert or append a wanted symbol field name into the field names template.
|
||||
*
|
||||
* Should be used for any symbol property editor. If the name already exists, it
|
||||
* overwrites the same name.
|
||||
*
|
||||
* @param aFieldName is a full description of the wanted field, and it must not match
|
||||
* any of the default field names.
|
||||
* @param aGlobal indicates whether to add to the global or project table.
|
||||
*/
|
||||
void AddTemplateFieldName( const TEMPLATE_FIELDNAME& aFieldName, bool aGlobal );
|
||||
|
||||
/**
|
||||
* Delete the entire contents.
|
||||
*/
|
||||
void DeleteAllFieldNameTemplates( bool aGlobal );
|
||||
|
||||
/**
|
||||
* Return a template field name list for read only access.
|
||||
*/
|
||||
const TEMPLATE_FIELDNAMES& GetTemplateFieldNames();
|
||||
|
||||
/**
|
||||
* Return a specific list (global or project) for read only access.
|
||||
*/
|
||||
const TEMPLATE_FIELDNAMES& GetTemplateFieldNames( bool aGlobal );
|
||||
|
||||
/**
|
||||
* Search for \a aName in the the template field name list.
|
||||
*
|
||||
* @param aName A wxString object containing the field name to search for.
|
||||
* @return the template field name if found; NULL otherwise.
|
||||
*/
|
||||
const TEMPLATE_FIELDNAME* GetFieldName( const wxString& aName );
|
||||
|
||||
protected:
|
||||
void resolveTemplates();
|
||||
|
||||
private:
|
||||
TEMPLATE_FIELDNAMES m_globals;
|
||||
TEMPLATE_FIELDNAMES m_project;
|
||||
|
@ -136,67 +188,6 @@ private:
|
|||
// Combined list. Project templates override global ones.
|
||||
TEMPLATE_FIELDNAMES m_resolved;
|
||||
bool m_resolvedDirty;
|
||||
|
||||
public:
|
||||
TEMPLATES() :
|
||||
m_resolvedDirty( true )
|
||||
{ }
|
||||
|
||||
/**
|
||||
* Function Format
|
||||
* serializes this object out as text into the given OUTPUTFORMATTER.
|
||||
*/
|
||||
void Format( OUTPUTFORMATTER* out, int nestLevel, bool aGlobal ) const ;
|
||||
|
||||
/**
|
||||
* Function Parse
|
||||
* fills this object from information in the input stream handled by TEMPLATE_FIELDNAMES_LEXER
|
||||
*/
|
||||
void Parse( TEMPLATE_FIELDNAMES_LEXER* in, bool aGlobal );
|
||||
|
||||
|
||||
/**
|
||||
* Function AddTemplateFieldName
|
||||
* inserts or appends a wanted symbol field name into the fieldnames
|
||||
* template. Should be used for any symbol property editor. If the name
|
||||
* already exists, it overwrites the same name.
|
||||
*
|
||||
* @param aFieldName is a full description of the wanted field, and it must not match
|
||||
* any of the default fieldnames.
|
||||
* @param aGlobal indicates whether to add to the global or project table.
|
||||
*/
|
||||
void AddTemplateFieldName( const TEMPLATE_FIELDNAME& aFieldName, bool aGlobal );
|
||||
|
||||
/**
|
||||
* Function DeleteAllFieldNameTemplates
|
||||
* deletes the entire contents.
|
||||
*/
|
||||
void DeleteAllFieldNameTemplates( bool aGlobal );
|
||||
|
||||
/**
|
||||
* Function GetTemplateFieldName
|
||||
* returns a template fieldnames list for read only access.
|
||||
*/
|
||||
const TEMPLATE_FIELDNAMES& GetTemplateFieldNames();
|
||||
|
||||
/**
|
||||
* Function GetTemplateFieldName
|
||||
* returns a specific list (global or project) for read only access.
|
||||
*/
|
||||
const TEMPLATE_FIELDNAMES& GetTemplateFieldNames( bool aGlobal );
|
||||
|
||||
/**
|
||||
* Function GetFieldName
|
||||
* searches for \a aName in the the template field name list.
|
||||
*
|
||||
* @param aName A wxString object containing the field name to search for.
|
||||
* @return the template fieldname if found; NULL otherwise.
|
||||
*/
|
||||
const TEMPLATE_FIELDNAME* GetFieldName( const wxString& aName );
|
||||
|
||||
protected:
|
||||
void resolveTemplates();
|
||||
|
||||
};
|
||||
|
||||
#endif // _TEMPLATE_FIELDNAME_H_
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2020 KiCad Developers, see change_log.txt for contributors.
|
||||
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -28,9 +28,9 @@
|
|||
#include <wx/textentry.h>
|
||||
|
||||
/**
|
||||
* TEXTENTRY_TRICKS
|
||||
* is used to add cut/copy/paste to a wxTextEntry instance. While these are normally handled
|
||||
* witout our intervention, this is not always the case.
|
||||
* Add cut/copy/paste to a wxTextEntry instance.
|
||||
*
|
||||
* While these are normally handled without our intervention, this is not always the case.
|
||||
*/
|
||||
struct TEXTENTRY_TRICKS
|
||||
{
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 1992-2012 KiCad Developers, see change_log.txt for contributors.
|
||||
* Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -31,8 +31,7 @@
|
|||
class OUTPUTFORMATTER;
|
||||
|
||||
/**
|
||||
* TITLE_BLOCK
|
||||
* holds the information shown in the lower right corner of a plot, printout, or
|
||||
* Hold the information shown in the lower right corner of a plot, printout, or
|
||||
* editing view.
|
||||
*
|
||||
* @author Dick Hollenbeck
|
||||
|
@ -52,7 +51,6 @@ class TITLE_BLOCK
|
|||
};
|
||||
|
||||
public:
|
||||
|
||||
TITLE_BLOCK() {};
|
||||
virtual ~TITLE_BLOCK() {}; // a virtual dtor seems needed to build
|
||||
// python lib without warning
|
||||
|
@ -68,8 +66,7 @@ public:
|
|||
}
|
||||
|
||||
/**
|
||||
* Function SetDate
|
||||
* sets the date field, and defaults to the current time and date.
|
||||
* Set the date field, and defaults to the current time and date.
|
||||
*/
|
||||
void SetDate( const wxString& aDate )
|
||||
{
|
||||
|
@ -119,8 +116,7 @@ public:
|
|||
}
|
||||
|
||||
/**
|
||||
* Function Format
|
||||
* outputs the object to \a aFormatter in s-expression form.
|
||||
* Output the object to \a aFormatter in s-expression form.
|
||||
*
|
||||
* @param aFormatter The #OUTPUTFORMATTER object to write to.
|
||||
* @param aNestLevel The indentation next level.
|
||||
|
@ -136,6 +132,7 @@ private:
|
|||
{
|
||||
if( (int)m_tbTexts.GetCount() <= aIdx )
|
||||
m_tbTexts.Add( wxEmptyString, aIdx + 1 - m_tbTexts.GetCount() );
|
||||
|
||||
m_tbTexts[aIdx] = aText;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2009 jean-pierre.charras@gipsa-lab.inpg.fr
|
||||
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
|
||||
* Copyright (C) 2009 KiCad Developers, see change_log.txt for contributors.
|
||||
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@gmail.com>
|
||||
* Copyright (C) 2009-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -47,8 +47,10 @@ class BASE_SCREEN;
|
|||
*/
|
||||
|
||||
|
||||
/* Type of undo/redo operations
|
||||
* each type must be redo/undone by a specific operation
|
||||
/**
|
||||
* Type of undo/redo operations
|
||||
*
|
||||
* Each type must be redo/undone by a specific operation.
|
||||
*/
|
||||
enum class UNDO_REDO {
|
||||
UNSPECIFIED = 0, // illegal
|
||||
|
@ -77,29 +79,11 @@ enum class UNDO_REDO {
|
|||
|
||||
class ITEM_PICKER
|
||||
{
|
||||
private:
|
||||
STATUS_FLAGS m_pickerFlags; /* a copy of m_flags member. useful in mode/drag
|
||||
* undo/redo commands */
|
||||
UNDO_REDO m_undoRedoStatus; /* type of operation to undo/redo for this item */
|
||||
EDA_ITEM* m_pickedItem; /* Pointer on the schematic or board item that is concerned
|
||||
* (picked), or in undo redo commands, the copy of an
|
||||
* edited item. */
|
||||
KICAD_T m_pickedItemType; /* type of schematic or board item that is concerned */
|
||||
|
||||
EDA_ITEM* m_link; /* Pointer on another item. Used in undo redo command
|
||||
* used when a duplicate exists i.e. when an item is
|
||||
* modified, and the copy of initial item exists (the
|
||||
* duplicate) m_Item points the duplicate (i.e the old
|
||||
* copy of an active item) and m_Link points the active
|
||||
* item in schematic */
|
||||
|
||||
BASE_SCREEN* m_screen; /* For new and deleted items the screen the item should
|
||||
* be added to/removed from. */
|
||||
|
||||
public:
|
||||
// ITEM_PICKER( EDA_ITEM* aItem = NULL, UNDO_REDO aStatus = UNSPECIFIED );
|
||||
ITEM_PICKER();
|
||||
ITEM_PICKER( BASE_SCREEN* aScreen, EDA_ITEM* aItem, UNDO_REDO aStatus = UNDO_REDO::UNSPECIFIED );
|
||||
ITEM_PICKER( BASE_SCREEN* aScreen, EDA_ITEM* aItem,
|
||||
UNDO_REDO aStatus = UNDO_REDO::UNSPECIFIED );
|
||||
|
||||
EDA_ITEM* GetItem() const { return m_pickedItem; }
|
||||
|
||||
|
@ -124,21 +108,41 @@ public:
|
|||
EDA_ITEM* GetLink() const { return m_link; }
|
||||
|
||||
BASE_SCREEN* GetScreen() const { return m_screen; }
|
||||
|
||||
private:
|
||||
STATUS_FLAGS m_pickerFlags; /* a copy of m_flags member. useful in mode/drag
|
||||
* undo/redo commands */
|
||||
UNDO_REDO m_undoRedoStatus; /* type of operation to undo/redo for this item */
|
||||
EDA_ITEM* m_pickedItem; /* Pointer on the schematic or board item that is concerned
|
||||
* (picked), or in undo redo commands, the copy of an
|
||||
* edited item. */
|
||||
KICAD_T m_pickedItemType; /* type of schematic or board item that is concerned */
|
||||
|
||||
EDA_ITEM* m_link; /* Pointer on another item. Used in undo redo command
|
||||
* used when a duplicate exists i.e. when an item is
|
||||
* modified, and the copy of initial item exists (the
|
||||
* duplicate) m_Item points the duplicate (i.e the old
|
||||
* copy of an active item) and m_Link points the active
|
||||
* item in schematic */
|
||||
|
||||
BASE_SCREEN* m_screen; /* For new and deleted items the screen the item should
|
||||
* be added to/removed from. */
|
||||
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* PICKED_ITEMS_LIST
|
||||
* is a holder to handle information on schematic or board items.
|
||||
* A holder to handle information on schematic or board items.
|
||||
*
|
||||
* The information held is a pointer on each item, and the command made.
|
||||
*/
|
||||
class PICKED_ITEMS_LIST
|
||||
{
|
||||
public:
|
||||
UNDO_REDO m_Status; /* info about operation to undo/redo for this item. can be
|
||||
* UNSPECIFIED */
|
||||
wxPoint m_TransformPoint; /* used to undo redo command by the same command: usually
|
||||
* need to know the rotate point or the move vector */
|
||||
* UNSPECIFIED */
|
||||
wxPoint m_TransformPoint; /* used to undo redo command by the same command: usually
|
||||
* need to know the rotate point or the move vector */
|
||||
|
||||
private:
|
||||
std::vector <ITEM_PICKER> m_ItemsList;
|
||||
|
@ -148,46 +152,40 @@ public:
|
|||
~PICKED_ITEMS_LIST();
|
||||
|
||||
/**
|
||||
* Function PushItem
|
||||
* pushes \a aItem to the top of the list
|
||||
* Push \a aItem to the top of the list.
|
||||
*
|
||||
* @param aItem Picker to push on to the list.
|
||||
*/
|
||||
void PushItem( const ITEM_PICKER& aItem );
|
||||
|
||||
/**
|
||||
* Function PopItem
|
||||
* @return The picker removed from the top of the list.
|
||||
*/
|
||||
ITEM_PICKER PopItem();
|
||||
|
||||
/**
|
||||
* Function IsItemInList
|
||||
* @return True if \a aItem is found in the pick list.
|
||||
*/
|
||||
bool ContainsItem( const EDA_ITEM* aItem ) const;
|
||||
|
||||
/**
|
||||
* Function FindItem
|
||||
* @return Index of the searched item. If the item is not stored in the list, negative value
|
||||
* is returned.
|
||||
* is returned.
|
||||
*/
|
||||
int FindItem( const EDA_ITEM* aItem ) const;
|
||||
|
||||
/**
|
||||
* Function ClearItemsList
|
||||
* deletes only the list of pickers, NOT the picked data itself.
|
||||
* Delete only the list of pickers NOT the picked data itself.
|
||||
*/
|
||||
void ClearItemsList();
|
||||
|
||||
/**
|
||||
* Function ClearListAndDeleteItems
|
||||
* deletes the list of pickers, AND the data pointed by m_PickedItem or
|
||||
* m_PickedItemLink, according to the type of undo/redo command recorded
|
||||
* Delete the list of pickers AND the data pointed by #m_PickedItem or #m_PickedItemLink
|
||||
* according to the type of undo/redo command recorded.
|
||||
*/
|
||||
void ClearListAndDeleteItems();
|
||||
|
||||
/**
|
||||
* Function GetCount
|
||||
* @return The count of pickers stored in this list.
|
||||
*/
|
||||
unsigned GetCount() const
|
||||
|
@ -196,9 +194,8 @@ public:
|
|||
}
|
||||
|
||||
/**
|
||||
* Function ReversePickersListOrder
|
||||
* reverses the order of pickers stored in this list.
|
||||
* <p>
|
||||
* Reverse the order of pickers stored in this list.
|
||||
*
|
||||
* This is useful when pop a list from Undo to Redo (and vice-versa) because
|
||||
* sometimes undo (or redo) a command needs to keep the order of successive
|
||||
* changes. Obviously, undo and redo are in reverse order
|
||||
|
@ -206,80 +203,72 @@ public:
|
|||
void ReversePickersListOrder();
|
||||
|
||||
/**
|
||||
* Function GetItemWrapper
|
||||
* @return The picker of a picked item.
|
||||
* @param aIdx Index of the picker in the picked list
|
||||
* if this picker does not exist, a picker is returned,
|
||||
* with its members set to 0 or NULL
|
||||
* @param aIdx Index of the picker in the picked list if this picker does not exist,
|
||||
* a picker is returned, with its members set to 0 or NULL.
|
||||
*/
|
||||
ITEM_PICKER GetItemWrapper( unsigned int aIdx ) const;
|
||||
|
||||
/**
|
||||
* Function GetPickedItem
|
||||
* @return A pointer to the picked item
|
||||
* @param aIdx Index of the picked item in the picked list
|
||||
* @return A pointer to the picked item.
|
||||
* @param aIdx Index of the picked item in the picked list.
|
||||
*/
|
||||
EDA_ITEM* GetPickedItem( unsigned int aIdx ) const;
|
||||
|
||||
/**
|
||||
* Function GetScreenForItem
|
||||
* @return A pointer to the picked item's sceen
|
||||
* @param aIdx Index of the picked item in the picked list
|
||||
* @return A pointer to the picked item's sceen.
|
||||
* @param aIdx Index of the picked item in the picked list.
|
||||
*/
|
||||
BASE_SCREEN* GetScreenForItem( unsigned int aIdx ) const;
|
||||
|
||||
/**
|
||||
* Function GetPickedItemLink
|
||||
* @return link of the picked item, or null if does not exist
|
||||
* @param aIdx Index of the picked item in the picked list
|
||||
* @return link of the picked item, or null if does not exist.
|
||||
* @param aIdx Index of the picked item in the picked list.
|
||||
*/
|
||||
EDA_ITEM* GetPickedItemLink( unsigned int aIdx ) const;
|
||||
|
||||
/**
|
||||
* Function GetPickedItemStatus
|
||||
* @return The type of undo/redo operation associated to the picked item,
|
||||
* or UNSPECIFIED if does not exist
|
||||
* @param aIdx Index of the picked item in the picked list
|
||||
* or UNSPECIFIED if does not exist.
|
||||
* @param aIdx Index of the picked item in the picked list.
|
||||
*/
|
||||
UNDO_REDO GetPickedItemStatus( unsigned int aIdx ) const;
|
||||
|
||||
/**
|
||||
* Function GetPickerFlags
|
||||
* returns the value of the picker flag.
|
||||
* @param aIdx Index of the picker in the picked list
|
||||
* @return The value stored in the picker, if the picker exists, or 0 if does not exist
|
||||
* Return the value of the picker flag.
|
||||
*
|
||||
* @param aIdx Index of the picker in the picked list.
|
||||
* @return The value stored in the picker, if the picker exists, or 0 if does not exist.
|
||||
*/
|
||||
STATUS_FLAGS GetPickerFlags( unsigned aIdx ) const;
|
||||
|
||||
/**
|
||||
* Function SetPickedItem
|
||||
* @param aItem A pointer to the item to pick
|
||||
* @param aIdx Index of the picker in the picked list
|
||||
* @return True if the picker exists or false if does not exist
|
||||
* @param aItem A pointer to the item to pick.
|
||||
* @param aIdx Index of the picker in the picked list.
|
||||
* @return True if the picker exists or false if does not exist.
|
||||
*/
|
||||
bool SetPickedItem( EDA_ITEM* aItem, unsigned aIdx );
|
||||
|
||||
/**
|
||||
* Function SetPickedItem
|
||||
* @param aItem A pointer to the item to pick
|
||||
* @param aStatus The type of undo/redo operation associated to the item to pick
|
||||
* @param aIdx Index of the picker in the picked list
|
||||
* @return True if the picker exists or false if does not exist
|
||||
* @param aItem A pointer to the item to pick.
|
||||
* @param aStatus The type of undo/redo operation associated to the item to pick.
|
||||
* @param aIdx Index of the picker in the picked list.
|
||||
* @return True if the picker exists or false if does not exist.
|
||||
*/
|
||||
bool SetPickedItem( EDA_ITEM* aItem, UNDO_REDO aStatus, unsigned aIdx );
|
||||
|
||||
/**
|
||||
* Function SetPickedItemLink
|
||||
* set the link associated to a given picked item.
|
||||
* @param aLink = the link to the item associated to the picked item
|
||||
* @param aIdx = index of the picker in the picked list
|
||||
* @return true if the picker exists, or false if does not exist
|
||||
* Set the link associated to a given picked item.
|
||||
*
|
||||
* @param aLink is the link to the item associated to the picked item.
|
||||
* @param aIdx is index of the picker in the picked list.
|
||||
* @return true if the picker exists, or false if does not exist.
|
||||
*/
|
||||
bool SetPickedItemLink( EDA_ITEM* aLink, unsigned aIdx );
|
||||
|
||||
/**
|
||||
* Function SetPickedItemStatus
|
||||
* sets the type of undo/redo operation for a given picked item.
|
||||
* Set the type of undo/redo operation for a given picked item.
|
||||
*
|
||||
* @param aStatus The type of undo/redo operation associated to the picked item
|
||||
* @param aIdx Index of the picker in the picked list
|
||||
* @return True if the picker exists or false if does not exist
|
||||
|
@ -287,26 +276,27 @@ public:
|
|||
bool SetPickedItemStatus( UNDO_REDO aStatus, unsigned aIdx );
|
||||
|
||||
/**
|
||||
* Function SetPickerFlags
|
||||
* set the flags of the picker (usually to the picked item m_flags value)
|
||||
* @param aFlags The flag value to save in picker
|
||||
* @param aIdx Index of the picker in the picked list
|
||||
* @return True if the picker exists or false if does not exist
|
||||
* Set the flags of the picker (usually to the picked item m_flags value).
|
||||
*
|
||||
* @param aFlags The flag value to save in picker.
|
||||
* @param aIdx Index of the picker in the picked list.
|
||||
* @return True if the picker exists or false if does not exist.
|
||||
*/
|
||||
bool SetPickerFlags( STATUS_FLAGS aFlags, unsigned aIdx );
|
||||
|
||||
/**
|
||||
* Function RemovePicker
|
||||
* removes one entry (one picker) from the list of picked items.
|
||||
* @param aIdx Index of the picker in the picked list
|
||||
* @return True if ok or false if did not exist
|
||||
* Remove one entry (one picker) from the list of picked items.
|
||||
*
|
||||
* @param aIdx Index of the picker in the picked list.
|
||||
* @return True if ok or false if did not exist.
|
||||
*/
|
||||
bool RemovePicker( unsigned aIdx );
|
||||
|
||||
/**
|
||||
* Function CopyList
|
||||
* copies all data from aSource to the list.
|
||||
* Items picked are not copied. just pointer in them are copied
|
||||
* Copy all data from aSource to the list.
|
||||
*
|
||||
* Items picked are not copied. just pointer in them are copied.
|
||||
*
|
||||
* @param aSource The list of items to copy to the list.
|
||||
*/
|
||||
void CopyList( const PICKED_ITEMS_LIST& aSource );
|
||||
|
@ -314,17 +304,11 @@ public:
|
|||
|
||||
|
||||
/**
|
||||
* UNDO_REDO_CONTAINER
|
||||
* is a holder to handle alist of undo (or redo) command.
|
||||
* this class handles a list of ITEM_PICKER (each manage one schematic or board item).
|
||||
* A holder to handle a list of undo (or redo) commands.
|
||||
*/
|
||||
class UNDO_REDO_CONTAINER
|
||||
{
|
||||
public:
|
||||
std::vector <PICKED_ITEMS_LIST*> m_CommandsList; // the list of possible undo/redo commands
|
||||
|
||||
public:
|
||||
|
||||
UNDO_REDO_CONTAINER();
|
||||
~UNDO_REDO_CONTAINER();
|
||||
|
||||
|
@ -333,6 +317,8 @@ public:
|
|||
PICKED_ITEMS_LIST* PopCommand();
|
||||
|
||||
void ClearCommandList();
|
||||
|
||||
std::vector <PICKED_ITEMS_LIST*> m_CommandsList; // the list of possible undo/redo commands
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -2,7 +2,9 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2013 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
||||
* Copyright (C) 2013 KiCad Developers, see CHANGELOG.TXT for contributors.
|
||||
* Copyright (C) 2013-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* @author Dick Hollenbeck
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -34,9 +36,9 @@
|
|||
|
||||
|
||||
/**
|
||||
* Function IsUTF8
|
||||
* tests a c-string to see if it is UTF8 encoded. BTW an ASCII string is a valid
|
||||
* UTF8 string.
|
||||
* Test a C string to see if it is UTF8 encoded.
|
||||
*
|
||||
* An ASCII string is a valid UTF8 string.
|
||||
*/
|
||||
bool IsUTF8( const char* aString );
|
||||
|
||||
|
@ -49,31 +51,25 @@ bool IsUTF8( const char* aString );
|
|||
|
||||
|
||||
/**
|
||||
* UTF8
|
||||
* is an 8 bit string that is assuredly encoded in UTF8, and supplies special
|
||||
* conversion support to and from wxString, to and from std::string, and has
|
||||
* non-mutating iteration over unicode characters.
|
||||
* An 8 bit string that is assuredly encoded in UTF8, and supplies special conversion
|
||||
* support to and from wxString, to and from std::string, and has non-mutating iteration
|
||||
* over Unicode characters.
|
||||
*
|
||||
* <p>I've been careful to supply only conversion facilities and not try
|
||||
* and duplicate wxString() with many member functions. There are multiple ways
|
||||
* to create text into a std::string without the need of too many member functions:
|
||||
* I've been careful to supply only conversion facilities and not try and duplicate
|
||||
* wxString() with many member functions. There are multiple ways to create text into
|
||||
* a std::string without the need of too many member functions:
|
||||
*
|
||||
* <ul>
|
||||
* <li>richio.h's StrPrintf()</li>
|
||||
* <li>std::ostringstream.</li>
|
||||
* </ul>
|
||||
* - richio.h's StrPrintf().
|
||||
* - std::ostringstream.
|
||||
*
|
||||
* <p>Because this class used no virtuals, it should be possible to cast any
|
||||
* std::string into a UTF8 using this kind of cast: (UTF8 &) without construction
|
||||
* or copying being the effect of the cast. Be sure the source std::string holds
|
||||
* UTF8 encoded text before you do that.
|
||||
*
|
||||
* @author Dick Hollenbeck
|
||||
* Because this class uses no virtuals, it should be possible to cast any std::string
|
||||
* into a UTF8 using this kind of cast: (UTF8 &) without construction or copying being
|
||||
* the effect of the cast. Be sure the source std::string holds UTF8 encoded text before
|
||||
* you do that.
|
||||
*/
|
||||
class UTF8
|
||||
{
|
||||
public:
|
||||
|
||||
UTF8( const wxString& o );
|
||||
|
||||
/// This is a constructor for which you could end up with
|
||||
|
@ -103,7 +99,6 @@ public:
|
|||
}
|
||||
|
||||
// expose some std::string functions publicly, since base class must be private.
|
||||
|
||||
const char* c_str() const { return m_s.c_str(); }
|
||||
bool empty() const { return m_s.empty(); }
|
||||
|
||||
|
@ -119,7 +114,8 @@ public:
|
|||
bool operator==( const std::string& rhs ) const { return m_s == rhs; }
|
||||
bool operator==( const char* s ) const { return m_s == s; }
|
||||
|
||||
std::string::size_type find_first_of( const std::string& str, std::string::size_type pos = 0 ) const
|
||||
std::string::size_type find_first_of( const std::string& str,
|
||||
std::string::size_type pos = 0 ) const
|
||||
{
|
||||
return m_s.find_first_of( str, pos );
|
||||
}
|
||||
|
@ -206,19 +202,7 @@ public:
|
|||
*/
|
||||
class uni_iter
|
||||
{
|
||||
friend class UTF8;
|
||||
|
||||
const unsigned char* it;
|
||||
|
||||
// private constructor
|
||||
uni_iter( const char* start ) :
|
||||
it( (const unsigned char*) start )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
public:
|
||||
|
||||
uni_iter() // Needed only to build python wrapper, not used outside the wrapper
|
||||
{
|
||||
it = NULL;
|
||||
|
@ -276,11 +260,21 @@ public:
|
|||
bool operator<=( const uni_iter& other ) const { return it <= other.it; }
|
||||
bool operator> ( const uni_iter& other ) const { return it > other.it; }
|
||||
bool operator>=( const uni_iter& other ) const { return it >= other.it; }
|
||||
|
||||
private:
|
||||
friend class UTF8;
|
||||
|
||||
const unsigned char* it;
|
||||
|
||||
// private constructor
|
||||
uni_iter( const char* start ) :
|
||||
it( (const unsigned char*) start )
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Function ubegin
|
||||
* returns a @a uni_iter initialized to the start of "this" UTF8 byte sequence.
|
||||
* Returns a @a uni_iter initialized to the start of "this" UTF8 byte sequence.
|
||||
*/
|
||||
uni_iter ubegin() const
|
||||
{
|
||||
|
@ -288,8 +282,7 @@ public:
|
|||
}
|
||||
|
||||
/**
|
||||
* Function uend
|
||||
* returns a @a uni_iter initialized to the end of "this" UTF8 byte sequence.
|
||||
* Return a @a uni_iter initialized to the end of "this" UTF8 byte sequence.
|
||||
*/
|
||||
uni_iter uend() const
|
||||
{
|
||||
|
@ -297,13 +290,12 @@ public:
|
|||
}
|
||||
|
||||
/**
|
||||
* Function uni_forward
|
||||
* advances over a single UTF8 encoded multibyte character, capturing the
|
||||
* unicode character as it goes, and returning the number of bytes consumed.
|
||||
* Advance over a single UTF8 encoded multibyte character, capturing the Unicode character
|
||||
* as it goes, and returning the number of bytes consumed.
|
||||
*
|
||||
* @param aSequence is the UTF8 byte sequence, must be aligned on start of character.
|
||||
* @param aResult is where to put the unicode character, and may be NULL if no interest.
|
||||
* @return int - the count of bytes consumed.
|
||||
* @return the count of bytes consumed.
|
||||
*/
|
||||
static int uni_forward( const unsigned char* aSequence, unsigned* aResult = NULL );
|
||||
#endif // SWIG
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#include <wx/filename.h>
|
||||
|
||||
/**
|
||||
* WX_FILENAME - A wrapper around a wxFileName which is much more performant with a subset of the API.
|
||||
* A wrapper around a wxFileName which is much more performant with a subset of the API.
|
||||
*
|
||||
* A wrapper around a wxFileName which avoids expensive calls to wxFileName::SplitPath()
|
||||
* and string concatenations by caching the path and filename locally and only resolving
|
||||
|
@ -57,4 +57,4 @@ private:
|
|||
wxString m_fullName;
|
||||
};
|
||||
|
||||
#endif // WX_FILENAME_H
|
||||
#endif // WX_FILENAME_H
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2010 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
||||
* Copyright (C) 1992-2010 KiCAd Developers, see change_log.txt for contributors.
|
||||
* Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
|
@ -36,26 +36,25 @@
|
|||
|
||||
|
||||
/**
|
||||
* XNODE
|
||||
* holds an XML or S-expression element. It is used for eXporting
|
||||
* a document tree in EITHER XML or S-expression.
|
||||
* Hold an XML or S-expression element.
|
||||
*
|
||||
* It is used for exporting a document tree in either XML or S-expression.
|
||||
*/
|
||||
class XNODE : public wxXmlNode
|
||||
{
|
||||
public:
|
||||
//-----<overloads>---------------------------------------------------------
|
||||
XNODE() :
|
||||
wxXmlNode()
|
||||
{
|
||||
}
|
||||
|
||||
XNODE( wxXmlNodeType aType, const wxString& aName, const wxString& aContent = wxEmptyString ) :
|
||||
wxXmlNode( NULL, aType, aName, aContent )
|
||||
wxXmlNode( nullptr, aType, aName, aContent )
|
||||
{
|
||||
}
|
||||
|
||||
XNODE( XNODE* aParent, wxXmlNodeType aType, const wxString& aName,
|
||||
const wxString& aContent = wxEmptyString, wxXmlAttribute* aProperties = NULL ) :
|
||||
const wxString& aContent = wxEmptyString, wxXmlAttribute* aProperties = nullptr ) :
|
||||
wxXmlNode( aParent, aType, aName, aContent, aProperties )
|
||||
{
|
||||
}
|
||||
|
@ -74,23 +73,23 @@ public:
|
|||
{
|
||||
return (XNODE* )wxXmlNode::GetParent();
|
||||
}
|
||||
//-----</overloads>--------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Function Format
|
||||
* writes this object as UTF8 out to an OUTPUTFORMATTER as an S-expression.
|
||||
* Write this object as #UTF8 out to an #OUTPUTFORMATTER as an S-expression.
|
||||
*
|
||||
* @param out The formatter to write to.
|
||||
* @param nestLevel A multiple of the number of spaces to preceed the output with.
|
||||
* @param nestLevel A multiple of the number of spaces to precede the output with.
|
||||
* @throw IO_ERROR if a system error writing the output, such as a full disk.
|
||||
*/
|
||||
virtual void Format( OUTPUTFORMATTER* out, int nestLevel );
|
||||
|
||||
/**
|
||||
* Function FormatContents
|
||||
* writes the contents of object as UTF8 out to an OUTPUTFORMATTER as an S-expression.
|
||||
* Write the contents of object as #UTF8 out to an #OUTPUTFORMATTER as an S-expression.
|
||||
*
|
||||
* This is the same as Format() except that the outer wrapper is not included.
|
||||
*
|
||||
* @param out The formatter to write to.
|
||||
* @param nestLevel A multiple of the number of spaces to preceed the output with.
|
||||
* @param nestLevel A multiple of the number of spaces to precede the output with.
|
||||
* @throw IO_ERROR if a system error writing the output, such as a full disk.
|
||||
*/
|
||||
virtual void FormatContents( OUTPUTFORMATTER* out, int nestLevel );
|
||||
|
|
Loading…
Reference in New Issue