📄 parsing.h
字号:
/* ***** BEGIN LICENSE BLOCK ***** * Source last modified: $Id: parsing.h,v 1.1.2.1 2004/07/09 01:50:15 hubbe Exp $ * * Portions Copyright (c) 1995-2004 RealNetworks, Inc. All Rights Reserved. * * The contents of this file, and the files included with this file, * are subject to the current version of the RealNetworks Public * Source License (the "RPSL") available at * http://www.helixcommunity.org/content/rpsl unless you have licensed * the file under the current version of the RealNetworks Community * Source License (the "RCSL") available at * http://www.helixcommunity.org/content/rcsl, in which case the RCSL * will apply. You may also obtain the license terms directly from * RealNetworks. You may not use this file except in compliance with * the RPSL or, if you have a valid RCSL with RealNetworks applicable * to this file, the RCSL. Please see the applicable RPSL or RCSL for * the rights, obligations and limitations governing use of the * contents of the file. * * Alternatively, the contents of this file may be used under the * terms of the GNU General Public License Version 2 or later (the * "GPL") in which case the provisions of the GPL are applicable * instead of those above. If you wish to allow use of your version of * this file only under the terms of the GPL, and not to allow others * to use your version of this file under the terms of either the RPSL * or RCSL, indicate your decision by deleting the provisions above * and replace them with the notice and other provisions required by * the GPL. If you do not delete the provisions above, a recipient may * use your version of this file under the terms of any one of the * RPSL, the RCSL or the GPL. * * This file is part of the Helix DNA Technology. RealNetworks is the * developer of the Original Code and owns the copyrights in the * portions it created. * * This file, and the files included with this file, is distributed * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET * ENJOYMENT OR NON-INFRINGEMENT. * * Technology Compatibility Kit Test Suite(s) Location: * http://www.helixcommunity.org/content/tck * * Contributor(s): * * ***** END LICENSE BLOCK ***** *////////////////////////////////////////////////////////////////////////////////// PARSING.H////// This file contains the functions that are used in RealText rendering to // parse the text and deal with the tokens.//// (1) ULONG32 skipSpacesTabsAndNewlineChars(_CHAR* pBuf, ULONG32 bufLen,// ULONG32 startIndx). // //Takes a pointer to a char buffer and skips all contiguous space// // chars, tab chars, newline chars, and/or carriage return chars// // and returns the index of the first non-such char (at or past// // startIndx) in the buffer. Note that this character may be the// // terminating '\0' char.//// (2) ULONG32 findNextSpaceTabOrNewLineChar(_CHAR* pBuf, ULONG32 bufLen,// ULONG32 startIndx, ULONG32 &indexOfEqualsSign,// ULONG32 ulCurCharset);// //Takes a pointer to a char buffer and skips all contiguous// // characters that are NOT space chars, tab chars, newline chars,// // or carriage return chars and returns the index of the first// // space, tab, newline, or carriage return char (at or past// // startIndx) encountered in the buffer. If no '=' sign is found,// // indexOfEqualsSign is set to bufLen. Note that the index returned// // may be of the terminating '\0' char. Note also that ulCurCharset// // is needed because we may want to skip trail byte if a lead DBCS// // byte is found, but only if the charset is a DBCS one.//// (3) void convertToUpperCase(_CHAR* pBuf, ULONG32 bufLen);// //Converts all lower-case alphabet chars in buf to uppercase except// // chars inside quotes.//// (4) ULONG32 findNextChar(_CHAR charToFind, _CHAR* pBuf, ULONG32 ulBufLen,// ULONG32 ulStartIndex, ULONG32 ulCurCharset);// //Finds the next instance of the specified character in pBuf starting its// // search at ulStartIndex and returning the index of the next// // occurance of charToFind (or ulBufLen if charToFind was not found).// // Note that ulCurCharset is needed because we may want to skip trail// // byte if a lead DBCS byte is found, but only if the charset is a DBCS one.//// (5) BOOL GetNextTokenLvalueRvaluePair(_CHAR* pBuf, ULONG32 ulBufLen,// ULONG32& ulLvalueStartIndex, ULONG32& ulLvalueEndIndex,// ULONG32& ulRvalueStartIndex, ULONG32& ulRvalueEndIndex)// // Finds the start and end indices of both elements of the next // // "lvalue=rvalue" token in pBuf.// //// // Example 1. : if pBuf is the contents inside the following []'s: // // [ COLOR= red]// // then this function will set ulLvalueStartIndex to 1, // // ulLvalueEndIndex to 6, ulRvalueStartIndex to 8, and // // ulRvalueEndIndex to 11; "COLOR" and "red" are the values found.// //// // Exmple 2: if pBuf is the contents inside the following []'s: // // [COLOR ="light blue" blah blah]// // then this function will set ulLvalueStartIndex to 0, // // ulLvalueEndIndex to 5, ulRvalueStartIndex to 10, and // // ulRvalueEndIndex to 20; "COLOR" and "light blue" are the vals found.//// (6) BOOL lookForStartAndEndQuotesOfString(// _CHAR* pBuf,// ULONG32 ulBufLen,// BOOL& bStartQuoteWasFound,// BOOL& bEndQuoteWasFound);// //Returns TRUE if either a start or end quote was found. Note: this// // function does NOT mess with the pBuf in any way, so it is the// // responsibility of the caller to do a pBuf++ if start quote is to// // be removed and to put a '\0' in place of the end quote if it is// // to be removed. If the string is only one character long and that// // char is a quote, then bStartQuoteWasFound is set to TRUE and// // bEndQuoteWasFound is set to FALSE.////#if !defined(_PARSING_H_)#define _PARSING_H_//Defines for indenting list items:#define UNORDERED_LIST_INDENT_AMT 20#define ORDERED_LIST_INDENT_AMT UNORDERED_LIST_INDENT_AMT///////////////////////////////////////////////////////////////////////////////Takes a pointer to a char buffer and skips all contiguous space chars,// tab char, newline chars, and/or carriage return chars and returns the// index of the first non-such char (at or past startIndx) in the buffer.// Note that this character may be the terminating '\0' char.ULONG32 skipSpacesTabsAndNewlineChars( _CHAR* pBuf, ULONG32 bufLen, ULONG32 startIndx);/////////////////////////////////////////////////////////////////////////////// - Takes a pointer to a char buffer and skips all contiguous characters// that are NOT space chars, tab chars, newline chars, or carriage// return chars and returns the index of the first space, tab, newline,// or carriage return char (at or past startIndx) encountered in the// buffer. The index of the first '=' char, if any, encountered is// placed in indexOfEqualsSign parameter. If no '=' sign is found,// indexOfEqualsSign is set to bufLen. //// - Note: the index returned may be that of the terminating '\0' char.//// - Note also that ulCurCharset is needed because we may want to skip// trail byte if a lead DBCS byte is found, but only if the charset// is a DBCS one.ULONG32 findNextSpaceTabOrNewLineChar( _CHAR* pBuf, ULONG32 bufLen, ULONG32 startIndx, ULONG32 &indexOfEqualsSign, ULONG32 ulCurCharset);///////////////////////////////////////////////////////////////////////////////Converts all lower-case alphabet chars in buf to uppercase unless they are// inside quotes, e.g., [blah "blah"] will be converted to [BLAH "blah"]:void convertToUpperCase( _CHAR* pBuf, ULONG32 bufLen);/////////////////////////////////////////////////////////////////////////////// Finds the next instance of the specified character in pBuf starting its// search at ulStartIndex and returning the index of the next occurance of// charToFind (or ulBufLen if charToFind was not found):// Note that ulCurCharset is needed because we may want to skip trail// byte if a lead DBCS byte is found, but only if the charset is a DBCS one.//ULONG32 findNextChar(_CHAR charToFind, _CHAR* pBuf, ULONG32 ulBufLen, ULONG32 ulStartIndex, ULONG32 ulCurCharset);/////////////////////////////////////////////////////////////////////////////// Finds the start and end indices of both elements of the next // "lvalue=rvalue" token in pBuf.//// Example 2: if pBuf is the contents inside the following []'s: // [ COLOR= red]// then this function will set ulLvalueStartIndex to 1, // ulLvalueEndIndex to 6, ulRvalueStartIndex to 8, and // ulRvalueEndIndex to 11; "COLOR" and "red" are the values found.//// Example 2: if pBuf is the contents inside the following []'s: // [COLOR ="light blue" blah blah]// then this function will set ulLvalueStartIndex to 0, // ulLvalueEndIndex to 5, ulRvalueStartIndex to 10, and // ulRvalueEndIndex to 20; "COLOR" and "light blue" are the values found.//BOOL GetNextTokenLvalueRvaluePair(_CHAR* pBuf, ULONG32 ulBufLen, ULONG32& ulLvalueStartIndex, ULONG32& ulLvalueEndIndex, ULONG32& ulRvalueStartIndex, ULONG32& ulRvalueEndIndex);///////////////////////////////////////////////////////////////////////////////Returns TRUE if either a start or end quote was found. Note: this// function does NOT mess with the pBuf in any way, so it is the// responsibility of the caller to do a pBuf++ if start quote is to// be removed and to put a '\0' in place of the end quote if it is// to be removed. If the string is only one character long and that// char is a quote, then bStartQuoteWasFound is set to TRUE and// bEndQuoteWasFound is set to FALSE.BOOL lookForStartAndEndQuotesOfString( _CHAR* pBuf, ULONG32 ulBufLen, BOOL& bStartQuoteWasFound, BOOL& bEndQuoteWasFound);#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -