Header clean up round 4.

This commit is contained in:
Wayne Stambaugh 2020-12-21 10:17:52 -05:00
parent 6e4b1fe8d4
commit 96c935673e
25 changed files with 733 additions and 827 deletions

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2014 CERN * 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> * @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
@ -31,10 +31,9 @@
#include <type_traits> #include <type_traits>
/** /**
* Function IsA()
*
* Checks if the type of aObject is T. * 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. * @return true, if aObject type equals T.
*/ */
template <class T, class I> 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*. * Cast \a aObject to type Casted*. Uses #EDA_ITEM::Type() and #EDA_ITEM::ClassOf() to
* Uses EDA_ITEM::Type() and EDA_ITEM::ClassOf() to check if type matches. * check if type matches.
* @param aObject object to be casted *
* @param aObject object to be casted.
* @return down-casted object or NULL if type doesn't match Casted. * @return down-casted object or NULL if type doesn't match Casted.
*/ */
template<class Casted, class From> template<class Casted, class From>
@ -72,8 +72,7 @@ class EDA_ITEM;
/** /**
* Enum KICAD_T * The set of class identification values stored in #EDA_ITEM::m_structType
* is the set of class identification values, stored in EDA_ITEM::m_structType
*/ */
enum KICAD_T enum KICAD_T
{ {
@ -225,10 +224,13 @@ enum KICAD_T
}; };
/** /**
* Returns the underlying type of the given type. This is useful for finding the * Returns the underlying type of the given type.
* element type given one of the "non-type" types such as SCH_LINE_LOCATE_WIRE_T *
* @param aType Given type to resolve * This is useful for finding the element type given one of the "non-type" types such as
* @return Base type * SCH_LINE_LOCATE_WIRE_T.
*
* @param aType Given type to resolve.
* @return Base type.
*/ */
constexpr KICAD_T BaseType( const KICAD_T aType ) constexpr KICAD_T BaseType( const KICAD_T aType )
{ {

View File

@ -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. * @return true if the application can be started.
*/ */
virtual bool OnPgmInit() = 0; // call this from wxApp::OnInit() virtual bool OnPgmInit() = 0; // call this from wxApp::OnInit()

View File

@ -1,5 +1,6 @@
/* /*
* Copyright (C) 2018 CERN * Copyright (C) 2018 CERN
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
* Author: Maciej Suminski <maciej.suminski@cern.ch> * Author: Maciej Suminski <maciej.suminski@cern.ch>
* *
* This program is free software: you can redistribute it and/or modify it * This program is free software: you can redistribute it and/or modify it
@ -25,8 +26,7 @@ class APP_SETTINGS_BASE;
class COLOR_SETTINGS; class COLOR_SETTINGS;
/** /**
* PRINT_PARAMETERS * Handle the parameters used to print a board drawing.
* handles the parameters used to print a board drawing.
*/ */
struct PRINTOUT_SETTINGS struct PRINTOUT_SETTINGS
{ {
@ -46,8 +46,15 @@ struct PRINTOUT_SETTINGS
} }
virtual void Save( APP_SETTINGS_BASE* aConfig ); virtual void Save( APP_SETTINGS_BASE* aConfig );
virtual void Load( 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 double m_scale; ///< Printing scale
bool m_titleBlock; ///< Print frame and title block bool m_titleBlock; ///< Print frame and title block
bool m_blackWhite; ///< Print in B&W or Color bool m_blackWhite; ///< Print in B&W or Color
@ -57,11 +64,6 @@ struct PRINTOUT_SETTINGS
/// The color settings to be used for printing /// The color settings to be used for printing
COLOR_SETTINGS* m_colorSettings; 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 */ #endif /* PRINTOUT_H */

View File

@ -2,8 +2,8 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2013 CERN * Copyright (C) 2013 CERN
* Copyright (C) 2019-2020 KiCad Developers, see AUTHORS.txt for contributors.
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch> * @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 * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -37,7 +37,8 @@
#include <iomanip> #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 * 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() * its creation (or the last call to Start() ) and the last call to Stop()
*/ */
@ -45,9 +46,10 @@ class PROF_COUNTER
{ {
public: public:
/** /**
* Creates a PROF_COUNTER for measuring an elapsed time in milliseconds * 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 * @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 ) : PROF_COUNTER( const std::string& aName, bool aAutostart = true ) :
m_name( aName ), m_running( false ) 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. * The counter is started and the string to print in message is left empty.
*/ */
PROF_COUNTER() PROF_COUNTER()
@ -66,7 +69,7 @@ public:
} }
/** /**
* Starts or restarts the counter * Start or restart the counter.
*/ */
void Start() 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() void Stop()
{ {
@ -121,9 +124,9 @@ public:
} }
/** /**
* @return the time since the timer was started. If the timer is stopped, * @return the time since the timer was started. If the timer is stopped, the duration
* the duration is from the start time to the time it was stopped, else it * is from the start time to the time it was stopped, else it is to the current
* is to the current time. * time.
*/ */
template <typename DURATION> template <typename DURATION>
DURATION SinceStart( bool aSinceLast = false ) 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. * @return the elapsed time in ms since the timer was started.
*/ */
double msecs( bool aSinceLast = false ) 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 * 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 * @author Dick Hollenbeck
*/ */
unsigned GetRunningMicroSecs(); unsigned GetRunningMicroSecs();

View File

@ -5,7 +5,7 @@
* This program source code file is part of KICAD, a free EDA CAD application. * 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 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 * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -27,14 +27,11 @@
/** /**
* PROPERTIES * A name/value tuple with unique names and optional values. The names
* is a name/value tuple with unique names and optional values. The names
* may be iterated alphabetically. * may be iterated alphabetically.
*/ */
class PROPERTIES : public std::map< std::string, UTF8 > class PROPERTIES : public std::map< std::string, UTF8 >
{ {
// alphabetical tuple of name and value hereby defined.
public: public:
bool Clear( const std::string& aProperty ) bool Clear( const std::string& aProperty )
{ {
@ -47,15 +44,17 @@ public:
} }
/** /**
* Function Value * Fetch a property by \a aName and returns true if that property was found, else false.
* fetches a property by aName and returns true if that property was found, else false. * If not found, \a aFetchedValue is not touched.
* If not found, aFetchedValue is not touched. *
* @param aName is the property or option to look for. * @param aName is the property or option to look for.
* @param aFetchedValue is where to put the value of the property if it * @param aFetchedValue is where to put the value of the property if it exists and
* exists and aFetchedValue is not NULL. * \a aFetchedValue is not NULL.
* @return bool - true if property is found, else false. * @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_ #endif // _PROPERTIES_H_
// LocalWords: aName aFetchedValue

View File

@ -2,6 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2020 CERN * Copyright (C) 2020 CERN
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch> * @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
* @author Maciej Suminski <maciej.suminski@cern.ch> * @author Maciej Suminski <maciej.suminski@cern.ch>
* *
@ -167,10 +168,6 @@ public:
class PROPERTY_BASE class PROPERTY_BASE
{ {
private:
///> Used to generate unique IDs
size_t nextId = 0;
public: public:
PROPERTY_BASE( const wxString& aName, PROPERTY_DISPLAY aDisplay = DEFAULT ) : PROPERTY_BASE( const wxString& aName, PROPERTY_DISPLAY aDisplay = DEFAULT ) :
m_id( nextId ), m_id( nextId ),
@ -293,6 +290,9 @@ private:
///> Condition that determines whether the property is available ///> Condition that determines whether the property is available
std::function<bool(INSPECTABLE*)> m_availFunc; std::function<bool(INSPECTABLE*)> m_availFunc;
///> Used to generate unique IDs
size_t nextId = 0;
friend class INSPECTABLE; friend class INSPECTABLE;
}; };
@ -580,8 +580,8 @@ private:
public: \ public: \
wxAnyValueTypeImpl() : wxAnyValueTypeImplBase<type>() {} \ wxAnyValueTypeImpl() : wxAnyValueTypeImplBase<type>() {} \
virtual ~wxAnyValueTypeImpl() {} \ virtual ~wxAnyValueTypeImpl() {} \
virtual bool ConvertValue( const wxAnyValueBuffer& src,\ virtual bool ConvertValue( const wxAnyValueBuffer& src, wxAnyValueType* dstType, \
wxAnyValueType* dstType, wxAnyValueBuffer& dst ) const override\ wxAnyValueBuffer& dst ) const override \
{ \ { \
type value = GetValue( src ); \ type value = GetValue( src ); \
ENUM_MAP<type>& conv = ENUM_MAP<type>::Instance(); \ ENUM_MAP<type>& conv = ENUM_MAP<type>::Instance(); \
@ -602,8 +602,7 @@ private:
} \ } \
}; };
#define IMPLEMENT_ENUM_TO_WXANY(type)\ #define IMPLEMENT_ENUM_TO_WXANY( type ) WX_IMPLEMENT_ANY_VALUE_TYPE( wxAnyValueTypeImpl<type> )
WX_IMPLEMENT_ANY_VALUE_TYPE(wxAnyValueTypeImpl<type>)
#define ENUM_TO_WXANY( type ) \ #define ENUM_TO_WXANY( type ) \
DECLARE_ENUM_TO_WXANY( type ) \ DECLARE_ENUM_TO_WXANY( type ) \

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * 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 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 * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -26,8 +26,7 @@
#define PTREE_H_ #define PTREE_H_
/* /*
Implement "KiCad s-expression" support for boost::property_tree's ptree, the 8
Implement "KiCad s-epression" support for boost::property_tree's ptree, the 8
bit string version of property_tree. The ram resident structure of the ptree is bit string version of property_tree. The ram resident structure of the ptree is
mostly compatible with one created using the xml_parser from mostly compatible with one created using the xml_parser from
boost::property_tree, with slight differences in the way atoms are stored. The 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 the boost website and there are a number of examples in the
pcbnew/eagle_plugin.cpp file in this project. Powerful path navigation support pcbnew/eagle_plugin.cpp file in this project. Powerful path navigation support
makes it easy to extract a subset of a ptree. 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; typedef boost::property_tree::ptree_error PTREE_ERROR;
/** /**
* Function Scan * Fill an empty #PTREE with information from a KiCad s-expression stream.
* 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 * Use a #DSNLEXER with an empty keyword table as @a aLexer. Useful for parsing s-expression
* s-expression files or strings of arbitrary grammars, say from a file or clipboard. * files or strings of arbitrary grammars, say from a file or clipboard. The s-expression
* The s-expression must be "KiCad compatible". See Documentation/s-expressions.txt * must be "KiCad compatible". See Documentation/s-expressions.txt for this KiCad compatible
* for this KiCad compatible definition (it is the non-specctra mode). * definition (it is the non-specctra mode). And also see in tools/property_tree.cpp for
* And also see in tools/property_tree.cpp for example usage. * example usage.
* *
* <code> * <code>
* *
@ -87,8 +85,7 @@ typedef boost::property_tree::ptree_error PTREE_ERROR;
void Scan( PTREE* aTree, DSNLEXER* aLexer ); void Scan( PTREE* aTree, DSNLEXER* aLexer );
/** /**
* Function Format * Output a #PTREE into s-expression format via an #OUTPUTFORMATTER derivative.
* outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
*/ */
void Format( OUTPUTFORMATTER* out, int aNestLevel, int aCtl, const CPTREE& aTree ); void Format( OUTPUTFORMATTER* out, int aNestLevel, int aCtl, const CPTREE& aTree );

View File

@ -74,16 +74,6 @@ class RC_ITEM
public: public:
typedef std::vector<KIID> KIIDS; 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() : RC_ITEM() :
m_errorCode( 0 ), m_errorCode( 0 ),
m_parent( nullptr ) m_parent( nullptr )
@ -181,6 +171,16 @@ public:
* Format a coordinate or position to text. * Format a coordinate or position to text.
*/ */
static wxString ShowCoord( EDA_UNITS aUnits, const wxPoint& aPos ); 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 ); static KIID ToUUID( wxDataViewItem aItem );
public:
RC_TREE_MODEL( EDA_DRAW_FRAME* aParentFrame, wxDataViewCtrl* aView ); RC_TREE_MODEL( EDA_DRAW_FRAME* aParentFrame, wxDataViewCtrl* aView );
~RC_TREE_MODEL(); ~RC_TREE_MODEL();
@ -292,7 +290,6 @@ private:
void rebuildModel( RC_ITEMS_PROVIDER* aProvider, int aSeverities ); void rebuildModel( RC_ITEMS_PROVIDER* aProvider, int aSeverities );
void onSizeView( wxSizeEvent& aEvent ); void onSizeView( wxSizeEvent& aEvent );
private:
EDA_DRAW_FRAME* m_editFrame; EDA_DRAW_FRAME* m_editFrame;
wxDataViewCtrl* m_view; wxDataViewCtrl* m_view;
int m_severities; int m_severities;

View File

@ -1,7 +1,7 @@
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * 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 * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -40,13 +40,15 @@ namespace KIGFX
class VIEW_ITEM; class VIEW_ITEM;
/** /**
* RENDER_SETTINGS * Container for all the knowledge about how graphical objects are drawn on any output
* Contains all the knowledge about how graphical objects are drawn on any output * surface/device.
* surface/device. This includes: *
* This includes:
* - color/transparency settings * - color/transparency settings
* - highlighting and high contrast mode control * - highlighting and high contrast mode control
* - drawing quality control (sketch/outline mode) * - drawing quality control (sketch/outline mode)
* - text processing flags * - text processing flags
*
* The class acts as an interface between the PAINTER object and the GUI (i.e. Layers/Items * The class acts as an interface between the PAINTER object and the GUI (i.e. Layers/Items
* widget or display options dialog). * widget or display options dialog).
*/ */
@ -59,8 +61,8 @@ public:
virtual void LoadColors( const COLOR_SETTINGS* aSettings ) { } virtual void LoadColors( const COLOR_SETTINGS* aSettings ) { }
/** /**
* Function SetLayerIsHighContrast * Set the specified layer as high-contrast.
* Sets the specified layer as high-contrast. *
* @param aLayerId is a layer number that should be displayed in a specific mode. * @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). * @param aEnabled is the new layer state ( true = active or false = not active).
*/ */
@ -73,8 +75,8 @@ public:
} }
/** /**
* Function GetLayerIsHighContrast * Return information whether the queried layer is marked as high-contrast.
* Returns information whether the queried layer is marked as high-contrast. *
* @return True if the queried layer is marked as active. * @return True if the queried layer is marked as active.
*/ */
inline bool GetLayerIsHighContrast( int aLayerId ) const inline bool GetLayerIsHighContrast( int aLayerId ) const
@ -83,7 +85,6 @@ public:
} }
/** /**
* Function GetHighContrastLayers()
* Returns the set of currently high-contrast layers. * Returns the set of currently high-contrast layers.
*/ */
const std::set<unsigned int> GetHighContrastLayers() const 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 * Return the board layer which is in high-contrast mode.
* board layer which is high-contrast at any given time, although there might be *
* many high-contrast synthetic (GAL) layers. * 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 PCB_LAYER_ID GetPrimaryHighContrastLayer() const
{ {
@ -111,8 +113,7 @@ public:
void SetActiveLayer( PCB_LAYER_ID aLayer ) { m_activeLayer = aLayer; } void SetActiveLayer( PCB_LAYER_ID aLayer ) { m_activeLayer = aLayer; }
/** /**
* Function ClearHighContrastLayers * Clear the list of active layers.
* Clears the list of active layers.
*/ */
inline void ClearHighContrastLayers() inline void ClearHighContrastLayers()
{ {
@ -120,8 +121,8 @@ public:
} }
/** /**
* Function IsHighlightEnabled * Return current highlight setting.
* Returns current highlight setting. *
* @return True if highlight is enabled, false otherwise. * @return True if highlight is enabled, false otherwise.
*/ */
inline bool IsHighlightEnabled() const inline bool IsHighlightEnabled() const
@ -130,8 +131,8 @@ public:
} }
/** /**
* Function GetHighlightNetCode * Return the netcode of currently highlighted net.
* Returns netcode of currently highlighted net. *
* @return Netcode of currently highlighted net. * @return Netcode of currently highlighted net.
*/ */
inline const std::set<int>& GetHighlightNetCodes() const inline const std::set<int>& GetHighlightNetCodes() const
@ -140,10 +141,12 @@ public:
} }
/** /**
* Function SetHighlight * Turns on/off highlighting.
* Turns on/off highlighting - it may be done for the active layer or the specified net(s). *
* It may be done for the active layer or the specified net(s)..
*
* @param aEnabled tells if highlighting should be enabled. * @param aEnabled tells if highlighting should be enabled.
* @param aNetcode is optional and if specified, turns on higlighting only for the net with * @param aNetcode is optional and if specified, turns on highlighting only for the net with
* number given as the parameter. * number given as the parameter.
*/ */
inline void SetHighlight( bool aEnabled, int aNetcode = -1, bool aMulti = false ) 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. * Turns on/off high contrast display mode.
*/ */
void SetHighContrast( bool aEnabled ) { m_hiContrastEnabled = aEnabled; } 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 * Returns the color that should be used to draw the specific VIEW_ITEM on the specific layer
* using currently used render settings. * using currently used render settings.
*
* @param aItem is the VIEW_ITEM. * @param aItem is the VIEW_ITEM.
* @param aLayer is the layer. * @param aLayer is the layer.
* @return The color. * @return The color.
@ -189,31 +192,28 @@ public:
void SetShowPageLimits( bool aDraw ) { m_showPageLimits = aDraw; } void SetShowPageLimits( bool aDraw ) { m_showPageLimits = aDraw; }
/** /**
* Function GetBackgroundColor * Return current background color settings.
* Returns current background color settings.
*/ */
virtual const COLOR4D& GetBackgroundColor() = 0; virtual const COLOR4D& GetBackgroundColor() = 0;
/** /**
* Sets the background color. * Set the background color.
*/ */
virtual void SetBackgroundColor( const COLOR4D& aColor ) = 0; virtual void SetBackgroundColor( const COLOR4D& aColor ) = 0;
/** /**
* Function GetGridColor * Return current grid color settings.
* Returns current grid color settings.
*/ */
virtual const COLOR4D& GetGridColor() = 0; virtual const COLOR4D& GetGridColor() = 0;
/** /**
* Function GetCursorColor * Return current cursor color settings.
* Returns current cursor color settings.
*/ */
virtual const COLOR4D& GetCursorColor() = 0; virtual const COLOR4D& GetCursorColor() = 0;
/** /**
* Function GetLayerColor * Return the color used to draw a layer.
* Returns the color used to draw a layer. *
* @param aLayer is the layer number. * @param aLayer is the layer number.
*/ */
inline const COLOR4D& GetLayerColor( int aLayer ) const inline const COLOR4D& GetLayerColor( int aLayer ) const
@ -222,8 +222,8 @@ public:
} }
/** /**
* Function SetLayerColor * Change the color used to draw a layer.
* Changes the color used to draw a layer. *
* @param aLayer is the layer number. * @param aLayer is the layer number.
* @param aColor is the new color. * @param aColor is the new color.
*/ */
@ -259,7 +259,6 @@ public:
protected: protected:
/** /**
* Function update
* Precalculates extra colors for layers (e.g. highlighted, darkened and any needed version * Precalculates extra colors for layers (e.g. highlighted, darkened and any needed version
* of base colors). * of base colors).
*/ */

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2013 Wayne Stambaugh <stambaughw@verizon.net> * 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 * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -43,8 +43,7 @@ class WX_INFOBAR;
/** /**
* REPORTER * A pure virtual class used to derive REPORTER objects from.
* is 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 * The purpose of the REPORTER object is to offer a way for a procedural function
* to report multiple errors without having to: * to report multiple errors without having to:
@ -57,12 +56,13 @@ class WX_INFOBAR;
* - warning * - warning
* - error * - error
* - action (i.e. indication of changes - add component, change footprint, etc. ) * - action (i.e. indication of changes - add component, change footprint, etc. )
*
* They are indicators for the message formatting and displaying code, * They are indicators for the message formatting and displaying code,
* filtering is not made here. * filtering is not made here.
*/ */
class REPORTER { class REPORTER
{
public: public:
/** /**
* Location where the message is to be reported. * Location where the message is to be reported.
@ -77,30 +77,30 @@ public:
}; };
/** /**
* Function Report * Report a string with a given severity.
* is a pure virtual function to override in the derived object.
* *
* @param aText is the string to report. * @param aText is the string to report.
* @param aSeverity is an indicator ( RPT_UNDEFINED, RPT_INFO, RPT_WARNING, * @param aSeverity is an indicator ( RPT_UNDEFINED, RPT_INFO, RPT_WARNING, RPT_ERROR,
* RPT_ERROR, RPT_ACTION ) used to filter and format messages * 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 * 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 ); 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 ); return Report( aText, aSeverity );
} }
@ -113,7 +113,6 @@ public:
REPORTER& operator <<( const char* aText ) { return Report( aText ); } REPORTER& operator <<( const char* aText ) { return Report( aText ); }
/** /**
* Function HasMessage
* Returns true if the reporter client is non-empty. * Returns true if the reporter client is non-empty.
*/ */
virtual bool HasMessage() const = 0; virtual bool HasMessage() const = 0;
@ -130,8 +129,7 @@ public:
/** /**
* WX_TEXT_CTRL_REPORTER * A wrapper for reporting to a wxTextCtrl object.
* is wrapper for reporting to a wxTextCtrl object.
*/ */
class WX_TEXT_CTRL_REPORTER : public REPORTER 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; bool HasMessage() const override;
}; };
/** /**
* WX_STRING_REPORTER * A wrapper for reporting to a wxString object.
* is a wrapper for reporting to a wxString object.
*/ */
class WX_STRING_REPORTER : public REPORTER class WX_STRING_REPORTER : public REPORTER
{ {
@ -180,8 +178,7 @@ public:
/** /**
* WX_HTML_PANEL_REPORTER * A wrapper for reporting to a wx HTML window.
* is a wrapper for reporting to a wx HTML window
*/ */
class WX_HTML_PANEL_REPORTER : public REPORTER 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; 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 * Used as to simplify code by avoiding the reportee to check for a non-NULL reporter object.
* avoiding the reportee to check for a non-NULL reporter object.
*/ */
class NULL_REPORTER : public REPORTER class NULL_REPORTER : public REPORTER
{ {
@ -227,15 +226,14 @@ public:
static REPORTER& GetInstance(); 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; } bool HasMessage() const override { return false; }
}; };
/** /**
* STDOUT_REPORTER
*
* Debug type reporter, forwarding messages to std::cout. * Debug type reporter, forwarding messages to std::cout.
*/ */
class STDOUT_REPORTER : public REPORTER class STDOUT_REPORTER : public REPORTER
@ -251,37 +249,38 @@ public:
static REPORTER& GetInstance(); 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; } bool HasMessage() const override { return false; }
}; };
/** /**
* STATUSBAR_REPORTER * A wrapper for reporting to a specific text location in a statusbar.
* is a wrapper for reporting to a specific text location in a statusbar
*/ */
class STATUSBAR_REPORTER : public REPORTER class STATUSBAR_REPORTER : public REPORTER
{ {
private:
wxStatusBar* m_statusBar;
int m_position;
public: public:
STATUSBAR_REPORTER( wxStatusBar* aStatusBar, int aPosition = 0 ) 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; REPORTER& Report( const wxString& aText, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
bool HasMessage() const override; bool HasMessage() const override;
private:
wxStatusBar* m_statusBar;
int m_position;
}; };
/** /**
* INFOBAR_REPORTER * A wrapper for reporting to a #WX_INFOBAR UI element.
* is 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 * 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 * 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 class INFOBAR_REPORTER : public REPORTER
{ {
private:
bool m_messageSet;
WX_INFOBAR* m_infoBar;
wxString m_message;
SEVERITY m_severity;
public: public:
INFOBAR_REPORTER( WX_INFOBAR* aInfoBar ) INFOBAR_REPORTER( WX_INFOBAR* aInfoBar )
: REPORTER(), : 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; bool HasMessage() const override;
@ -315,6 +309,12 @@ public:
* Update the infobar with the reported text. * Update the infobar with the reported text.
*/ */
void Finalize(); void Finalize();
private:
bool m_messageSet;
WX_INFOBAR* m_infoBar;
wxString m_message;
SEVERITY m_severity;
}; };
#endif // _REPORTER_H_ #endif // _REPORTER_H_

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * 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) 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 * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -42,13 +42,12 @@
/** /**
* Function StrPrintf * This is like sprintf() but the output is appended to a std::string instead of to a
* is like sprintf() but the output is appended to a std::string instead of to a
* character array. * character array.
*
* @param aResult is the string to append to, previous text is not clear()ed. * @param aResult is the string to append to, previous text is not clear()ed.
* @param aFormat is a printf() style format string. * @param aFormat is a printf() style format string.
* @return int - the count of bytes appended to the result string, no terminating * @return the count of bytes appended to the result string, no terminating nul is included.
* nul is included.
*/ */
int int
#if defined(__GNUG__) #if defined(__GNUG__)
@ -58,9 +57,9 @@ int
/** /**
* Function StrPrintf * This is like sprintf() but the output is returned in a std::string instead of to a
* is like sprintf() but the output is returned in a std::string instead of to a
* character array. * character array.
*
* @param format is a printf() style format string. * @param format is a printf() style format string.
* @return std::string - the result of the sprintf(). * @return std::string - the result of the sprintf().
*/ */
@ -75,13 +74,84 @@ std::string
#define LINE_READER_LINE_INITIAL_SIZE 5000 #define LINE_READER_LINE_INITIAL_SIZE 5000
/** /**
* LINE_READER * An abstract class from which implementation specific LINE_READERs may be derived to
* is an abstract class from which implementation specific LINE_READERs may * read single lines of text and manage a line number counter.
* be derived to read single lines of text and manage a line number counter.
*/ */
class LINE_READER 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: 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_length; ///< no. bytes in line before trailing nul.
unsigned m_lineNum; unsigned m_lineNum;
@ -91,127 +161,37 @@ protected:
unsigned m_maxLineLength; ///< maximum allowed capacity using resizing. unsigned m_maxLineLength; ///< maximum allowed capacity using resizing.
wxString m_source; ///< origin of text lines, e.g. filename or "clipboard" 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 * A LINE_READER that reads from an open file.
* 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. * File must be already open so that this class can exist without any UI policy.
*/ */
class FILE_LINE_READER : public LINE_READER 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: public:
/** /**
* Constructor FILE_LINE_READER * Take @a aFileName and the size of the desired line buffer and opens the file and
* takes @a aFileName and the size of the desired line buffer and opens * assumes the obligation to close it.
* 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 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 * @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 * 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). * 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 * 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. * 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. * @param aMaxLineLength is the number of bytes to use in the line buffer.
* *
* @throw IO_ERROR if @a aFileName cannot be opened. * @throw IO_ERROR if @a aFileName cannot be opened.
*/ */
FILE_LINE_READER( const wxString& aFileName, FILE_LINE_READER( const wxString& aFileName, unsigned aStartingLineNumber = 0,
unsigned aStartingLineNumber = 0,
unsigned aMaxLineLength = LINE_READER_LINE_DEFAULT_MAX ); unsigned aMaxLineLength = LINE_READER_LINE_DEFAULT_MAX );
/** /**
* Constructor FILE_LINE_READER * Take an open FILE and the size of the desired line buffer and takes ownership of
* takes an open FILE and the size of the desired line buffer and takes * the open file, i.e. assumes the obligation to close it.
* ownership of the open file, i.e. assumes the obligation to close it.
* *
* @param aFile is an open file. * @param aFile is an open file.
* @param aFileName is the name of the file for error reporting purposes. * @param aFileName is the name of the file for error reporting purposes.
@ -228,29 +208,31 @@ public:
unsigned aMaxLineLength = LINE_READER_LINE_DEFAULT_MAX ); 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(); ~FILE_LINE_READER();
char* ReadLine() override; char* ReadLine() override;
/** /**
* Function Rewind * Rewind the file and resets the line number back to zero.
* rewinds the file and resets the line number back to zero. Line number *
* will go to 1 on first ReadLine(). * Line number will go to 1 on first ReadLine().
*/ */
void Rewind() void Rewind()
{ {
rewind( m_fp ); rewind( m_fp );
m_lineNum = 0; 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 class STRING_LINE_READER : public LINE_READER
{ {
@ -261,22 +243,21 @@ protected:
public: 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 * @param aString is a source string consisting of one or more lines
* of text, where multiple lines are separated with a '\n' character. * of text, where multiple lines are separated with a '\n' character.
* The last line does not necessarily need a trailing '\n'. * The last line does not necessarily need a trailing '\n'.
*
* @param aSource describes the source of aString for error reporting purposes * @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 ); STRING_LINE_READER( const std::string& aString, const wxString& aSource );
/** /**
* Constructor STRING_LINE_READER( const STRING_LINE_READER& ) * Construct a string line reader.
* allows for a continuation of the reading of a stream started by another *
* 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 * STRING_LINE_READER. Any stream offset and source name are used from
* @a aStartingPoint.
*/ */
STRING_LINE_READER( const STRING_LINE_READER& aStartingPoint ); STRING_LINE_READER( const STRING_LINE_READER& aStartingPoint );
@ -285,18 +266,13 @@ public:
/** /**
* INPUTSTREAM_LINE_READER * A #LINE_READER that reads from a wxInputStream object.
* is a LINE_READER that reads from a wxInputStream object.
*/ */
class INPUTSTREAM_LINE_READER : public LINE_READER class INPUTSTREAM_LINE_READER : public LINE_READER
{ {
protected:
wxInputStream* m_stream; //< The input stream to read. No ownership of this pointer.
public: public:
/** /**
* Constructor WXINPUTSTREAM_LINE_READER * Construct a #LINE_READER from a wxInputStream object.
* *
* @param aStream A pointer to a wxInputStream object to read. * @param aStream A pointer to a wxInputStream object to read.
* @param aSource The name of the stream source, for error reporting purposes. * @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 ); INPUTSTREAM_LINE_READER( wxInputStream* aStream, const wxString& aSource );
char* ReadLine() override; 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 #define OUTPUTFMTBUFZ 500 ///< default buffer size for any OUTPUT_FORMATTER
/** /**
* OUTPUTFORMATTER * An interface used to output 8 bit text in a convenient way.
* is an important interface (abstract class) used to output 8 bit text in *
* a convenient way. The primary interface is "printf() - like" but * The primary interface is "printf() - like" but with support for indentation control. The
* with support for indentation control. The destination of the 8 bit * destination of the 8 bit wide text is up to the implementer.
* wide text is up to the implementer.
* <p> * <p>
* The implementer only has to implement the write() function, but can * The implementer only has to implement the write() function, but can also optionally
* also optionally re-implement GetQuoteChar(). * re-implement GetQuoteChar().
* <p> * <p>
* If you want to output a wxString, then use TO_UTF8() on it * If you want to output a wxString, then use TO_UTF8() on it before passing it as an
* before passing it as an argument to Print(). * argument to Print().
* <p> * <p>
* Since this is an abstract interface, only classes derived from * Since this is an abstract interface, only classes derived from this one may actually be
* this one may actually be used. * used.
*/ */
class OUTPUTFORMATTER class OUTPUTFORMATTER
{ {
std::vector<char> m_buffer;
char quoteChar[2];
int sprint( const char* fmt, ... );
int vprint( const char* fmt, va_list ap );
protected: protected:
OUTPUTFORMATTER( int aReserve = OUTPUTFMTBUFZ, char aQuoteChar = '"' ) : OUTPUTFORMATTER( int aReserve = OUTPUTFMTBUFZ, char aQuoteChar = '"' ) :
m_buffer( aReserve, '\0' ) m_buffer( aReserve, '\0' )
@ -345,22 +316,19 @@ protected:
virtual ~OUTPUTFORMATTER() {} virtual ~OUTPUTFORMATTER() {}
/** /**
* Function GetQuoteChar * Perform quote character need determination according to the Specctra DSN specification.
* performs quote character need determination according to the Specctra DSN
* specification.
* @param wrapee A string that might need wrapping on each end. * @param wrapee A string that might need wrapping on each end.
* @param quote_char A single character C string which provides the current * @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 "" * @return the quote_char as a single character string, or "" if the wrapee does not need
* if the wrapee does not need to be wrapped. * to be wrapped.
*/ */
static const char* GetQuoteChar( const char* wrapee, const char* quote_char ); 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 aOutBuf is the start of a byte buffer to write.
* @param aCount tells how many bytes to write. * @param aCount tells how many bytes to write.
@ -375,18 +343,13 @@ protected:
// See http://docs.freebsd.org/info/gcc/gcc.info.Function_Attributes.html // 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 // 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 #else
#define PRINTF_FUNC // nothing #define PRINTF_FUNC // nothing
#endif #endif
public: public:
//-----<interface functions>------------------------------------------
/** /**
* Function Print * Format and write text to the output stream.
* formats and writes text to the output stream.
* *
* @param nestLevel The multiple of spaces to precede the output with. * @param nestLevel The multiple of spaces to precede the output with.
* @param fmt A printf() style format string. * @param fmt A printf() style format string.
@ -398,35 +361,31 @@ public:
int PRINTF_FUNC Print( int nestLevel, const char* fmt, ... ); int PRINTF_FUNC Print( int nestLevel, const char* fmt, ... );
/** /**
* Function GetQuoteChar * Perform quote character need determination.
* performs quote character need determination. *
* It returns the quote character as a single character string for a given * It returns the quote character as a single character string for a given input wrapee
* input wrapee string. If the wrappee does not need to be quoted, * string. If the wrappee does not need to be quoted, the return value is "" (the null
* the return value is "" (the null string), such as when there are no * string), such as when there are no delimiters in the input wrapee string. If you want
* delimiters in the input wrapee string. If you want the quote_char * the quote_char to be assuredly not "", then pass in "(" as the wrappee.
* to be assuredly not "", then pass in "(" as the wrappee.
* <p> * <p>
* Implementations are free to override the default behavior, which is to * Implementations are free to override the default behavior, which is to call the static
* call the static function of the same name. * function of the same name.
*
* @param wrapee A string that might need wrapping on each end. * @param wrapee A string that might need wrapping on each end.
* @return const char* - the quote_char as a single character string, or "" * @return the quote_char as a single character string, or "" if the wrapee does not need
* if the wrapee does not need to be wrapped. * to be wrapped.
*/ */
virtual const char* GetQuoteChar( const char* wrapee ); virtual const char* GetQuoteChar( const char* wrapee );
/** /**
* Function Quotes * Check \a aWrapee input string for a need to be quoted (e.g. contains a ')' character
* checks \a aWrapee input string for a need to be quoted * or a space), and for \" double quotes within the string that need to be escaped such
* (e.g. contains a ')' character or a space), and for \" double quotes * that the DSNLEXER will correctly parse the string from a file later.
* 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, * @param aWrapee is a string that might need wrapping in double quotes, and it might need
* and it might need to have its internal content escaped, or not. * to have its internal content escaped, or not.
* * @return a std::string- whose c_str() function can be called for passing to printf()
* @return std::string - whose c_str() function can be called for passing * style functions that output UTF8 encoded s-expression streams.
* 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. * @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 ); 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 * Implement an #OUTPUTFORMATTER to a memory buffer.
* implements OUTPUTFORMATTER to a memory buffer. After Print()ing the *
* string is available through GetString() * After Print()ing the string is available through GetString()
*/ */
class STRING_FORMATTER : public OUTPUTFORMATTER class STRING_FORMATTER : public OUTPUTFORMATTER
{ {
std::string m_mystring;
public: public:
/** /**
* Constructor STRING_FORMATTER * Reserve space in the buffer.
* reserves space in the buffer
*/ */
STRING_FORMATTER( int aReserve = OUTPUTFMTBUFZ, char aQuoteChar = '"' ) : STRING_FORMATTER( int aReserve = OUTPUTFMTBUFZ, char aQuoteChar = '"' ) :
OUTPUTFORMATTER( aReserve, aQuoteChar ) OUTPUTFORMATTER( aReserve, aQuoteChar )
@ -459,8 +420,7 @@ public:
} }
/** /**
* Function Clear * Clear the buffer and empties the internal string.
* clears the buffer and empties the internal string.
*/ */
void Clear() void Clear()
{ {
@ -468,8 +428,7 @@ public:
} }
/** /**
* Function StripUseless * Removes whitespace, '(', and ')' from the string.
* removes whitespace, '(', and ')' from the mystring.
*/ */
void StripUseless(); void StripUseless();
@ -479,40 +438,37 @@ public:
} }
protected: protected:
//-----<OUTPUTFORMATTER>------------------------------------------------
void write( const char* aOutBuf, int aCount ) override; void write( const char* aOutBuf, int aCount ) override;
//-----</OUTPUTFORMATTER>-----------------------------------------------
private:
std::string m_mystring;
}; };
/** /**
* FILE_OUTPUTFORMATTER * Used for text file output.
* may be used for text file output. It is about 8 times faster than *
* STREAM_OUTPUTFORMATTER for file streams. * It is about 8 times faster than STREAM_OUTPUTFORMATTER for file streams.
*/ */
class FILE_OUTPUTFORMATTER : public OUTPUTFORMATTER class FILE_OUTPUTFORMATTER : public OUTPUTFORMATTER
{ {
public: public:
/** /**
* Constructor
* @param aFileName is the full filename to open and save to as a text file. * @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" ) * @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. * for text files that are to be created here and now.
* @param aQuoteChar is a char used for quoting problematic strings * @param aQuoteChar is a char used for quoting problematic strings (with whitespace or
(with whitespace or special characters in them). * special characters in them).
* @throw IO_ERROR if the file cannot be opened. * @throw IO_ERROR if the file cannot be opened.
*/ */
FILE_OUTPUTFORMATTER( const wxString& aFileName, FILE_OUTPUTFORMATTER( const wxString& aFileName, const wxChar* aMode = wxT( "wt" ),
const wxChar* aMode = wxT( "wt" ),
char aQuoteChar = '"' ); char aQuoteChar = '"' );
~FILE_OUTPUTFORMATTER(); ~FILE_OUTPUTFORMATTER();
protected: protected:
//-----<OUTPUTFORMATTER>------------------------------------------------
void write( const char* aOutBuf, int aCount ) override; void write( const char* aOutBuf, int aCount ) override;
//-----</OUTPUTFORMATTER>-----------------------------------------------
FILE* m_fp; ///< takes ownership FILE* m_fp; ///< takes ownership
wxString m_filename; wxString m_filename;
@ -520,9 +476,9 @@ protected:
/** /**
* STREAM_OUTPUTFORMATTER * Implement an #OUTPUTFORMATTER to a wxWidgets wxOutputStream.
* implements OUTPUTFORMATTER to a wxWidgets wxOutputStream. The stream is *
* neither opened nor closed by this class. * The stream is neither opened nor closed by this class.
*/ */
class STREAM_OUTPUTFORMATTER : public OUTPUTFORMATTER class STREAM_OUTPUTFORMATTER : public OUTPUTFORMATTER
{ {
@ -530,9 +486,8 @@ class STREAM_OUTPUTFORMATTER : public OUTPUTFORMATTER
public: public:
/** /**
* Constructor STREAM_OUTPUTFORMATTER * This can take any number of wxOutputStream derivations, so it can write to a file,
* can take any number of wxOutputStream derivations, so it can write * socket, or zip file.
* to a file, socket, or zip file.
*/ */
STREAM_OUTPUTFORMATTER( wxOutputStream& aStream, char aQuoteChar = '"' ) : STREAM_OUTPUTFORMATTER( wxOutputStream& aStream, char aQuoteChar = '"' ) :
OUTPUTFORMATTER( OUTPUTFMTBUFZ, aQuoteChar ), OUTPUTFORMATTER( OUTPUTFMTBUFZ, aQuoteChar ),
@ -541,9 +496,7 @@ public:
} }
protected: protected:
//-----<OUTPUTFORMATTER>------------------------------------------------
void write( const char* aOutBuf, int aCount ) override; void write( const char* aOutBuf, int aCount ) override;
//-----</OUTPUTFORMATTER>-----------------------------------------------
}; };
#endif // RICHIO_H_ #endif // RICHIO_H_

View File

@ -28,9 +28,7 @@
#include <wx/stc/stc.h> #include <wx/stc/stc.h>
/** /**
* SCINTILLA_TRICKS * Add cut/copy/paste, autocomplete and brace highlighting to a wxStyleTextCtrl instance.
* is used to add cut/copy/paste, autocomplete and brace highlighting to a wxStyleTextCtrl
* instance.
*/ */
class SCINTILLA_TRICKS : public wxEvtHandler class SCINTILLA_TRICKS : public wxEvtHandler
{ {

View File

@ -25,9 +25,8 @@
#define __SCOPED_SET_RESET_H #define __SCOPED_SET_RESET_H
/** /**
* @class SCOPED_SET_RESET * RAII class that sets an value at construction and resets it to the original value
* @brief RAII class that sets an value at construction and resets * at destruction.
* it to the original value at destruction.
* *
* @note There is no type deduction for template classes until C++17, \ * @note There is no type deduction for template classes until C++17, \
* so you can't do this: * so you can't do this:
@ -46,8 +45,7 @@ class SCOPED_SET_RESET
{ {
public: public:
SCOPED_SET_RESET( VAL_TYPE& target, SCOPED_SET_RESET( VAL_TYPE& target, VAL_TYPE value ):
VAL_TYPE value ):
m_target( target ) m_target( target )
{ {
m_original = 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() ~SCOPED_SET_RESET()
{ {

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2014 CERN * 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> * @author Maciej Suminski <maciej.suminski@cern.ch>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
@ -32,16 +32,15 @@
/** /**
* SEARCH_STACK * Look for files in a number of paths.
* 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 * Augments wxPathList. I chose the name because it sounded like a stack of work, as a
* that anything you put in here means searching work at some point in time. * reminder that anything you put in here means searching work at some point in time.
* (An alternative is to simply know where something is.) * (An alternative is to simply know where something is.)
*/ */
class SEARCH_STACK : public wxPathList, public PROJECT::_ELEM class SEARCH_STACK : public wxPathList, public PROJECT::_ELEM
{ {
public: public:
KICAD_T Type() override { return SEARCH_STACK_T; } KICAD_T Type() override { return SEARCH_STACK_T; }
#if defined(DEBUG) #if defined(DEBUG)
@ -49,26 +48,24 @@ public:
#endif #endif
/** /**
* Function FilenameWithRelativePathInSearchList * Return the shortest possible path which can be use later to find a full path from
* returns the shortest possible path which can be use later to find * this SEARCH_STACK.
* a full path from this SEARCH_STACK. *
* <p> * If the library path is already in the library search paths list, just add the library
* If the library path is already in the library search paths list, * name to the list. Otherwise, add the library name with the full or relative path.
* just add the library name to the list. Otherwise, add the library * The relative path is preferable because it preserves use of default libraries paths,
* name with the full or relative path. The relative path is preferable * when the path is a sub path of these default paths. Note we accept only sub paths
* because it preserves use of default libraries paths, when the path * not relative paths starting by ../ that are not subpaths and are outside KiCad library
* is a sub path of these default paths. Note we accept only sub paths * paths
* not relative paths starting by ../ that are not subpaths and are
* outside kicad libs paths
* *
* @param aFullFilename The filename with path and extension. * @param aFullFilename The filename with path and extension.
* @param aBaseDir The absolute path on which relative paths in this * @param aBaseDir The absolute path on which relative paths in this SEARCH_STACK are
* SEARCH_STACK are based. * based.
* @return a short filename (with extension) with only a relative path if * @return a short filename (with extension) with only a relative path if
* this filename can be found in library paths * this filename can be found in library paths
*/ */
wxString FilenameWithRelativePathInSearchList( wxString FilenameWithRelativePathInSearchList( const wxString& aFullFilename,
const wxString& aFullFilename, const wxString& aBaseDir ); const wxString& aBaseDir );
wxString FindValidPath( const wxString& aFileName ) const 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 * @param aPaths path or path list to add. paths must be separated by ";" on windows,
* separated by ";" on windows, or ":" | ";" on unix. * or ":" | ";" on unix.
* * @param aIndex insertion point, -1 for append.
* @param aIndex = insertion point, -1 for append.
*/ */
void AddPaths( const wxString& aPaths, int aIndex = -1 ); void AddPaths( const wxString& aPaths, int aIndex = -1 );
/** /**
* Function RemovePaths * Remove the given path(s) from the library path list.
* 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 * @param aPaths path or list of paths to remove. If list, paths must be separated by
* ";" on windows, or ":" | ";" on unix. * ";" on windows, or ":" | ";" on unix.
*/ */
void RemovePaths( const wxString& aPaths ); void RemovePaths( const wxString& aPaths );
/** /**
* Function Split * Separate \a aPathString into individual paths.
* separates aPathString into individual paths. *
* @param aResult is where to put the paths, it should be empty upon entry. * @param aResult is where to put the paths, it should be empty upon entry.
* @param aPathString is concatonated string with interposing ';' or ':' separators. * @param aPathString is concatenated string with interposing ';' or ':' separators.
* @return int - the count of paths found in aPathString * @return the count of paths found in \a aPathString
*/ */
static int Split( wxArrayString* aResult, const wxString& aPathString ); static int Split( wxArrayString* aResult, const wxString& aPathString );
#if 1 // this function is so poorly designed it deserves not to exist. #if 1 // this function is so poorly designed it deserves not to exist.
/** /**
* Function LastVisitedPath * A quirky function inherited from old code that seems to serve particular needs in
* is a quirky function inherited from old code that seems to serve particular * the UI.
* 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 * It returns what is called the last visited directory or if \a aSubPathToSearch is
* ( but not the CWD ). * empty, the first path in this SEARCH_STACK ( but not the CWD ).
* *
* @todo add more here if you can figure it out. * @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 ); const wxString LastVisitedPath( const wxString& aSubPathToSearch = wxEmptyString );
#endif #endif

View File

@ -2,6 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2014-2015 CERN * Copyright (C) 2014-2015 CERN
* Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
* Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch> * Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
@ -36,8 +37,6 @@
class EDA_DRAW_FRAME; class EDA_DRAW_FRAME;
/** /**
* STATUS_POPUP
*
* A tiny, headerless popup window used to display useful status (e.g. line length * A tiny, headerless popup window used to display useful status (e.g. line length
* tuning info) next to the mouse cursor. * tuning info) next to the mouse cursor.
*/ */
@ -54,7 +53,7 @@ public:
virtual void Move( const VECTOR2I& aWhere ); 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 * @param aMsecs is the time expressed in milliseconds
*/ */
@ -75,9 +74,7 @@ protected:
/** /**
* STATUS_TEXT_POPUP * Extension of #STATUS_POPUP for displaying a single line text.
*
* Extension of STATUS_POPUP, displaying a single line text.
*/ */
class STATUS_TEXT_POPUP : public STATUS_POPUP class STATUS_TEXT_POPUP : public STATUS_POPUP
{ {
@ -87,12 +84,14 @@ public:
/** /**
* Display a text. * Display a text.
*
* @param aText is the text to be displayed. * @param aText is the text to be displayed.
*/ */
void SetText( const wxString& aText ); void SetText( const wxString& aText );
/** /**
* Change text color. * Change text color.
*
* @param aColor is the new text color. * @param aColor is the new text color.
*/ */
void SetTextColor( const wxColour& aColor ); void SetTextColor( const wxColour& aColor );

View File

@ -2,6 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * 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) 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 * 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 * under the terms of the GNU General Public License as published by the
@ -34,7 +35,8 @@
#define OPEN_OSTREAM( var, name ) \ #define OPEN_OSTREAM( var, name ) \
kicad::stream var##_BUF_; \ kicad::stream var##_BUF_; \
std::ostream& var = *var ## _BUF_.Open( name, std::ios_base::out | std::ios_base::trunc | std::ios_base::binary ) std::ostream& var = *var##_BUF_.Open( name, std::ios_base::out | std::ios_base::trunc \
| std::ios_base::binary )
#define OPEN_ISTREAM( var, name ) \ #define OPEN_ISTREAM( var, name ) \
kicad::stream var##_BUF_; \ kicad::stream var##_BUF_; \
@ -42,7 +44,8 @@
#define OPEN_IOSTREAM( var, name ) \ #define OPEN_IOSTREAM( var, name ) \
kicad::stream var##_BUF_; \ kicad::stream var##_BUF_; \
std::iostream& var = *var ## _BUF_.Open( name, std::ios_base::out | std::ios_base::in | std::ios_base::binary ) 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()
@ -52,8 +55,7 @@
namespace kicad namespace kicad
{ {
/** /**
* class stream is equivalent to std::stream, but accept UTF8 chars * This is equivalent to std::stream but accepts UTF8 chars in filenames.
* in filenames
*/ */
class stream class stream
{ {
@ -70,7 +72,7 @@
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__ )

View File

@ -1,7 +1,7 @@
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * 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 * 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 * 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 * 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). * 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: public:
SYNC_QUEUE() SYNC_QUEUE()
{ {
@ -58,10 +54,11 @@ public:
} }
/** /**
* Pop a value off the queue into the provided variable. If the queue is empty, the * Pop a value if the queue into the provided variable.
* variable is not touched.
* *
* @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 ) 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 bool empty() const
{ {
@ -109,6 +106,12 @@ public:
m_queue.pop(); 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 #endif // SYNC_QUEUE_H

View File

@ -1,7 +1,7 @@
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * 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 * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -32,10 +32,8 @@
class SEARCH_STACK; class SEARCH_STACK;
/** /**
* Function SystemDirsAppend * Append system places to \a aSearchStack in a platform specific way and pertinent
* appends system places to aSearchStack in a platform specific way, and pertinent * to KiCad programs.
* to KiCad programs. It seems to be a place to collect bad ideas and keep them
* out of view.
*/ */
void SystemDirsAppend( SEARCH_STACK* aSearchStack ); void SystemDirsAppend( SEARCH_STACK* aSearchStack );

View File

@ -33,12 +33,11 @@ class TEMPLATE_FIELDNAMES_LEXER;
/** /**
* Enum NumFieldType * The set of all field indices assuming an array like sequence that a SCH_COMPONENT or
* is the set of all field indices assuming an array like sequence that a * LIB_PART can hold.
* SCH_COMPONENT or LIB_PART can hold. *
* The first fields are called fixed fields and the quantity of them is * The first fields are fixed fields and are defined by #MANDATORY_FIELDS. After that come
* given by MANDATORY_FIELDS. After that come an unlimited number of * an unlimited number of user defined fields, only some of which have indices defined here.
* user defined fields, only some of which have indices defined here.
*/ */
enum NumFieldType { enum NumFieldType {
REFERENCE_FIELD = 0, ///< Field Reference of part, i.e. "IC21" REFERENCE_FIELD = 0, ///< Field Reference of part, i.e. "IC21"
@ -62,17 +61,12 @@ enum NumFieldType {
/** /**
* Struct TEMPLATE_FIELDNAME * Hold a name of a symbol's field, field value, and default visibility.
* holds a name of a component's field, field value, and default visibility. *
* Template fieldnames are wanted fieldnames for use in the symbol/component * Template fieldnames are wanted field names for use in the symbol property editors.
* property editors.
*/ */
struct TEMPLATE_FIELDNAME 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() : TEMPLATE_FIELDNAME() :
m_Visible( false ), m_Visible( false ),
m_URL( false ) m_URL( false )
@ -94,34 +88,37 @@ struct TEMPLATE_FIELDNAME
} }
/** /**
* Function Format * Serialize this object out as text into the given #OUTPUTFORMATTER.
* serializes this object out as text into the given OUTPUTFORMATTER.
*/ */
void Format( OUTPUTFORMATTER* out, int nestLevel ) const ; void Format( OUTPUTFORMATTER* out, int nestLevel ) const ;
/** /**
* Function Parse * Fill this object from information in the input stream \a aSpec, which is a
* fills this object from information in the input stream \a aSpec, which * #TEMPLATE_FIELDNAMES_LEXER.
* is a TEMPLATE_FIELDNAMES_LEXER. The entire textual element spec is <br> *
* (field (name _yourfieldname_)(value _yourvalue_) visible)) <br> * The entire textual element spec is <br>(field (name _yourfieldname_)(value _yourvalue_)
* The presence of value is optional, the presence of visible is optional. * 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 * When this function is called, the input token stream given by \a aSpec is assumed to be
* is assumed to be positioned at the '^' in the following example, i.e. just after the * positioned at the '^' in the following example, i.e. just after the identifying keyword
* identifying keyword and before the content specifying stuff.<br> * and before the content specifying stuff.<br>(field ^ (....) )</br>.
* (field ^ (....) )
* *
* @param aSpec is the input token stream of keywords and symbols. * @param aSpec is the input token stream of keywords and symbols.
*/ */
void Parse( TEMPLATE_FIELDNAMES_LEXER* aSpec ); void Parse( TEMPLATE_FIELDNAMES_LEXER* aSpec );
/** /**
* Function GetDefaultFieldName * Return a default symbol field name for field \a aFieldNdx for all components.
* returns a default symbol field name for field \a aFieldNdx for all components. *
* These fieldnames are not modifiable, but template fieldnames are. * 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 * @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 ); 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; typedef std::vector< TEMPLATE_FIELDNAME > TEMPLATE_FIELDNAMES;
@ -129,37 +126,28 @@ typedef std::vector< TEMPLATE_FIELDNAME > TEMPLATE_FIELDNAMES;
class TEMPLATES class TEMPLATES
{ {
private:
TEMPLATE_FIELDNAMES m_globals;
TEMPLATE_FIELDNAMES m_project;
// Combined list. Project templates override global ones.
TEMPLATE_FIELDNAMES m_resolved;
bool m_resolvedDirty;
public: public:
TEMPLATES() : TEMPLATES() :
m_resolvedDirty( true ) m_resolvedDirty( true )
{ } { }
/** /**
* Function Format * Serialize this object out as text into the given #OUTPUTFORMATTER.
* serializes this object out as text into the given OUTPUTFORMATTER.
*/ */
void Format( OUTPUTFORMATTER* out, int nestLevel, bool aGlobal ) const ; void Format( OUTPUTFORMATTER* out, int nestLevel, bool aGlobal ) const ;
/** /**
* Function Parse * Fill this object from information in the input stream handled by
* fills this object from information in the input stream handled by TEMPLATE_FIELDNAMES_LEXER * #TEMPLATE_FIELDNAMES_LEXER.
*/ */
void Parse( TEMPLATE_FIELDNAMES_LEXER* in, bool aGlobal ); void Parse( TEMPLATE_FIELDNAMES_LEXER* in, bool aGlobal );
/** /**
* Function AddTemplateFieldName * Insert or append a wanted symbol field name into the field names template.
* inserts or appends a wanted symbol field name into the fieldnames *
* template. Should be used for any symbol property editor. If the name * Should be used for any symbol property editor. If the name already exists, it
* already exists, it overwrites the same name. * overwrites the same name.
* *
* @param aFieldName is a full description of the wanted field, and it must not match * @param aFieldName is a full description of the wanted field, and it must not match
* any of the default field names. * any of the default field names.
@ -168,26 +156,22 @@ public:
void AddTemplateFieldName( const TEMPLATE_FIELDNAME& aFieldName, bool aGlobal ); void AddTemplateFieldName( const TEMPLATE_FIELDNAME& aFieldName, bool aGlobal );
/** /**
* Function DeleteAllFieldNameTemplates * Delete the entire contents.
* deletes the entire contents.
*/ */
void DeleteAllFieldNameTemplates( bool aGlobal ); void DeleteAllFieldNameTemplates( bool aGlobal );
/** /**
* Function GetTemplateFieldName * Return a template field name list for read only access.
* returns a template fieldnames list for read only access.
*/ */
const TEMPLATE_FIELDNAMES& GetTemplateFieldNames(); const TEMPLATE_FIELDNAMES& GetTemplateFieldNames();
/** /**
* Function GetTemplateFieldName * Return a specific list (global or project) for read only access.
* returns a specific list (global or project) for read only access.
*/ */
const TEMPLATE_FIELDNAMES& GetTemplateFieldNames( bool aGlobal ); const TEMPLATE_FIELDNAMES& GetTemplateFieldNames( bool aGlobal );
/** /**
* Function GetFieldName * Search for \a aName in the the template field name list.
* searches for \a aName in the the template field name list.
* *
* @param aName A wxString object containing the field name to search for. * @param aName A wxString object containing the field name to search for.
* @return the template field name if found; NULL otherwise. * @return the template field name if found; NULL otherwise.
@ -197,6 +181,13 @@ public:
protected: protected:
void resolveTemplates(); void resolveTemplates();
private:
TEMPLATE_FIELDNAMES m_globals;
TEMPLATE_FIELDNAMES m_project;
// Combined list. Project templates override global ones.
TEMPLATE_FIELDNAMES m_resolved;
bool m_resolvedDirty;
}; };
#endif // _TEMPLATE_FIELDNAME_H_ #endif // _TEMPLATE_FIELDNAME_H_

View File

@ -1,7 +1,7 @@
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * 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 * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -28,9 +28,9 @@
#include <wx/textentry.h> #include <wx/textentry.h>
/** /**
* TEXTENTRY_TRICKS * Add cut/copy/paste to a wxTextEntry instance.
* 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. * While these are normally handled without our intervention, this is not always the case.
*/ */
struct TEXTENTRY_TRICKS struct TEXTENTRY_TRICKS
{ {

View File

@ -1,7 +1,7 @@
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * 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 * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -31,8 +31,7 @@
class OUTPUTFORMATTER; class OUTPUTFORMATTER;
/** /**
* TITLE_BLOCK * Hold the information shown in the lower right corner of a plot, printout, or
* holds the information shown in the lower right corner of a plot, printout, or
* editing view. * editing view.
* *
* @author Dick Hollenbeck * @author Dick Hollenbeck
@ -52,7 +51,6 @@ class TITLE_BLOCK
}; };
public: public:
TITLE_BLOCK() {}; TITLE_BLOCK() {};
virtual ~TITLE_BLOCK() {}; // a virtual dtor seems needed to build virtual ~TITLE_BLOCK() {}; // a virtual dtor seems needed to build
// python lib without warning // python lib without warning
@ -68,8 +66,7 @@ public:
} }
/** /**
* Function SetDate * Set the date field, and defaults to the current time and date.
* sets the date field, and defaults to the current time and date.
*/ */
void SetDate( const wxString& aDate ) void SetDate( const wxString& aDate )
{ {
@ -119,8 +116,7 @@ public:
} }
/** /**
* Function Format * Output the object to \a aFormatter in s-expression form.
* outputs the object to \a aFormatter in s-expression form.
* *
* @param aFormatter The #OUTPUTFORMATTER object to write to. * @param aFormatter The #OUTPUTFORMATTER object to write to.
* @param aNestLevel The indentation next level. * @param aNestLevel The indentation next level.
@ -136,6 +132,7 @@ private:
{ {
if( (int)m_tbTexts.GetCount() <= aIdx ) if( (int)m_tbTexts.GetCount() <= aIdx )
m_tbTexts.Add( wxEmptyString, aIdx + 1 - m_tbTexts.GetCount() ); m_tbTexts.Add( wxEmptyString, aIdx + 1 - m_tbTexts.GetCount() );
m_tbTexts[aIdx] = aText; m_tbTexts[aIdx] = aText;
} }

View File

@ -2,8 +2,8 @@
* This program source code file is part of KiCad, a free EDA CAD application. * 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) 2009 jean-pierre.charras@gipsa-lab.inpg.fr
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net> * Copyright (C) 2011 Wayne Stambaugh <stambaughw@gmail.com>
* Copyright (C) 2009 KiCad Developers, see change_log.txt for contributors. * Copyright (C) 2009-2020 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * 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 { enum class UNDO_REDO {
UNSPECIFIED = 0, // illegal UNSPECIFIED = 0, // illegal
@ -77,29 +79,11 @@ enum class UNDO_REDO {
class ITEM_PICKER 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: public:
// ITEM_PICKER( EDA_ITEM* aItem = NULL, UNDO_REDO aStatus = UNSPECIFIED ); // ITEM_PICKER( EDA_ITEM* aItem = NULL, UNDO_REDO aStatus = UNSPECIFIED );
ITEM_PICKER(); 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; } EDA_ITEM* GetItem() const { return m_pickedItem; }
@ -124,12 +108,32 @@ public:
EDA_ITEM* GetLink() const { return m_link; } EDA_ITEM* GetLink() const { return m_link; }
BASE_SCREEN* GetScreen() const { return m_screen; } 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 * A holder to handle information on schematic or board items.
* is a holder to handle information on schematic or board items. *
* The information held is a pointer on each item, and the command made. * The information held is a pointer on each item, and the command made.
*/ */
class PICKED_ITEMS_LIST class PICKED_ITEMS_LIST
@ -148,46 +152,40 @@ public:
~PICKED_ITEMS_LIST(); ~PICKED_ITEMS_LIST();
/** /**
* Function PushItem * Push \a aItem to the top of the list.
* pushes \a aItem to the top of the list *
* @param aItem Picker to push on to the list. * @param aItem Picker to push on to the list.
*/ */
void PushItem( const ITEM_PICKER& aItem ); void PushItem( const ITEM_PICKER& aItem );
/** /**
* Function PopItem
* @return The picker removed from the top of the list. * @return The picker removed from the top of the list.
*/ */
ITEM_PICKER PopItem(); ITEM_PICKER PopItem();
/** /**
* Function IsItemInList
* @return True if \a aItem is found in the pick list. * @return True if \a aItem is found in the pick list.
*/ */
bool ContainsItem( const EDA_ITEM* aItem ) const; 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 * @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; int FindItem( const EDA_ITEM* aItem ) const;
/** /**
* Function ClearItemsList * Delete only the list of pickers NOT the picked data itself.
* deletes only the list of pickers, NOT the picked data itself.
*/ */
void ClearItemsList(); void ClearItemsList();
/** /**
* Function ClearListAndDeleteItems * Delete the list of pickers AND the data pointed by #m_PickedItem or #m_PickedItemLink
* deletes the list of pickers, AND the data pointed by m_PickedItem or * according to the type of undo/redo command recorded.
* m_PickedItemLink, according to the type of undo/redo command recorded
*/ */
void ClearListAndDeleteItems(); void ClearListAndDeleteItems();
/** /**
* Function GetCount
* @return The count of pickers stored in this list. * @return The count of pickers stored in this list.
*/ */
unsigned GetCount() const unsigned GetCount() const
@ -196,9 +194,8 @@ public:
} }
/** /**
* Function ReversePickersListOrder * Reverse the order of pickers stored in this list.
* reverses the order of pickers stored in this list. *
* <p>
* This is useful when pop a list from Undo to Redo (and vice-versa) because * 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 * sometimes undo (or redo) a command needs to keep the order of successive
* changes. Obviously, undo and redo are in reverse order * changes. Obviously, undo and redo are in reverse order
@ -206,80 +203,72 @@ public:
void ReversePickersListOrder(); void ReversePickersListOrder();
/** /**
* Function GetItemWrapper
* @return The picker of a picked item. * @return The picker of a picked item.
* @param aIdx Index of the picker in the picked list * @param aIdx Index of the picker in the picked list if this picker does not exist,
* if this picker does not exist, a picker is returned, * a picker is returned, with its members set to 0 or NULL.
* with its members set to 0 or NULL
*/ */
ITEM_PICKER GetItemWrapper( unsigned int aIdx ) const; ITEM_PICKER GetItemWrapper( unsigned int aIdx ) const;
/** /**
* Function GetPickedItem * @return A pointer to the picked item.
* @return A pointer to the picked item * @param aIdx Index of the picked item in the picked list.
* @param aIdx Index of the picked item in the picked list
*/ */
EDA_ITEM* GetPickedItem( unsigned int aIdx ) const; EDA_ITEM* GetPickedItem( unsigned int aIdx ) const;
/** /**
* Function GetScreenForItem * @return A pointer to the picked item's sceen.
* @return A pointer to the picked item's sceen * @param aIdx Index of the picked item in the picked list.
* @param aIdx Index of the picked item in the picked list
*/ */
BASE_SCREEN* GetScreenForItem( unsigned int aIdx ) const; BASE_SCREEN* GetScreenForItem( unsigned int aIdx ) const;
/** /**
* Function GetPickedItemLink * @return link of the picked item, or null if does not exist.
* @return link of the picked item, or null if does not exist * @param aIdx Index of the picked item in the picked list.
* @param aIdx Index of the picked item in the picked list
*/ */
EDA_ITEM* GetPickedItemLink( unsigned int aIdx ) const; EDA_ITEM* GetPickedItemLink( unsigned int aIdx ) const;
/** /**
* Function GetPickedItemStatus
* @return The type of undo/redo operation associated to the picked item, * @return The type of undo/redo operation associated to the picked item,
* or UNSPECIFIED if does not exist * or UNSPECIFIED if does not exist.
* @param aIdx Index of the picked item in the picked list * @param aIdx Index of the picked item in the picked list.
*/ */
UNDO_REDO GetPickedItemStatus( unsigned int aIdx ) const; UNDO_REDO GetPickedItemStatus( unsigned int aIdx ) const;
/** /**
* Function GetPickerFlags * Return the value of the picker flag.
* returns the value of the picker flag. *
* @param aIdx Index of the picker in the picked list * @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 stored in the picker, if the picker exists, or 0 if does not exist.
*/ */
STATUS_FLAGS GetPickerFlags( unsigned aIdx ) const; STATUS_FLAGS GetPickerFlags( unsigned aIdx ) const;
/** /**
* Function SetPickedItem * @param aItem A pointer to the item to pick.
* @param aItem A pointer to the item to pick * @param aIdx Index of the picker in the picked list.
* @param aIdx Index of the picker in the picked list * @return True if the picker exists or false if does not exist.
* @return True if the picker exists or false if does not exist
*/ */
bool SetPickedItem( EDA_ITEM* aItem, unsigned aIdx ); bool SetPickedItem( EDA_ITEM* aItem, unsigned aIdx );
/** /**
* Function SetPickedItem * @param aItem A pointer to the item to pick.
* @param aItem A pointer to the item to pick * @param aStatus The type of undo/redo operation associated 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.
* @param aIdx Index of the picker in the picked list * @return True if the picker exists or false if does not exist.
* @return True if the picker exists or false if does not exist
*/ */
bool SetPickedItem( EDA_ITEM* aItem, UNDO_REDO aStatus, unsigned aIdx ); bool SetPickedItem( EDA_ITEM* aItem, UNDO_REDO aStatus, unsigned aIdx );
/** /**
* Function SetPickedItemLink * Set the link associated to a given picked item.
* set the link associated to a given picked item. *
* @param aLink = the link to the item associated to the picked item * @param aLink is the link to the item associated to the picked item.
* @param aIdx = index of the picker in the picked list * @param aIdx is index of the picker in the picked list.
* @return true if the picker exists, or false if does not exist * @return true if the picker exists, or false if does not exist.
*/ */
bool SetPickedItemLink( EDA_ITEM* aLink, unsigned aIdx ); bool SetPickedItemLink( EDA_ITEM* aLink, unsigned aIdx );
/** /**
* Function SetPickedItemStatus * Set the type of undo/redo operation for a given picked item.
* sets 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 aStatus The type of undo/redo operation associated to the picked item
* @param aIdx Index of the picker in the picked list * @param aIdx Index of the picker in the picked list
* @return True if the picker exists or false if does not exist * @return True if the picker exists or false if does not exist
@ -287,26 +276,27 @@ public:
bool SetPickedItemStatus( UNDO_REDO aStatus, unsigned aIdx ); bool SetPickedItemStatus( UNDO_REDO aStatus, unsigned aIdx );
/** /**
* Function SetPickerFlags * Set the flags of the picker (usually to the picked item m_flags value).
* set the flags of the picker (usually to the picked item m_flags value) *
* @param aFlags The flag value to save in picker * @param aFlags The flag value to save in picker.
* @param aIdx Index of the picker in the picked list * @param aIdx Index of the picker in the picked list.
* @return True if the picker exists or false if does not exist * @return True if the picker exists or false if does not exist.
*/ */
bool SetPickerFlags( STATUS_FLAGS aFlags, unsigned aIdx ); bool SetPickerFlags( STATUS_FLAGS aFlags, unsigned aIdx );
/** /**
* Function RemovePicker * Remove one entry (one picker) from the list of picked items.
* removes one entry (one picker) from the list of picked items. *
* @param aIdx Index of the picker in the picked list * @param aIdx Index of the picker in the picked list.
* @return True if ok or false if did not exist * @return True if ok or false if did not exist.
*/ */
bool RemovePicker( unsigned aIdx ); bool RemovePicker( unsigned aIdx );
/** /**
* Function CopyList * Copy all data from aSource to the list.
* copies all data from aSource to the list. *
* Items picked are not copied. just pointer in them are copied * Items picked are not copied. just pointer in them are copied.
*
* @param aSource The list of items to copy to the list. * @param aSource The list of items to copy to the list.
*/ */
void CopyList( const PICKED_ITEMS_LIST& aSource ); void CopyList( const PICKED_ITEMS_LIST& aSource );
@ -314,17 +304,11 @@ public:
/** /**
* UNDO_REDO_CONTAINER * A holder to handle a list of undo (or redo) commands.
* 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).
*/ */
class UNDO_REDO_CONTAINER class UNDO_REDO_CONTAINER
{ {
public: public:
std::vector <PICKED_ITEMS_LIST*> m_CommandsList; // the list of possible undo/redo commands
public:
UNDO_REDO_CONTAINER(); UNDO_REDO_CONTAINER();
~UNDO_REDO_CONTAINER(); ~UNDO_REDO_CONTAINER();
@ -333,6 +317,8 @@ public:
PICKED_ITEMS_LIST* PopCommand(); PICKED_ITEMS_LIST* PopCommand();
void ClearCommandList(); void ClearCommandList();
std::vector <PICKED_ITEMS_LIST*> m_CommandsList; // the list of possible undo/redo commands
}; };

View File

@ -2,7 +2,9 @@
* This program source code file is part of KiCad, a free EDA CAD application. * 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 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 * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -34,9 +36,9 @@
/** /**
* Function IsUTF8 * Test a C string to see if it is UTF8 encoded.
* tests a c-string to see if it is UTF8 encoded. BTW an ASCII string is a valid *
* UTF8 string. * An ASCII string is a valid UTF8 string.
*/ */
bool IsUTF8( const char* aString ); bool IsUTF8( const char* aString );
@ -49,31 +51,25 @@ bool IsUTF8( const char* aString );
/** /**
* UTF8 * An 8 bit string that is assuredly encoded in UTF8, and supplies special conversion
* is an 8 bit string that is assuredly encoded in UTF8, and supplies special * support to and from wxString, to and from std::string, and has non-mutating iteration
* conversion support to and from wxString, to and from std::string, and has * over Unicode characters.
* non-mutating iteration over unicode characters.
* *
* <p>I've been careful to supply only conversion facilities and not try * I've been careful to supply only conversion facilities and not try and duplicate
* and duplicate wxString() with many member functions. There are multiple ways * wxString() with many member functions. There are multiple ways to create text into
* to create text into a std::string without the need of too many member functions: * a std::string without the need of too many member functions:
* *
* <ul> * - richio.h's StrPrintf().
* <li>richio.h's StrPrintf()</li> * - std::ostringstream.
* <li>std::ostringstream.</li>
* </ul>
* *
* <p>Because this class used no virtuals, it should be possible to cast any * Because this class uses no virtuals, it should be possible to cast any std::string
* std::string into a UTF8 using this kind of cast: (UTF8 &) without construction * into a UTF8 using this kind of cast: (UTF8 &) without construction or copying being
* or copying being the effect of the cast. Be sure the source std::string holds * the effect of the cast. Be sure the source std::string holds UTF8 encoded text before
* UTF8 encoded text before you do that. * you do that.
*
* @author Dick Hollenbeck
*/ */
class UTF8 class UTF8
{ {
public: public:
UTF8( const wxString& o ); UTF8( const wxString& o );
/// This is a constructor for which you could end up with /// 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. // expose some std::string functions publicly, since base class must be private.
const char* c_str() const { return m_s.c_str(); } const char* c_str() const { return m_s.c_str(); }
bool empty() const { return m_s.empty(); } 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 std::string& rhs ) const { return m_s == rhs; }
bool operator==( const char* s ) const { return m_s == s; } 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 ); return m_s.find_first_of( str, pos );
} }
@ -206,19 +202,7 @@ public:
*/ */
class uni_iter class uni_iter
{ {
friend class UTF8;
const unsigned char* it;
// private constructor
uni_iter( const char* start ) :
it( (const unsigned char*) start )
{
}
public: public:
uni_iter() // Needed only to build python wrapper, not used outside the wrapper uni_iter() // Needed only to build python wrapper, not used outside the wrapper
{ {
it = NULL; 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; } 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 uni_iter ubegin() const
{ {
@ -288,8 +282,7 @@ public:
} }
/** /**
* Function uend * Return a @a uni_iter initialized to the end of "this" UTF8 byte sequence.
* returns a @a uni_iter initialized to the end of "this" UTF8 byte sequence.
*/ */
uni_iter uend() const uni_iter uend() const
{ {
@ -297,13 +290,12 @@ public:
} }
/** /**
* Function uni_forward * Advance over a single UTF8 encoded multibyte character, capturing the Unicode character
* advances over a single UTF8 encoded multibyte character, capturing the * as it goes, and returning the number of bytes consumed.
* 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 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. * @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 ); static int uni_forward( const unsigned char* aSequence, unsigned* aResult = NULL );
#endif // SWIG #endif // SWIG

View File

@ -27,7 +27,7 @@
#include <wx/filename.h> #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() * 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 * and string concatenations by caching the path and filename locally and only resolving

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * 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) 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 * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -36,26 +36,25 @@
/** /**
* XNODE * Hold an XML or S-expression element.
* holds an XML or S-expression element. It is used for eXporting *
* a document tree in EITHER XML or S-expression. * It is used for exporting a document tree in either XML or S-expression.
*/ */
class XNODE : public wxXmlNode class XNODE : public wxXmlNode
{ {
public: public:
//-----<overloads>---------------------------------------------------------
XNODE() : XNODE() :
wxXmlNode() wxXmlNode()
{ {
} }
XNODE( wxXmlNodeType aType, const wxString& aName, const wxString& aContent = wxEmptyString ) : 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, 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 ) wxXmlNode( aParent, aType, aName, aContent, aProperties )
{ {
} }
@ -74,23 +73,23 @@ public:
{ {
return (XNODE* )wxXmlNode::GetParent(); return (XNODE* )wxXmlNode::GetParent();
} }
//-----</overloads>--------------------------------------------------------
/** /**
* Function Format * Write this object as #UTF8 out to an #OUTPUTFORMATTER as an S-expression.
* writes this object as UTF8 out to an OUTPUTFORMATTER as an S-expression. *
* @param out The formatter to write to. * @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. * @throw IO_ERROR if a system error writing the output, such as a full disk.
*/ */
virtual void Format( OUTPUTFORMATTER* out, int nestLevel ); virtual void Format( OUTPUTFORMATTER* out, int nestLevel );
/** /**
* Function FormatContents * Write the contents of object as #UTF8 out to an #OUTPUTFORMATTER as an S-expression.
* writes 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. * This is the same as Format() except that the outer wrapper is not included.
*
* @param out The formatter to write to. * @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. * @throw IO_ERROR if a system error writing the output, such as a full disk.
*/ */
virtual void FormatContents( OUTPUTFORMATTER* out, int nestLevel ); virtual void FormatContents( OUTPUTFORMATTER* out, int nestLevel );