• R/O
  • SSH
  • HTTPS

gtaconfig: 提交


Commit MetaInfo

修訂39 (tree)
時間2019-08-02 20:27:35
作者quiret

Log Message

- added more syntax helper methods

Change Summary

差異

--- include/gtaconfig/syntax.h (revision 38)
+++ include/gtaconfig/syntax.h (revision 39)
@@ -17,6 +17,14 @@
1717 NUMERIC,
1818 SINGLE
1919 };
20+
21+ enum class eCharacterClass
22+ {
23+ NAME,
24+ NUMERIC,
25+ WHITESPACE,
26+ RENDERABLE
27+ };
2028 };
2129
2230 template <typename encodingCharType>
@@ -678,6 +686,27 @@
678686 return true;
679687 }
680688 template <typename checkCharType>
689+ bool HasCharacter(checkCharType cp, bool case_sensitive = true)
690+ {
691+ if ( Finished() )
692+ {
693+ return false;
694+ }
695+
696+ size_t our_ucp_len;
697+
698+ auto our_ucp = this->ReadNext( our_ucp_len );
699+
700+ if ( IsCharacterEqual( cp, our_ucp, case_sensitive ) )
701+ {
702+ return true;
703+ }
704+
705+ this->DecreaseSeek( our_ucp_len );
706+
707+ return false;
708+ }
709+ template <typename checkCharType>
681710 void ExpectToken(const checkCharType *tokenStr)
682711 {
683712 size_t tokenLen;
@@ -1028,7 +1057,55 @@
10281057 {
10291058 return ScanStringLen( string, cplen_tozero( string ), findOff, caseSensitive );
10301059 }
1060+ template <typename checkCharType>
1061+ const encodingCharType* ScanStringObviousLen( const checkCharType *string, size_t strLen, bool caseSensitive = true, bool *didFindOut = nullptr )
1062+ {
1063+ size_t findOff;
10311064
1065+ if ( !ScanStringLen( string, strLen, findOff, caseSensitive ) )
1066+ {
1067+ if ( didFindOut != nullptr )
1068+ {
1069+ *didFindOut = false;
1070+ }
1071+
1072+ return this->GetEndOfData();
1073+ }
1074+
1075+ if ( didFindOut != nullptr )
1076+ {
1077+ *didFindOut = true;
1078+ }
1079+
1080+ return ( this->m_buffer + findOff );
1081+ }
1082+ template <typename checkCharType>
1083+ const encodingCharType* ScanStringObvious( const checkCharType *string, bool caseSensitive = true, bool *didFindOut = nullptr )
1084+ {
1085+ return ScanStringObviousLen( string, cplen_tozero( string ), caseSensitive, didFindOut );
1086+ }
1087+
1088+ // Character class functions.
1089+ void ScanWhileCharacterClass( SyntaxHelpers::eCharacterClass charType )
1090+ {
1091+ while ( !Finished() )
1092+ {
1093+ size_t ucp_len;
1094+
1095+ auto ucp = this->ReadNext( ucp_len );
1096+
1097+ if ( ( charType == SyntaxHelpers::eCharacterClass::NUMERIC && !IsNumeric( ucp ) ) ||
1098+ ( charType == SyntaxHelpers::eCharacterClass::NAME && !IsName( ucp ) ) ||
1099+ ( charType == SyntaxHelpers::eCharacterClass::WHITESPACE && !IsSpace( ucp ) ) ||
1100+ ( charType == SyntaxHelpers::eCharacterClass::RENDERABLE && !is_char_renderable( ucp ) ) )
1101+ {
1102+ this->DecreaseSeek( ucp_len );
1103+
1104+ break;
1105+ }
1106+ }
1107+ }
1108+
10321109 const encodingCharType* GetCurrentData( void ) const
10331110 {
10341111 return ( m_buffer + m_offset );
Show on old repository browser