Frage

Now I have a large C++ project which is made up of about 1400k lines of code. Now I have a requirement: Add one line of code to each class which is derived from CDialog, CWnd or CListCtrl. It's impossible for me to do this manually. I think maybe UltraEdit regular expression can give me a hand, but I can't write related regular expression by myself.

Anybody can help me?

Here is the line of code to add:

virtual ULONG GetGestureStatus(CPoint ptTouch) { return 0;}

and here is my code structure(just for a illustration):

class CRibbonAddPlaceDialog : public CDialog
{
    DECLARE_DYNAMIC(CRibbonAddPlaceDialog)

public:
    CRibbonAddPlaceDialog();
    virtual ~CRibbonAddPlaceDialog();
    enum { IDD = IDD_RIBBON_ADDPLACE };

protected:
    virtual ULONG GetGestureStatus(CPoint ptTouch) { return 0;}//the line to add
    virtual void DoDataExchange(CDataExchange* pDX);
    DECLARE_MESSAGE_MAP()
    afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
    afx_msg void OnDestroy();
    virtual BOOL OnInitDialog();
    virtual BOOL OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo);
public:
    BOOL AddButton(CFX_WideString csTitle, AddPlaceButtonProc proc, void* pClientData, CFX_DIBitmap* pButtonImage);
public:

    CReader_RibbonFilePageManager* m_pRibbonFilePageMgr;
    CReader_RibbonStyle_Static*       m_pAddPlace;
    CReader_RibbonStyle_Static*       m_pAddPlaceTip;
    CTypedPtrArray<CPtrArray, buttondata*> m_arButtonData;
    CTypedPtrArray<CPtrArray, CBCGPButton*>m_arButton;

};
War es hilfreich?

Lösung

Assuming you want to place that line right after the opening {, try searching for (with Perl regexes turned on):

^(class\b.*\bC(?:Dialog|Wnd|ListCtrl).*\r?\n\{\r?\n)

and replace with

\1virtual ULONG GetGestureStatus(CPoint ptTouch) { return 0;}\r\n

Andere Tipps

perl -ibak -pe "s/protected:\n/protected:\n virtual ULONG GetGestureStatus(CPoint ptTouch) { return 0;}/" file_name

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top