📄 pdf_rules.h
字号:
/**
*by ren xing guo 2005/02/15
*/
#ifndef PDF_RULES_HPP_INCLUDED
#define PDF_RULES_HPP_INCLUDED
#include "re_ops.hpp"
namespace PDF_RULES {
/**
*pdf white space characters 00 Null (NUL) 09 Tab (HT) 0A Line feed (LF) 0C Form feed (FF)
* 0D Carriage return 20 Space (SP)
*/
struct MatchWSpace : public yard::re_or < yard::re_or3 < yard::MatchChar < char(0x00) >, yard::MatchChar < char(0x09) >,
yard::MatchChar < char(0x0A) > >, yard::re_or3 < yard::MatchChar < char(0x0C) >, yard::MatchChar < char(0x0D) >,
yard::MatchChar < char(0x20) > > > {
};
/** Match delimer charaters. The delimer characters include (, ), <, >, [, ], {, }, /, and % */
struct MatchDelimerCharacter {
static bool Accept(yard::ParserInputStream < char > & stream) {
if (stream.AtEnd()) return false;
char ch = stream.GetElem();
switch (ch) {
case '(':
return true;
break;
case ')':
return true;
break;
case '<':
return true;
break;
case '>':
return true;
break;
case '[':
return true;
break;
case ']':
return true;
break;
case '{':
return true;
break;
case '}':
return true;
break;
case '/':
return true;
break;
case '%':
return true;
break;
default:
return false;
}
return false;
}
};
/**
*match end of line(EOL) The combination of carrige return(CR 0x0D) followed immediately by a line feed(LF 0x0A) ia
* treated as one EOL marker.
*/
struct MatchEOL : public yard::re_and < yard::MatchChar < char(0x0D) >, yard::MatchChar < char(0x0A) > > { };
/** match comments. The comment consists of all characters between percent sign and end of line mark(EOL). */
struct MatchComment : public yard::re_and < yard::MatchChar < '%' >, yard::re_until < MatchEOL > > { };
/** match boolean obj The boolean object is identified by the keywords true and false. */
struct boolean_true_string {
static char const * GetString() { return "true"; }
};
struct boolean_false_string {
static char const * GetString() { return "false"; }
};
struct MatchBooleanObject : public yard::re_or < yard::MatchString < boolean_true_string >,
yard::MatchString < boolean_false_string > > {
};
/** match integer An integer number is expressed by one or more deciamal digits optionally preceded by a sign(+ or -). */
struct MatchInteger : public yard::re_and < yard::re_opt < yard::re_or < yard::MatchChar < '+' >,
yard::MatchChar < '-' > > >, yard::re_plus < yard::MatchNumber > > { };
/**
*match real The real number is expressed by one or more decimal digits with an optional sign and a leading ,trailing,or
* embeded decimal point.
*/
struct MatchReal : public yard::re_and3 < MatchInteger, yard::MatchChar < '.' >, yard::re_star < yard::MatchNumber > > { };
/** match number object The number object can be classified two categories: integer and real. */
struct MatchNumberObject : public yard::re_or < MatchInteger, MatchReal > { };
/**
*match literal string The literal string is constructed by an arbitray number characters enclosed in parentheses().
* warning: the escape charater should be treat as string .for example (\(\))
*/
struct MatchLiteralString;
/**
*Assumption: A :escape charater, B: fore parenthes, C:post parenthes. begining token = ^AB, ending token=^AC
* Tokens we should omit =^begining token && ^ending token =
*/
/** ^AB //the preceding charater never be escape charater */
struct MatchLiteralStringBeginToken : public yard::re_and < yard::MatchChar < '(' >,
yard::Control_RangeMatch < yard::re_not < yard::MatchChar < '\\' > >, -2, 0 > > {
};
struct MatchLiteralStringEndToken : public yard::re_and < yard::MatchChar < ')' >,
yard::Control_RangeMatch < yard::re_not < yard::MatchChar < '\\' > >, -2, 0 > > {
};
struct MatchLiteralString : public yard::re_NestRule < MatchLiteralStringBeginToken, MatchLiteralStringEndToken > {
};
/**
*Hexadecimal string match. A hexadecimal string is written as a sequence of hexadeciam digits(0-9 a-f A-F) enclosed
* within angle bracket.
*/
struct MatchHexadecimalString : public yard::re_and3 < yard::MatchChar < '<' >,
yard::re_star < yard::re_or3 < yard::MatchCharRange < '0', '9' >, yard::MatchCharRange < 'a', 'f' >,
yard::MatchCharRange < 'A', 'F' > > >, yard::MatchChar < '>' > > { };
/** Match string objects. */
struct MatchStringObject : public yard::re_or < MatchLiteralString, MatchHexadecimalString > { };
/**
*Match name object. A slash introduces a name.There can be no white space between the slash and the name.
* The name may include any regular charaters, but not delimer and white space charaters.
*/
struct MatchNameObject : public yard::re_and < yard::MatchChar < '/' >,
yard::re_until < yard::re_or < MatchDelimerCharacter, MatchWSpace > > > { };
/**
*Match array object. PDF directly supports only one dimentional array.Array of high dimention can be constructed by using
* arrays as elements of arrays,nested to any depth.
*/
struct MatchArrayObject : public yard::re_NestRule < yard::MatchChar < '[' >, yard::MatchChar < ']' > > { };
/** Match dictionaray object */
struct MatchDictionaryObject : public yard::re_NestRule < yard::re_repeat < yard::MatchChar < '<' >, 2 >,
yard::re_repeat < yard::MatchChar < '>' >, 2 > > { };
/** Match stream object */
struct stream_string {
static char const * GetString() { return "stream"; }
};
struct endstream_string {
static char const * GetString() { return "endstream"; }
};
/**
*Match stream object. A stream object consists of a dictionary followed by zero or more bytes bracked by
* stream and endstream.
*/
struct MatchStreamObject : public yard::re_and3 < yard::re_and < MatchDictionaryObject, yard::re_star < MatchWSpace > >,
yard::MatchString < stream_string >, yard::re_until < yard::MatchString < endstream_string > > > { };
/**
* Indirect object.
*/
struct MatchIndirectObject: public yard::re_and3<
yard::re_and<MatchInteger, yard::re_plus<MatchWSpace> >,
yard::re_and<MatchInteger, yard::re_plus<MatchWSpace> >,
yard::MatchChar<'R'>
>{};
/**Match standard filters
*ASCIIHexDecode
*ASCII85Decode
*LZWDecode
*FlateDecode
*RunLengthDecode
*CCITTFaxDecode
*JBIG2Decode
*DCTDecode
*JPXDecode
*Crypt
*/
struct ASCIIHexDecode_string {
static char const * GetString() { return "ASCIIHexDecode"; }
};
struct ASCII85Decode_string {
static char const * GetString() { return "/ASCII85Decode"; }
};
struct LZWDecode_string {
static char const * GetString() { return "/LZWDecode"; }
};
struct FlateDecode_string {
static char const * GetString() { return "/FlateDecode"; }
};
struct RunLengthDecode_string {
static char const * GetString() { return "/RunLengthDecode"; }
};
struct CCITTFaxDecode_string {
static char const * GetString() { return "/CCITTFaxDecode"; }
};
struct JBIG2Decode_string {
static char const * GetString() { return "JBIG2Decode"; }
};
struct DCTDecode_string {
static char const * GetString() { return "/DCTDecode"; }
};
struct JPXDecode_string {
static char const * GetString() { return "/JPXDecode"; }
};
struct Crypt_string {
static char const * GetString() { return "/Crypt"; }
};
/**
*The filter type can be name or array
*
/Filter [/ASCIIHexDecode /JBIG2Decode]
/DecodeParms [null << /JBIG2Globals 6 0 R >>]
*/
struct Filter_string {
static char const * GetString() { return "/Filter"; }
};
struct MatchFilterEntry : public yard::re_and3<
yard::MatchString<Filter_string>,
yard::re_star<MatchWSpace>,
yard::re_or3<
MatchIndirectObject,
MatchNameObject,
MatchArrayObject
>
>{};
/**
Match length entry.
*/
struct Length_string {
static char const * GetString() { return "/Length"; }
};
/**
Length type can be integer.
*/
struct MatchLengthEntry: public yard::re_and3<
yard::MatchString<Length_string>,
yard::re_star<MatchWSpace>,
yard::re_or<
MatchIndirectObject,
MatchInteger
>
>{};
/////////////////////////////////////////////////////////////////////////
//file structure
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -