The undocumented TParser class | La classe non-documentée TParser |
If you look in the Classes.hpp file, you'll find the undocumented TParser class. You can use this class to parse text into tokens. Spaces, tabs, doublequotes or empty lines are used as separators between tokens. A token can be a string, a numerical value like integers or float, an hexadecimal number or a single quoted string. TParser reads a FileStream, a StringStream or a memoryStream. | Dans le fichier Classes.hpp, il y a une classe non documentée : TParser. Vous pouvez utiliser cette classe pour récupérer les 'mots' qui composent un texte. TParser lit, en entrée, un stream. Ce stream peut être un FileStream, un MemoryStream ou un StringStream. Les espaces, les guillemets, les caractères de tabulation ou les lignes vides servent de séparateurs entre les 'mots'. Chaque 'mot' peut être un string, une valeur numérique comme un entier ou un float, un nombre hexadécimal ou un string délimité par un single quote (\'). |
Here is a brief description of some of the class properties and methods : | Voici une brève description de certaines propriétés et méthodes de la classe : |
Properties :
char Token read-only
Returns the type of the token.It could be
Renvoie le type de 'mot'. Il peut prendre la valeur
toEOF //End of Stream
toSymbol
toString
toInteger
toFloat
toWStringint SourceLine read-only
Returns the line number containing the token.
Renvoie le numéro de ligne contenant le 'mot'.Methods :
AnsiString TokenString()
Returns a token.
Renvoie un 'mot'.char NextToken()
Returns the type of the next token.
Renvoie le type du 'mot' suivant.int SourcePos()
Gives you the position of the token in the stream.
Renvoie la position du 'mot' dans le stream.Extended TokenFloat()
int TokenInt()
AnsiString TokenString()
WideString TokenWideString()
These four functions return a token and convert it to
an int, float or AnsiString depending on its type.
Ces quatre fonctions renvoie un 'mot' et le convertit
en fonction de son type en int, float ou AnsiString.
Below, you'll find a little example which parses a FileStream and shows the result in a TMemo. | Ci-dessous, vous trouverez un exemple qui analyse un fichier et affiche le résultat dans un TMemo. |
TFileStream *FS=new TFileStream("YourFile.xxx",fmOpenRead); |