现在我有一个大型 C++ 项目,由大约 1400k 行代码组成。现在我有一个要求:向从CDialog、CWnd或CListCtrl派生的每个类添加一行代码。我手动完成此操作是不可能的。我想也许UltraEdit正则表达式可以帮我一把,但我自己不会写相关的正则表达式。
有人可以帮助我吗?
这是要添加的代码行:
virtual ULONG GetGestureStatus(CPoint ptTouch) { return 0;}
这是我的代码结构(仅供引用):
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;
};
最佳答案
假设您想将该行放在开头 {
之后,请尝试搜索(打开 Perl 正则表达式):
^(class\b.*\bC(?:Dialog|Wnd|ListCtrl).*\r?\n\{\r?\n)
并替换为
\1virtual ULONG GetGestureStatus(CPoint ptTouch) { return 0;}\r\n
关于regex - UE中如何编写正则表达式来实现这个需求呢?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17695682/