| ¶Ô±ÈÐÂÎļþ |
| | |
| | | #if !defined(AFX_REGEXEDIT_H__A4EABEC5_2E8C_11D1_B79F_00805F9ECE10__INCLUDED_) |
| | | #define AFX_REGEXEDIT_H__A4EABEC5_2E8C_11D1_B79F_00805F9ECE10__INCLUDED_ |
| | | |
| | | #if _MSC_VER >= 1000 |
| | | #pragma once |
| | | #endif // _MSC_VER >= 1000 |
| | | |
| | | #include <afxwin.h> |
| | | #include <regex> |
| | | #include <functional> |
| | | #include <limits> |
| | | |
| | | // æä¸¾ç±»åï¼æ£å表达å¼ç±»å |
| | | enum class RegexType |
| | | { |
| | | Alphanumeric, // å
è®¸åæ¯åæ°å |
| | | Letters, // åªå
è®¸åæ¯ |
| | | Digits, // åªå
许æ°å |
| | | Decimal, // å
è®¸å°æ°åæ´æ° |
| | | Custom // èªå®ä¹æ£å |
| | | }; |
| | | |
| | | class CRegexEdit : public CEdit |
| | | { |
| | | DECLARE_DYNAMIC(CRegexEdit) |
| | | |
| | | public: |
| | | // æé 䏿æ |
| | | CRegexEdit(); |
| | | virtual ~CRegexEdit(); |
| | | |
| | | // 设置æ£åç±»å |
| | | void SetRegexType(RegexType enType); |
| | | |
| | | // 设置èªå®ä¹æ£åè¡¨è¾¾å¼ |
| | | void SetCustomRegex(const std::string& strCustomRegex); |
| | | |
| | | // 设置æ°å¼èå´ï¼æ´æ°ææµ®ç¹ï¼ |
| | | void SetValueRange(long double dMinValue, long double dMaxValue); |
| | | |
| | | // 设置èªå®ä¹æ¯è¾å½æ° |
| | | void SetCustomComparator(std::function<bool(const std::string&)> comparator); |
| | | |
| | | // 设置è¾å
¥ä¸åæ³å½æ° |
| | | void SetInvalidInputCallback(std::function<void()> callback); |
| | | |
| | | // æ¥æ¾å¹é
å
容 |
| | | bool FindMatch(const std::string& pattern, std::string& foundText); |
| | | |
| | | // æ¿æ¢å¹é
å
容 |
| | | void ReplaceMatch(const std::string& pattern, const std::string& replacement); |
| | | |
| | | protected: |
| | | // æ ¹æ®æä¸¾å¼è¿å对åºçæ£åè¡¨è¾¾å¼ |
| | | std::regex GetCurrentRegex() const; |
| | | |
| | | // æ ¡éªè¾å
¥æ¯å¦å¨æå®èå´å
|
| | | bool IsValueInRange(const std::string& strText); |
| | | |
| | | protected: |
| | | RegexType m_enRegexType; // å½åéä¸çæ£åç±»å |
| | | std::string m_strCustomRegex; // èªå®ä¹æ£åè¡¨è¾¾å¼ |
| | | long double m_dMinValue; // æå°å¼ |
| | | long double m_dMaxValue; // æå¤§å¼ |
| | | |
| | | std::function<bool(const std::string&)> m_customComparator; // èªå®ä¹æ¯è¾å½æ° |
| | | std::function<void()> m_invalidInputCallback; // ä¸åæ³è¾å
¥çåè°å½æ° |
| | | |
| | | protected: |
| | | void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags); |
| | | DECLARE_MESSAGE_MAP() |
| | | }; |
| | | |
| | | #endif // !defined(AFX_REGEXEDIT_H__A4EABEC5_2E8C_11D1_B79F_00805F9ECE10__INCLUDED_) |