googlecustomsearch.pp 54 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025
  1. unit googlecustomsearch;
  2. {$MODE objfpc}
  3. {$H+}
  4. interface
  5. uses sysutils, classes, googleservice, restbase, googlebase;
  6. type
  7. //Top-level schema types
  8. TContext = Class;
  9. TPromotion = Class;
  10. TQuery = Class;
  11. TResult = Class;
  12. TSearch = Class;
  13. TContextArray = Array of TContext;
  14. TPromotionArray = Array of TPromotion;
  15. TQueryArray = Array of TQuery;
  16. TResultArray = Array of TResult;
  17. TSearchArray = Array of TSearch;
  18. //Anonymous types, using auto-generated names
  19. TContextTypefacetsItemItem = Class;
  20. TPromotionTypebodyLinesItem = Class;
  21. TPromotionTypeimage = Class;
  22. TResultTypeimage = Class;
  23. TResultTypelabelsItem = Class;
  24. TResultTypepagemap = Class;
  25. TSearchTypequeries = Class;
  26. TSearchTypesearchInformation = Class;
  27. TSearchTypespelling = Class;
  28. TSearchTypeurl = Class;
  29. TContextTypefacetsItemArray = Array of TContextTypefacetsItemItem;
  30. TContextTypefacetsArray = Array of TContextTypefacetsItemArray;
  31. TPromotionTypebodyLinesArray = Array of TPromotionTypebodyLinesItem;
  32. TResultTypelabelsArray = Array of TResultTypelabelsItem;
  33. TSearchTypeitemsArray = Array of TResult;
  34. TSearchTypepromotionsArray = Array of TPromotion;
  35. { --------------------------------------------------------------------
  36. TContextTypefacetsItemItem
  37. --------------------------------------------------------------------}
  38. TContextTypefacetsItemItem = Class(TGoogleBaseObject)
  39. Private
  40. Fanchor : String;
  41. F_label : String;
  42. Flabel_with_op : String;
  43. Protected
  44. Class Function ExportPropertyName(Const AName : String) : string; override;
  45. //Property setters
  46. Procedure Setanchor(AIndex : Integer; const AValue : String); virtual;
  47. Procedure Set_label(AIndex : Integer; const AValue : String); virtual;
  48. Procedure Setlabel_with_op(AIndex : Integer; const AValue : String); virtual;
  49. Public
  50. Published
  51. Property anchor : String Index 0 Read Fanchor Write Setanchor;
  52. Property _label : String Index 8 Read F_label Write Set_label;
  53. Property label_with_op : String Index 16 Read Flabel_with_op Write Setlabel_with_op;
  54. end;
  55. TContextTypefacetsItemItemClass = Class of TContextTypefacetsItemItem;
  56. { --------------------------------------------------------------------
  57. TContext
  58. --------------------------------------------------------------------}
  59. TContext = Class(TGoogleBaseObject)
  60. Private
  61. Ffacets : TContextTypefacetsArray;
  62. Ftitle : String;
  63. Protected
  64. //Property setters
  65. Procedure Setfacets(AIndex : Integer; const AValue : TContextTypefacetsArray); virtual;
  66. Procedure Settitle(AIndex : Integer; const AValue : String); virtual;
  67. //2.6.4. bug workaround
  68. {$IFDEF VER2_6}
  69. Procedure SetArrayLength(Const AName : String; ALength : Longint); override;
  70. {$ENDIF VER2_6}
  71. Public
  72. Published
  73. Property facets : TContextTypefacetsArray Index 0 Read Ffacets Write Setfacets;
  74. Property title : String Index 8 Read Ftitle Write Settitle;
  75. end;
  76. TContextClass = Class of TContext;
  77. { --------------------------------------------------------------------
  78. TPromotionTypebodyLinesItem
  79. --------------------------------------------------------------------}
  80. TPromotionTypebodyLinesItem = Class(TGoogleBaseObject)
  81. Private
  82. FhtmlTitle : String;
  83. Flink : String;
  84. Ftitle : String;
  85. Furl : String;
  86. Protected
  87. //Property setters
  88. Procedure SethtmlTitle(AIndex : Integer; const AValue : String); virtual;
  89. Procedure Setlink(AIndex : Integer; const AValue : String); virtual;
  90. Procedure Settitle(AIndex : Integer; const AValue : String); virtual;
  91. Procedure Seturl(AIndex : Integer; const AValue : String); virtual;
  92. Public
  93. Published
  94. Property htmlTitle : String Index 0 Read FhtmlTitle Write SethtmlTitle;
  95. Property link : String Index 8 Read Flink Write Setlink;
  96. Property title : String Index 16 Read Ftitle Write Settitle;
  97. Property url : String Index 24 Read Furl Write Seturl;
  98. end;
  99. TPromotionTypebodyLinesItemClass = Class of TPromotionTypebodyLinesItem;
  100. { --------------------------------------------------------------------
  101. TPromotionTypeimage
  102. --------------------------------------------------------------------}
  103. TPromotionTypeimage = Class(TGoogleBaseObject)
  104. Private
  105. Fheight : integer;
  106. Fsource : String;
  107. Fwidth : integer;
  108. Protected
  109. //Property setters
  110. Procedure Setheight(AIndex : Integer; const AValue : integer); virtual;
  111. Procedure Setsource(AIndex : Integer; const AValue : String); virtual;
  112. Procedure Setwidth(AIndex : Integer; const AValue : integer); virtual;
  113. Public
  114. Published
  115. Property height : integer Index 0 Read Fheight Write Setheight;
  116. Property source : String Index 8 Read Fsource Write Setsource;
  117. Property width : integer Index 16 Read Fwidth Write Setwidth;
  118. end;
  119. TPromotionTypeimageClass = Class of TPromotionTypeimage;
  120. { --------------------------------------------------------------------
  121. TPromotion
  122. --------------------------------------------------------------------}
  123. TPromotion = Class(TGoogleBaseObject)
  124. Private
  125. FbodyLines : TPromotionTypebodyLinesArray;
  126. FdisplayLink : String;
  127. FhtmlTitle : String;
  128. Fimage : TPromotionTypeimage;
  129. Flink : String;
  130. Ftitle : String;
  131. Protected
  132. //Property setters
  133. Procedure SetbodyLines(AIndex : Integer; const AValue : TPromotionTypebodyLinesArray); virtual;
  134. Procedure SetdisplayLink(AIndex : Integer; const AValue : String); virtual;
  135. Procedure SethtmlTitle(AIndex : Integer; const AValue : String); virtual;
  136. Procedure Setimage(AIndex : Integer; const AValue : TPromotionTypeimage); virtual;
  137. Procedure Setlink(AIndex : Integer; const AValue : String); virtual;
  138. Procedure Settitle(AIndex : Integer; const AValue : String); virtual;
  139. //2.6.4. bug workaround
  140. {$IFDEF VER2_6}
  141. Procedure SetArrayLength(Const AName : String; ALength : Longint); override;
  142. {$ENDIF VER2_6}
  143. Public
  144. Published
  145. Property bodyLines : TPromotionTypebodyLinesArray Index 0 Read FbodyLines Write SetbodyLines;
  146. Property displayLink : String Index 8 Read FdisplayLink Write SetdisplayLink;
  147. Property htmlTitle : String Index 16 Read FhtmlTitle Write SethtmlTitle;
  148. Property image : TPromotionTypeimage Index 24 Read Fimage Write Setimage;
  149. Property link : String Index 32 Read Flink Write Setlink;
  150. Property title : String Index 40 Read Ftitle Write Settitle;
  151. end;
  152. TPromotionClass = Class of TPromotion;
  153. { --------------------------------------------------------------------
  154. TQuery
  155. --------------------------------------------------------------------}
  156. TQuery = Class(TGoogleBaseObject)
  157. Private
  158. Fcount : integer;
  159. Fcr : String;
  160. Fcref : String;
  161. Fcx : String;
  162. FdateRestrict : String;
  163. FdisableCnTwTranslation : String;
  164. FexactTerms : String;
  165. FexcludeTerms : String;
  166. FfileType : String;
  167. Ffilter : String;
  168. Fgl : String;
  169. FgoogleHost : String;
  170. FhighRange : String;
  171. Fhl : String;
  172. Fhq : String;
  173. FimgColorType : String;
  174. FimgDominantColor : String;
  175. FimgSize : String;
  176. FimgType : String;
  177. FinputEncoding : String;
  178. Flanguage : String;
  179. FlinkSite : String;
  180. FlowRange : String;
  181. ForTerms : String;
  182. FoutputEncoding : String;
  183. FrelatedSite : String;
  184. Frights : String;
  185. Fsafe : String;
  186. FsearchTerms : String;
  187. FsearchType : String;
  188. FsiteSearch : String;
  189. FsiteSearchFilter : String;
  190. Fsort : String;
  191. FstartIndex : integer;
  192. FstartPage : integer;
  193. Ftitle : String;
  194. FtotalResults : String;
  195. Protected
  196. //Property setters
  197. Procedure Setcount(AIndex : Integer; const AValue : integer); virtual;
  198. Procedure Setcr(AIndex : Integer; const AValue : String); virtual;
  199. Procedure Setcref(AIndex : Integer; const AValue : String); virtual;
  200. Procedure Setcx(AIndex : Integer; const AValue : String); virtual;
  201. Procedure SetdateRestrict(AIndex : Integer; const AValue : String); virtual;
  202. Procedure SetdisableCnTwTranslation(AIndex : Integer; const AValue : String); virtual;
  203. Procedure SetexactTerms(AIndex : Integer; const AValue : String); virtual;
  204. Procedure SetexcludeTerms(AIndex : Integer; const AValue : String); virtual;
  205. Procedure SetfileType(AIndex : Integer; const AValue : String); virtual;
  206. Procedure Setfilter(AIndex : Integer; const AValue : String); virtual;
  207. Procedure Setgl(AIndex : Integer; const AValue : String); virtual;
  208. Procedure SetgoogleHost(AIndex : Integer; const AValue : String); virtual;
  209. Procedure SethighRange(AIndex : Integer; const AValue : String); virtual;
  210. Procedure Sethl(AIndex : Integer; const AValue : String); virtual;
  211. Procedure Sethq(AIndex : Integer; const AValue : String); virtual;
  212. Procedure SetimgColorType(AIndex : Integer; const AValue : String); virtual;
  213. Procedure SetimgDominantColor(AIndex : Integer; const AValue : String); virtual;
  214. Procedure SetimgSize(AIndex : Integer; const AValue : String); virtual;
  215. Procedure SetimgType(AIndex : Integer; const AValue : String); virtual;
  216. Procedure SetinputEncoding(AIndex : Integer; const AValue : String); virtual;
  217. Procedure Setlanguage(AIndex : Integer; const AValue : String); virtual;
  218. Procedure SetlinkSite(AIndex : Integer; const AValue : String); virtual;
  219. Procedure SetlowRange(AIndex : Integer; const AValue : String); virtual;
  220. Procedure SetorTerms(AIndex : Integer; const AValue : String); virtual;
  221. Procedure SetoutputEncoding(AIndex : Integer; const AValue : String); virtual;
  222. Procedure SetrelatedSite(AIndex : Integer; const AValue : String); virtual;
  223. Procedure Setrights(AIndex : Integer; const AValue : String); virtual;
  224. Procedure Setsafe(AIndex : Integer; const AValue : String); virtual;
  225. Procedure SetsearchTerms(AIndex : Integer; const AValue : String); virtual;
  226. Procedure SetsearchType(AIndex : Integer; const AValue : String); virtual;
  227. Procedure SetsiteSearch(AIndex : Integer; const AValue : String); virtual;
  228. Procedure SetsiteSearchFilter(AIndex : Integer; const AValue : String); virtual;
  229. Procedure Setsort(AIndex : Integer; const AValue : String); virtual;
  230. Procedure SetstartIndex(AIndex : Integer; const AValue : integer); virtual;
  231. Procedure SetstartPage(AIndex : Integer; const AValue : integer); virtual;
  232. Procedure Settitle(AIndex : Integer; const AValue : String); virtual;
  233. Procedure SettotalResults(AIndex : Integer; const AValue : String); virtual;
  234. Public
  235. Published
  236. Property count : integer Index 0 Read Fcount Write Setcount;
  237. Property cr : String Index 8 Read Fcr Write Setcr;
  238. Property cref : String Index 16 Read Fcref Write Setcref;
  239. Property cx : String Index 24 Read Fcx Write Setcx;
  240. Property dateRestrict : String Index 32 Read FdateRestrict Write SetdateRestrict;
  241. Property disableCnTwTranslation : String Index 40 Read FdisableCnTwTranslation Write SetdisableCnTwTranslation;
  242. Property exactTerms : String Index 48 Read FexactTerms Write SetexactTerms;
  243. Property excludeTerms : String Index 56 Read FexcludeTerms Write SetexcludeTerms;
  244. Property fileType : String Index 64 Read FfileType Write SetfileType;
  245. Property filter : String Index 72 Read Ffilter Write Setfilter;
  246. Property gl : String Index 80 Read Fgl Write Setgl;
  247. Property googleHost : String Index 88 Read FgoogleHost Write SetgoogleHost;
  248. Property highRange : String Index 96 Read FhighRange Write SethighRange;
  249. Property hl : String Index 104 Read Fhl Write Sethl;
  250. Property hq : String Index 112 Read Fhq Write Sethq;
  251. Property imgColorType : String Index 120 Read FimgColorType Write SetimgColorType;
  252. Property imgDominantColor : String Index 128 Read FimgDominantColor Write SetimgDominantColor;
  253. Property imgSize : String Index 136 Read FimgSize Write SetimgSize;
  254. Property imgType : String Index 144 Read FimgType Write SetimgType;
  255. Property inputEncoding : String Index 152 Read FinputEncoding Write SetinputEncoding;
  256. Property language : String Index 160 Read Flanguage Write Setlanguage;
  257. Property linkSite : String Index 168 Read FlinkSite Write SetlinkSite;
  258. Property lowRange : String Index 176 Read FlowRange Write SetlowRange;
  259. Property orTerms : String Index 184 Read ForTerms Write SetorTerms;
  260. Property outputEncoding : String Index 192 Read FoutputEncoding Write SetoutputEncoding;
  261. Property relatedSite : String Index 200 Read FrelatedSite Write SetrelatedSite;
  262. Property rights : String Index 208 Read Frights Write Setrights;
  263. Property safe : String Index 216 Read Fsafe Write Setsafe;
  264. Property searchTerms : String Index 224 Read FsearchTerms Write SetsearchTerms;
  265. Property searchType : String Index 232 Read FsearchType Write SetsearchType;
  266. Property siteSearch : String Index 240 Read FsiteSearch Write SetsiteSearch;
  267. Property siteSearchFilter : String Index 248 Read FsiteSearchFilter Write SetsiteSearchFilter;
  268. Property sort : String Index 256 Read Fsort Write Setsort;
  269. Property startIndex : integer Index 264 Read FstartIndex Write SetstartIndex;
  270. Property startPage : integer Index 272 Read FstartPage Write SetstartPage;
  271. Property title : String Index 280 Read Ftitle Write Settitle;
  272. Property totalResults : String Index 288 Read FtotalResults Write SettotalResults;
  273. end;
  274. TQueryClass = Class of TQuery;
  275. { --------------------------------------------------------------------
  276. TResultTypeimage
  277. --------------------------------------------------------------------}
  278. TResultTypeimage = Class(TGoogleBaseObject)
  279. Private
  280. FbyteSize : integer;
  281. FcontextLink : String;
  282. Fheight : integer;
  283. FthumbnailHeight : integer;
  284. FthumbnailLink : String;
  285. FthumbnailWidth : integer;
  286. Fwidth : integer;
  287. Protected
  288. //Property setters
  289. Procedure SetbyteSize(AIndex : Integer; const AValue : integer); virtual;
  290. Procedure SetcontextLink(AIndex : Integer; const AValue : String); virtual;
  291. Procedure Setheight(AIndex : Integer; const AValue : integer); virtual;
  292. Procedure SetthumbnailHeight(AIndex : Integer; const AValue : integer); virtual;
  293. Procedure SetthumbnailLink(AIndex : Integer; const AValue : String); virtual;
  294. Procedure SetthumbnailWidth(AIndex : Integer; const AValue : integer); virtual;
  295. Procedure Setwidth(AIndex : Integer; const AValue : integer); virtual;
  296. Public
  297. Published
  298. Property byteSize : integer Index 0 Read FbyteSize Write SetbyteSize;
  299. Property contextLink : String Index 8 Read FcontextLink Write SetcontextLink;
  300. Property height : integer Index 16 Read Fheight Write Setheight;
  301. Property thumbnailHeight : integer Index 24 Read FthumbnailHeight Write SetthumbnailHeight;
  302. Property thumbnailLink : String Index 32 Read FthumbnailLink Write SetthumbnailLink;
  303. Property thumbnailWidth : integer Index 40 Read FthumbnailWidth Write SetthumbnailWidth;
  304. Property width : integer Index 48 Read Fwidth Write Setwidth;
  305. end;
  306. TResultTypeimageClass = Class of TResultTypeimage;
  307. { --------------------------------------------------------------------
  308. TResultTypelabelsItem
  309. --------------------------------------------------------------------}
  310. TResultTypelabelsItem = Class(TGoogleBaseObject)
  311. Private
  312. FdisplayName : String;
  313. Flabel_with_op : String;
  314. Fname : String;
  315. Protected
  316. //Property setters
  317. Procedure SetdisplayName(AIndex : Integer; const AValue : String); virtual;
  318. Procedure Setlabel_with_op(AIndex : Integer; const AValue : String); virtual;
  319. Procedure Setname(AIndex : Integer; const AValue : String); virtual;
  320. Public
  321. Published
  322. Property displayName : String Index 0 Read FdisplayName Write SetdisplayName;
  323. Property label_with_op : String Index 8 Read Flabel_with_op Write Setlabel_with_op;
  324. Property name : String Index 16 Read Fname Write Setname;
  325. end;
  326. TResultTypelabelsItemClass = Class of TResultTypelabelsItem;
  327. { --------------------------------------------------------------------
  328. TResultTypepagemap
  329. --------------------------------------------------------------------}
  330. TResultTypepagemap = Class(TGoogleBaseObject)
  331. Private
  332. Protected
  333. //Property setters
  334. Public
  335. Class Function AllowAdditionalProperties : Boolean; override;
  336. Published
  337. end;
  338. TResultTypepagemapClass = Class of TResultTypepagemap;
  339. { --------------------------------------------------------------------
  340. TResult
  341. --------------------------------------------------------------------}
  342. TResult = Class(TGoogleBaseObject)
  343. Private
  344. FcacheId : String;
  345. FdisplayLink : String;
  346. FfileFormat : String;
  347. FformattedUrl : String;
  348. FhtmlFormattedUrl : String;
  349. FhtmlSnippet : String;
  350. FhtmlTitle : String;
  351. Fimage : TResultTypeimage;
  352. Fkind : String;
  353. Flabels : TResultTypelabelsArray;
  354. Flink : String;
  355. Fmime : String;
  356. Fpagemap : TResultTypepagemap;
  357. Fsnippet : String;
  358. Ftitle : String;
  359. Protected
  360. //Property setters
  361. Procedure SetcacheId(AIndex : Integer; const AValue : String); virtual;
  362. Procedure SetdisplayLink(AIndex : Integer; const AValue : String); virtual;
  363. Procedure SetfileFormat(AIndex : Integer; const AValue : String); virtual;
  364. Procedure SetformattedUrl(AIndex : Integer; const AValue : String); virtual;
  365. Procedure SethtmlFormattedUrl(AIndex : Integer; const AValue : String); virtual;
  366. Procedure SethtmlSnippet(AIndex : Integer; const AValue : String); virtual;
  367. Procedure SethtmlTitle(AIndex : Integer; const AValue : String); virtual;
  368. Procedure Setimage(AIndex : Integer; const AValue : TResultTypeimage); virtual;
  369. Procedure Setkind(AIndex : Integer; const AValue : String); virtual;
  370. Procedure Setlabels(AIndex : Integer; const AValue : TResultTypelabelsArray); virtual;
  371. Procedure Setlink(AIndex : Integer; const AValue : String); virtual;
  372. Procedure Setmime(AIndex : Integer; const AValue : String); virtual;
  373. Procedure Setpagemap(AIndex : Integer; const AValue : TResultTypepagemap); virtual;
  374. Procedure Setsnippet(AIndex : Integer; const AValue : String); virtual;
  375. Procedure Settitle(AIndex : Integer; const AValue : String); virtual;
  376. //2.6.4. bug workaround
  377. {$IFDEF VER2_6}
  378. Procedure SetArrayLength(Const AName : String; ALength : Longint); override;
  379. {$ENDIF VER2_6}
  380. Public
  381. Published
  382. Property cacheId : String Index 0 Read FcacheId Write SetcacheId;
  383. Property displayLink : String Index 8 Read FdisplayLink Write SetdisplayLink;
  384. Property fileFormat : String Index 16 Read FfileFormat Write SetfileFormat;
  385. Property formattedUrl : String Index 24 Read FformattedUrl Write SetformattedUrl;
  386. Property htmlFormattedUrl : String Index 32 Read FhtmlFormattedUrl Write SethtmlFormattedUrl;
  387. Property htmlSnippet : String Index 40 Read FhtmlSnippet Write SethtmlSnippet;
  388. Property htmlTitle : String Index 48 Read FhtmlTitle Write SethtmlTitle;
  389. Property image : TResultTypeimage Index 56 Read Fimage Write Setimage;
  390. Property kind : String Index 64 Read Fkind Write Setkind;
  391. Property labels : TResultTypelabelsArray Index 72 Read Flabels Write Setlabels;
  392. Property link : String Index 80 Read Flink Write Setlink;
  393. Property mime : String Index 88 Read Fmime Write Setmime;
  394. Property pagemap : TResultTypepagemap Index 96 Read Fpagemap Write Setpagemap;
  395. Property snippet : String Index 104 Read Fsnippet Write Setsnippet;
  396. Property title : String Index 112 Read Ftitle Write Settitle;
  397. end;
  398. TResultClass = Class of TResult;
  399. { --------------------------------------------------------------------
  400. TSearchTypequeries
  401. --------------------------------------------------------------------}
  402. TSearchTypequeries = Class(TGoogleBaseObject)
  403. Private
  404. Protected
  405. //Property setters
  406. Public
  407. Class Function AllowAdditionalProperties : Boolean; override;
  408. Published
  409. end;
  410. TSearchTypequeriesClass = Class of TSearchTypequeries;
  411. { --------------------------------------------------------------------
  412. TSearchTypesearchInformation
  413. --------------------------------------------------------------------}
  414. TSearchTypesearchInformation = Class(TGoogleBaseObject)
  415. Private
  416. FformattedSearchTime : String;
  417. FformattedTotalResults : String;
  418. FsearchTime : double;
  419. FtotalResults : String;
  420. Protected
  421. //Property setters
  422. Procedure SetformattedSearchTime(AIndex : Integer; const AValue : String); virtual;
  423. Procedure SetformattedTotalResults(AIndex : Integer; const AValue : String); virtual;
  424. Procedure SetsearchTime(AIndex : Integer; const AValue : double); virtual;
  425. Procedure SettotalResults(AIndex : Integer; const AValue : String); virtual;
  426. Public
  427. Published
  428. Property formattedSearchTime : String Index 0 Read FformattedSearchTime Write SetformattedSearchTime;
  429. Property formattedTotalResults : String Index 8 Read FformattedTotalResults Write SetformattedTotalResults;
  430. Property searchTime : double Index 16 Read FsearchTime Write SetsearchTime;
  431. Property totalResults : String Index 24 Read FtotalResults Write SettotalResults;
  432. end;
  433. TSearchTypesearchInformationClass = Class of TSearchTypesearchInformation;
  434. { --------------------------------------------------------------------
  435. TSearchTypespelling
  436. --------------------------------------------------------------------}
  437. TSearchTypespelling = Class(TGoogleBaseObject)
  438. Private
  439. FcorrectedQuery : String;
  440. FhtmlCorrectedQuery : String;
  441. Protected
  442. //Property setters
  443. Procedure SetcorrectedQuery(AIndex : Integer; const AValue : String); virtual;
  444. Procedure SethtmlCorrectedQuery(AIndex : Integer; const AValue : String); virtual;
  445. Public
  446. Published
  447. Property correctedQuery : String Index 0 Read FcorrectedQuery Write SetcorrectedQuery;
  448. Property htmlCorrectedQuery : String Index 8 Read FhtmlCorrectedQuery Write SethtmlCorrectedQuery;
  449. end;
  450. TSearchTypespellingClass = Class of TSearchTypespelling;
  451. { --------------------------------------------------------------------
  452. TSearchTypeurl
  453. --------------------------------------------------------------------}
  454. TSearchTypeurl = Class(TGoogleBaseObject)
  455. Private
  456. Ftemplate : String;
  457. F_type : String;
  458. Protected
  459. Class Function ExportPropertyName(Const AName : String) : string; override;
  460. //Property setters
  461. Procedure Settemplate(AIndex : Integer; const AValue : String); virtual;
  462. Procedure Set_type(AIndex : Integer; const AValue : String); virtual;
  463. Public
  464. Published
  465. Property template : String Index 0 Read Ftemplate Write Settemplate;
  466. Property _type : String Index 8 Read F_type Write Set_type;
  467. end;
  468. TSearchTypeurlClass = Class of TSearchTypeurl;
  469. { --------------------------------------------------------------------
  470. TSearch
  471. --------------------------------------------------------------------}
  472. TSearch = Class(TGoogleBaseObject)
  473. Private
  474. Fcontext : TContext;
  475. Fitems : TSearchTypeitemsArray;
  476. Fkind : String;
  477. Fpromotions : TSearchTypepromotionsArray;
  478. Fqueries : TSearchTypequeries;
  479. FsearchInformation : TSearchTypesearchInformation;
  480. Fspelling : TSearchTypespelling;
  481. Furl : TSearchTypeurl;
  482. Protected
  483. //Property setters
  484. Procedure Setcontext(AIndex : Integer; const AValue : TContext); virtual;
  485. Procedure Setitems(AIndex : Integer; const AValue : TSearchTypeitemsArray); virtual;
  486. Procedure Setkind(AIndex : Integer; const AValue : String); virtual;
  487. Procedure Setpromotions(AIndex : Integer; const AValue : TSearchTypepromotionsArray); virtual;
  488. Procedure Setqueries(AIndex : Integer; const AValue : TSearchTypequeries); virtual;
  489. Procedure SetsearchInformation(AIndex : Integer; const AValue : TSearchTypesearchInformation); virtual;
  490. Procedure Setspelling(AIndex : Integer; const AValue : TSearchTypespelling); virtual;
  491. Procedure Seturl(AIndex : Integer; const AValue : TSearchTypeurl); virtual;
  492. //2.6.4. bug workaround
  493. {$IFDEF VER2_6}
  494. Procedure SetArrayLength(Const AName : String; ALength : Longint); override;
  495. {$ENDIF VER2_6}
  496. Public
  497. Published
  498. Property context : TContext Index 0 Read Fcontext Write Setcontext;
  499. Property items : TSearchTypeitemsArray Index 8 Read Fitems Write Setitems;
  500. Property kind : String Index 16 Read Fkind Write Setkind;
  501. Property promotions : TSearchTypepromotionsArray Index 24 Read Fpromotions Write Setpromotions;
  502. Property queries : TSearchTypequeries Index 32 Read Fqueries Write Setqueries;
  503. Property searchInformation : TSearchTypesearchInformation Index 40 Read FsearchInformation Write SetsearchInformation;
  504. Property spelling : TSearchTypespelling Index 48 Read Fspelling Write Setspelling;
  505. Property url : TSearchTypeurl Index 56 Read Furl Write Seturl;
  506. end;
  507. TSearchClass = Class of TSearch;
  508. { --------------------------------------------------------------------
  509. TCseResource
  510. --------------------------------------------------------------------}
  511. //Optional query Options for TCseResource, method List
  512. TCseListOptions = Record
  513. c2coff : String;
  514. cr : String;
  515. cref : String;
  516. cx : String;
  517. dateRestrict : String;
  518. exactTerms : String;
  519. excludeTerms : String;
  520. fileType : String;
  521. filter : String;
  522. gl : String;
  523. googlehost : String;
  524. highRange : String;
  525. hl : String;
  526. hq : String;
  527. imgColorType : String;
  528. imgDominantColor : String;
  529. imgSize : String;
  530. imgType : String;
  531. linkSite : String;
  532. lowRange : String;
  533. lr : String;
  534. num : integer;
  535. orTerms : String;
  536. q : String;
  537. relatedSite : String;
  538. rights : String;
  539. safe : String;
  540. searchType : String;
  541. siteSearch : String;
  542. siteSearchFilter : String;
  543. sort : String;
  544. start : integer;
  545. end;
  546. TCseResource = Class(TGoogleResource)
  547. Public
  548. Class Function ResourceName : String; override;
  549. Class Function DefaultAPI : TGoogleAPIClass; override;
  550. Function List(AQuery : string = '') : TSearch;
  551. Function List(AQuery : TCselistOptions) : TSearch;
  552. end;
  553. { --------------------------------------------------------------------
  554. TCustomsearchAPI
  555. --------------------------------------------------------------------}
  556. TCustomsearchAPI = Class(TGoogleAPI)
  557. Private
  558. FCseInstance : TCseResource;
  559. Function GetCseInstance : TCseResource;virtual;
  560. Public
  561. //Override class functions with API info
  562. Class Function APIName : String; override;
  563. Class Function APIVersion : String; override;
  564. Class Function APIRevision : String; override;
  565. Class Function APIID : String; override;
  566. Class Function APITitle : String; override;
  567. Class Function APIDescription : String; override;
  568. Class Function APIOwnerDomain : String; override;
  569. Class Function APIOwnerName : String; override;
  570. Class Function APIIcon16 : String; override;
  571. Class Function APIIcon32 : String; override;
  572. Class Function APIdocumentationLink : String; override;
  573. Class Function APIrootUrl : string; override;
  574. Class Function APIbasePath : string;override;
  575. Class Function APIbaseURL : String;override;
  576. Class Function APIProtocol : string;override;
  577. Class Function APIservicePath : string;override;
  578. Class Function APIbatchPath : String;override;
  579. Class Function APIAuthScopes : TScopeInfoArray;override;
  580. Class Function APINeedsAuth : Boolean;override;
  581. Class Procedure RegisterAPIResources; override;
  582. //Add create function for resources
  583. Function CreateCseResource(AOwner : TComponent) : TCseResource;virtual;overload;
  584. Function CreateCseResource : TCseResource;virtual;overload;
  585. //Add default on-demand instances for resources
  586. Property CseResource : TCseResource Read GetCseInstance;
  587. end;
  588. implementation
  589. { --------------------------------------------------------------------
  590. TContextTypefacetsItemItem
  591. --------------------------------------------------------------------}
  592. Procedure TContextTypefacetsItemItem.Setanchor(AIndex : Integer; const AValue : String);
  593. begin
  594. If (Fanchor=AValue) then exit;
  595. Fanchor:=AValue;
  596. MarkPropertyChanged(AIndex);
  597. end;
  598. Procedure TContextTypefacetsItemItem.Set_label(AIndex : Integer; const AValue : String);
  599. begin
  600. If (F_label=AValue) then exit;
  601. F_label:=AValue;
  602. MarkPropertyChanged(AIndex);
  603. end;
  604. Procedure TContextTypefacetsItemItem.Setlabel_with_op(AIndex : Integer; const AValue : String);
  605. begin
  606. If (Flabel_with_op=AValue) then exit;
  607. Flabel_with_op:=AValue;
  608. MarkPropertyChanged(AIndex);
  609. end;
  610. Class Function TContextTypefacetsItemItem.ExportPropertyName(Const AName : String) :String;
  611. begin
  612. Case AName of
  613. '_label' : Result:='label';
  614. else
  615. Result:=Inherited ExportPropertyName(AName);
  616. end;
  617. end;
  618. { --------------------------------------------------------------------
  619. TContext
  620. --------------------------------------------------------------------}
  621. Procedure TContext.Setfacets(AIndex : Integer; const AValue : TContextTypefacetsArray);
  622. begin
  623. If (Ffacets=AValue) then exit;
  624. Ffacets:=AValue;
  625. MarkPropertyChanged(AIndex);
  626. end;
  627. Procedure TContext.Settitle(AIndex : Integer; const AValue : String);
  628. begin
  629. If (Ftitle=AValue) then exit;
  630. Ftitle:=AValue;
  631. MarkPropertyChanged(AIndex);
  632. end;
  633. //2.6.4. bug workaround
  634. {$IFDEF VER2_6}
  635. Procedure TContext.SetArrayLength(Const AName : String; ALength : Longint);
  636. begin
  637. Case AName of
  638. 'facets' : SetLength(Ffacets,ALength);
  639. else
  640. Inherited SetArrayLength(AName,ALength);
  641. end;
  642. end;
  643. {$ENDIF VER2_6}
  644. { --------------------------------------------------------------------
  645. TPromotionTypebodyLinesItem
  646. --------------------------------------------------------------------}
  647. Procedure TPromotionTypebodyLinesItem.SethtmlTitle(AIndex : Integer; const AValue : String);
  648. begin
  649. If (FhtmlTitle=AValue) then exit;
  650. FhtmlTitle:=AValue;
  651. MarkPropertyChanged(AIndex);
  652. end;
  653. Procedure TPromotionTypebodyLinesItem.Setlink(AIndex : Integer; const AValue : String);
  654. begin
  655. If (Flink=AValue) then exit;
  656. Flink:=AValue;
  657. MarkPropertyChanged(AIndex);
  658. end;
  659. Procedure TPromotionTypebodyLinesItem.Settitle(AIndex : Integer; const AValue : String);
  660. begin
  661. If (Ftitle=AValue) then exit;
  662. Ftitle:=AValue;
  663. MarkPropertyChanged(AIndex);
  664. end;
  665. Procedure TPromotionTypebodyLinesItem.Seturl(AIndex : Integer; const AValue : String);
  666. begin
  667. If (Furl=AValue) then exit;
  668. Furl:=AValue;
  669. MarkPropertyChanged(AIndex);
  670. end;
  671. { --------------------------------------------------------------------
  672. TPromotionTypeimage
  673. --------------------------------------------------------------------}
  674. Procedure TPromotionTypeimage.Setheight(AIndex : Integer; const AValue : integer);
  675. begin
  676. If (Fheight=AValue) then exit;
  677. Fheight:=AValue;
  678. MarkPropertyChanged(AIndex);
  679. end;
  680. Procedure TPromotionTypeimage.Setsource(AIndex : Integer; const AValue : String);
  681. begin
  682. If (Fsource=AValue) then exit;
  683. Fsource:=AValue;
  684. MarkPropertyChanged(AIndex);
  685. end;
  686. Procedure TPromotionTypeimage.Setwidth(AIndex : Integer; const AValue : integer);
  687. begin
  688. If (Fwidth=AValue) then exit;
  689. Fwidth:=AValue;
  690. MarkPropertyChanged(AIndex);
  691. end;
  692. { --------------------------------------------------------------------
  693. TPromotion
  694. --------------------------------------------------------------------}
  695. Procedure TPromotion.SetbodyLines(AIndex : Integer; const AValue : TPromotionTypebodyLinesArray);
  696. begin
  697. If (FbodyLines=AValue) then exit;
  698. FbodyLines:=AValue;
  699. MarkPropertyChanged(AIndex);
  700. end;
  701. Procedure TPromotion.SetdisplayLink(AIndex : Integer; const AValue : String);
  702. begin
  703. If (FdisplayLink=AValue) then exit;
  704. FdisplayLink:=AValue;
  705. MarkPropertyChanged(AIndex);
  706. end;
  707. Procedure TPromotion.SethtmlTitle(AIndex : Integer; const AValue : String);
  708. begin
  709. If (FhtmlTitle=AValue) then exit;
  710. FhtmlTitle:=AValue;
  711. MarkPropertyChanged(AIndex);
  712. end;
  713. Procedure TPromotion.Setimage(AIndex : Integer; const AValue : TPromotionTypeimage);
  714. begin
  715. If (Fimage=AValue) then exit;
  716. Fimage:=AValue;
  717. MarkPropertyChanged(AIndex);
  718. end;
  719. Procedure TPromotion.Setlink(AIndex : Integer; const AValue : String);
  720. begin
  721. If (Flink=AValue) then exit;
  722. Flink:=AValue;
  723. MarkPropertyChanged(AIndex);
  724. end;
  725. Procedure TPromotion.Settitle(AIndex : Integer; const AValue : String);
  726. begin
  727. If (Ftitle=AValue) then exit;
  728. Ftitle:=AValue;
  729. MarkPropertyChanged(AIndex);
  730. end;
  731. //2.6.4. bug workaround
  732. {$IFDEF VER2_6}
  733. Procedure TPromotion.SetArrayLength(Const AName : String; ALength : Longint);
  734. begin
  735. Case AName of
  736. 'bodylines' : SetLength(FbodyLines,ALength);
  737. else
  738. Inherited SetArrayLength(AName,ALength);
  739. end;
  740. end;
  741. {$ENDIF VER2_6}
  742. { --------------------------------------------------------------------
  743. TQuery
  744. --------------------------------------------------------------------}
  745. Procedure TQuery.Setcount(AIndex : Integer; const AValue : integer);
  746. begin
  747. If (Fcount=AValue) then exit;
  748. Fcount:=AValue;
  749. MarkPropertyChanged(AIndex);
  750. end;
  751. Procedure TQuery.Setcr(AIndex : Integer; const AValue : String);
  752. begin
  753. If (Fcr=AValue) then exit;
  754. Fcr:=AValue;
  755. MarkPropertyChanged(AIndex);
  756. end;
  757. Procedure TQuery.Setcref(AIndex : Integer; const AValue : String);
  758. begin
  759. If (Fcref=AValue) then exit;
  760. Fcref:=AValue;
  761. MarkPropertyChanged(AIndex);
  762. end;
  763. Procedure TQuery.Setcx(AIndex : Integer; const AValue : String);
  764. begin
  765. If (Fcx=AValue) then exit;
  766. Fcx:=AValue;
  767. MarkPropertyChanged(AIndex);
  768. end;
  769. Procedure TQuery.SetdateRestrict(AIndex : Integer; const AValue : String);
  770. begin
  771. If (FdateRestrict=AValue) then exit;
  772. FdateRestrict:=AValue;
  773. MarkPropertyChanged(AIndex);
  774. end;
  775. Procedure TQuery.SetdisableCnTwTranslation(AIndex : Integer; const AValue : String);
  776. begin
  777. If (FdisableCnTwTranslation=AValue) then exit;
  778. FdisableCnTwTranslation:=AValue;
  779. MarkPropertyChanged(AIndex);
  780. end;
  781. Procedure TQuery.SetexactTerms(AIndex : Integer; const AValue : String);
  782. begin
  783. If (FexactTerms=AValue) then exit;
  784. FexactTerms:=AValue;
  785. MarkPropertyChanged(AIndex);
  786. end;
  787. Procedure TQuery.SetexcludeTerms(AIndex : Integer; const AValue : String);
  788. begin
  789. If (FexcludeTerms=AValue) then exit;
  790. FexcludeTerms:=AValue;
  791. MarkPropertyChanged(AIndex);
  792. end;
  793. Procedure TQuery.SetfileType(AIndex : Integer; const AValue : String);
  794. begin
  795. If (FfileType=AValue) then exit;
  796. FfileType:=AValue;
  797. MarkPropertyChanged(AIndex);
  798. end;
  799. Procedure TQuery.Setfilter(AIndex : Integer; const AValue : String);
  800. begin
  801. If (Ffilter=AValue) then exit;
  802. Ffilter:=AValue;
  803. MarkPropertyChanged(AIndex);
  804. end;
  805. Procedure TQuery.Setgl(AIndex : Integer; const AValue : String);
  806. begin
  807. If (Fgl=AValue) then exit;
  808. Fgl:=AValue;
  809. MarkPropertyChanged(AIndex);
  810. end;
  811. Procedure TQuery.SetgoogleHost(AIndex : Integer; const AValue : String);
  812. begin
  813. If (FgoogleHost=AValue) then exit;
  814. FgoogleHost:=AValue;
  815. MarkPropertyChanged(AIndex);
  816. end;
  817. Procedure TQuery.SethighRange(AIndex : Integer; const AValue : String);
  818. begin
  819. If (FhighRange=AValue) then exit;
  820. FhighRange:=AValue;
  821. MarkPropertyChanged(AIndex);
  822. end;
  823. Procedure TQuery.Sethl(AIndex : Integer; const AValue : String);
  824. begin
  825. If (Fhl=AValue) then exit;
  826. Fhl:=AValue;
  827. MarkPropertyChanged(AIndex);
  828. end;
  829. Procedure TQuery.Sethq(AIndex : Integer; const AValue : String);
  830. begin
  831. If (Fhq=AValue) then exit;
  832. Fhq:=AValue;
  833. MarkPropertyChanged(AIndex);
  834. end;
  835. Procedure TQuery.SetimgColorType(AIndex : Integer; const AValue : String);
  836. begin
  837. If (FimgColorType=AValue) then exit;
  838. FimgColorType:=AValue;
  839. MarkPropertyChanged(AIndex);
  840. end;
  841. Procedure TQuery.SetimgDominantColor(AIndex : Integer; const AValue : String);
  842. begin
  843. If (FimgDominantColor=AValue) then exit;
  844. FimgDominantColor:=AValue;
  845. MarkPropertyChanged(AIndex);
  846. end;
  847. Procedure TQuery.SetimgSize(AIndex : Integer; const AValue : String);
  848. begin
  849. If (FimgSize=AValue) then exit;
  850. FimgSize:=AValue;
  851. MarkPropertyChanged(AIndex);
  852. end;
  853. Procedure TQuery.SetimgType(AIndex : Integer; const AValue : String);
  854. begin
  855. If (FimgType=AValue) then exit;
  856. FimgType:=AValue;
  857. MarkPropertyChanged(AIndex);
  858. end;
  859. Procedure TQuery.SetinputEncoding(AIndex : Integer; const AValue : String);
  860. begin
  861. If (FinputEncoding=AValue) then exit;
  862. FinputEncoding:=AValue;
  863. MarkPropertyChanged(AIndex);
  864. end;
  865. Procedure TQuery.Setlanguage(AIndex : Integer; const AValue : String);
  866. begin
  867. If (Flanguage=AValue) then exit;
  868. Flanguage:=AValue;
  869. MarkPropertyChanged(AIndex);
  870. end;
  871. Procedure TQuery.SetlinkSite(AIndex : Integer; const AValue : String);
  872. begin
  873. If (FlinkSite=AValue) then exit;
  874. FlinkSite:=AValue;
  875. MarkPropertyChanged(AIndex);
  876. end;
  877. Procedure TQuery.SetlowRange(AIndex : Integer; const AValue : String);
  878. begin
  879. If (FlowRange=AValue) then exit;
  880. FlowRange:=AValue;
  881. MarkPropertyChanged(AIndex);
  882. end;
  883. Procedure TQuery.SetorTerms(AIndex : Integer; const AValue : String);
  884. begin
  885. If (ForTerms=AValue) then exit;
  886. ForTerms:=AValue;
  887. MarkPropertyChanged(AIndex);
  888. end;
  889. Procedure TQuery.SetoutputEncoding(AIndex : Integer; const AValue : String);
  890. begin
  891. If (FoutputEncoding=AValue) then exit;
  892. FoutputEncoding:=AValue;
  893. MarkPropertyChanged(AIndex);
  894. end;
  895. Procedure TQuery.SetrelatedSite(AIndex : Integer; const AValue : String);
  896. begin
  897. If (FrelatedSite=AValue) then exit;
  898. FrelatedSite:=AValue;
  899. MarkPropertyChanged(AIndex);
  900. end;
  901. Procedure TQuery.Setrights(AIndex : Integer; const AValue : String);
  902. begin
  903. If (Frights=AValue) then exit;
  904. Frights:=AValue;
  905. MarkPropertyChanged(AIndex);
  906. end;
  907. Procedure TQuery.Setsafe(AIndex : Integer; const AValue : String);
  908. begin
  909. If (Fsafe=AValue) then exit;
  910. Fsafe:=AValue;
  911. MarkPropertyChanged(AIndex);
  912. end;
  913. Procedure TQuery.SetsearchTerms(AIndex : Integer; const AValue : String);
  914. begin
  915. If (FsearchTerms=AValue) then exit;
  916. FsearchTerms:=AValue;
  917. MarkPropertyChanged(AIndex);
  918. end;
  919. Procedure TQuery.SetsearchType(AIndex : Integer; const AValue : String);
  920. begin
  921. If (FsearchType=AValue) then exit;
  922. FsearchType:=AValue;
  923. MarkPropertyChanged(AIndex);
  924. end;
  925. Procedure TQuery.SetsiteSearch(AIndex : Integer; const AValue : String);
  926. begin
  927. If (FsiteSearch=AValue) then exit;
  928. FsiteSearch:=AValue;
  929. MarkPropertyChanged(AIndex);
  930. end;
  931. Procedure TQuery.SetsiteSearchFilter(AIndex : Integer; const AValue : String);
  932. begin
  933. If (FsiteSearchFilter=AValue) then exit;
  934. FsiteSearchFilter:=AValue;
  935. MarkPropertyChanged(AIndex);
  936. end;
  937. Procedure TQuery.Setsort(AIndex : Integer; const AValue : String);
  938. begin
  939. If (Fsort=AValue) then exit;
  940. Fsort:=AValue;
  941. MarkPropertyChanged(AIndex);
  942. end;
  943. Procedure TQuery.SetstartIndex(AIndex : Integer; const AValue : integer);
  944. begin
  945. If (FstartIndex=AValue) then exit;
  946. FstartIndex:=AValue;
  947. MarkPropertyChanged(AIndex);
  948. end;
  949. Procedure TQuery.SetstartPage(AIndex : Integer; const AValue : integer);
  950. begin
  951. If (FstartPage=AValue) then exit;
  952. FstartPage:=AValue;
  953. MarkPropertyChanged(AIndex);
  954. end;
  955. Procedure TQuery.Settitle(AIndex : Integer; const AValue : String);
  956. begin
  957. If (Ftitle=AValue) then exit;
  958. Ftitle:=AValue;
  959. MarkPropertyChanged(AIndex);
  960. end;
  961. Procedure TQuery.SettotalResults(AIndex : Integer; const AValue : String);
  962. begin
  963. If (FtotalResults=AValue) then exit;
  964. FtotalResults:=AValue;
  965. MarkPropertyChanged(AIndex);
  966. end;
  967. { --------------------------------------------------------------------
  968. TResultTypeimage
  969. --------------------------------------------------------------------}
  970. Procedure TResultTypeimage.SetbyteSize(AIndex : Integer; const AValue : integer);
  971. begin
  972. If (FbyteSize=AValue) then exit;
  973. FbyteSize:=AValue;
  974. MarkPropertyChanged(AIndex);
  975. end;
  976. Procedure TResultTypeimage.SetcontextLink(AIndex : Integer; const AValue : String);
  977. begin
  978. If (FcontextLink=AValue) then exit;
  979. FcontextLink:=AValue;
  980. MarkPropertyChanged(AIndex);
  981. end;
  982. Procedure TResultTypeimage.Setheight(AIndex : Integer; const AValue : integer);
  983. begin
  984. If (Fheight=AValue) then exit;
  985. Fheight:=AValue;
  986. MarkPropertyChanged(AIndex);
  987. end;
  988. Procedure TResultTypeimage.SetthumbnailHeight(AIndex : Integer; const AValue : integer);
  989. begin
  990. If (FthumbnailHeight=AValue) then exit;
  991. FthumbnailHeight:=AValue;
  992. MarkPropertyChanged(AIndex);
  993. end;
  994. Procedure TResultTypeimage.SetthumbnailLink(AIndex : Integer; const AValue : String);
  995. begin
  996. If (FthumbnailLink=AValue) then exit;
  997. FthumbnailLink:=AValue;
  998. MarkPropertyChanged(AIndex);
  999. end;
  1000. Procedure TResultTypeimage.SetthumbnailWidth(AIndex : Integer; const AValue : integer);
  1001. begin
  1002. If (FthumbnailWidth=AValue) then exit;
  1003. FthumbnailWidth:=AValue;
  1004. MarkPropertyChanged(AIndex);
  1005. end;
  1006. Procedure TResultTypeimage.Setwidth(AIndex : Integer; const AValue : integer);
  1007. begin
  1008. If (Fwidth=AValue) then exit;
  1009. Fwidth:=AValue;
  1010. MarkPropertyChanged(AIndex);
  1011. end;
  1012. { --------------------------------------------------------------------
  1013. TResultTypelabelsItem
  1014. --------------------------------------------------------------------}
  1015. Procedure TResultTypelabelsItem.SetdisplayName(AIndex : Integer; const AValue : String);
  1016. begin
  1017. If (FdisplayName=AValue) then exit;
  1018. FdisplayName:=AValue;
  1019. MarkPropertyChanged(AIndex);
  1020. end;
  1021. Procedure TResultTypelabelsItem.Setlabel_with_op(AIndex : Integer; const AValue : String);
  1022. begin
  1023. If (Flabel_with_op=AValue) then exit;
  1024. Flabel_with_op:=AValue;
  1025. MarkPropertyChanged(AIndex);
  1026. end;
  1027. Procedure TResultTypelabelsItem.Setname(AIndex : Integer; const AValue : String);
  1028. begin
  1029. If (Fname=AValue) then exit;
  1030. Fname:=AValue;
  1031. MarkPropertyChanged(AIndex);
  1032. end;
  1033. { --------------------------------------------------------------------
  1034. TResultTypepagemap
  1035. --------------------------------------------------------------------}
  1036. Class Function TResultTypepagemap.AllowAdditionalProperties : Boolean;
  1037. begin
  1038. Result:=True;
  1039. end;
  1040. { --------------------------------------------------------------------
  1041. TResult
  1042. --------------------------------------------------------------------}
  1043. Procedure TResult.SetcacheId(AIndex : Integer; const AValue : String);
  1044. begin
  1045. If (FcacheId=AValue) then exit;
  1046. FcacheId:=AValue;
  1047. MarkPropertyChanged(AIndex);
  1048. end;
  1049. Procedure TResult.SetdisplayLink(AIndex : Integer; const AValue : String);
  1050. begin
  1051. If (FdisplayLink=AValue) then exit;
  1052. FdisplayLink:=AValue;
  1053. MarkPropertyChanged(AIndex);
  1054. end;
  1055. Procedure TResult.SetfileFormat(AIndex : Integer; const AValue : String);
  1056. begin
  1057. If (FfileFormat=AValue) then exit;
  1058. FfileFormat:=AValue;
  1059. MarkPropertyChanged(AIndex);
  1060. end;
  1061. Procedure TResult.SetformattedUrl(AIndex : Integer; const AValue : String);
  1062. begin
  1063. If (FformattedUrl=AValue) then exit;
  1064. FformattedUrl:=AValue;
  1065. MarkPropertyChanged(AIndex);
  1066. end;
  1067. Procedure TResult.SethtmlFormattedUrl(AIndex : Integer; const AValue : String);
  1068. begin
  1069. If (FhtmlFormattedUrl=AValue) then exit;
  1070. FhtmlFormattedUrl:=AValue;
  1071. MarkPropertyChanged(AIndex);
  1072. end;
  1073. Procedure TResult.SethtmlSnippet(AIndex : Integer; const AValue : String);
  1074. begin
  1075. If (FhtmlSnippet=AValue) then exit;
  1076. FhtmlSnippet:=AValue;
  1077. MarkPropertyChanged(AIndex);
  1078. end;
  1079. Procedure TResult.SethtmlTitle(AIndex : Integer; const AValue : String);
  1080. begin
  1081. If (FhtmlTitle=AValue) then exit;
  1082. FhtmlTitle:=AValue;
  1083. MarkPropertyChanged(AIndex);
  1084. end;
  1085. Procedure TResult.Setimage(AIndex : Integer; const AValue : TResultTypeimage);
  1086. begin
  1087. If (Fimage=AValue) then exit;
  1088. Fimage:=AValue;
  1089. MarkPropertyChanged(AIndex);
  1090. end;
  1091. Procedure TResult.Setkind(AIndex : Integer; const AValue : String);
  1092. begin
  1093. If (Fkind=AValue) then exit;
  1094. Fkind:=AValue;
  1095. MarkPropertyChanged(AIndex);
  1096. end;
  1097. Procedure TResult.Setlabels(AIndex : Integer; const AValue : TResultTypelabelsArray);
  1098. begin
  1099. If (Flabels=AValue) then exit;
  1100. Flabels:=AValue;
  1101. MarkPropertyChanged(AIndex);
  1102. end;
  1103. Procedure TResult.Setlink(AIndex : Integer; const AValue : String);
  1104. begin
  1105. If (Flink=AValue) then exit;
  1106. Flink:=AValue;
  1107. MarkPropertyChanged(AIndex);
  1108. end;
  1109. Procedure TResult.Setmime(AIndex : Integer; const AValue : String);
  1110. begin
  1111. If (Fmime=AValue) then exit;
  1112. Fmime:=AValue;
  1113. MarkPropertyChanged(AIndex);
  1114. end;
  1115. Procedure TResult.Setpagemap(AIndex : Integer; const AValue : TResultTypepagemap);
  1116. begin
  1117. If (Fpagemap=AValue) then exit;
  1118. Fpagemap:=AValue;
  1119. MarkPropertyChanged(AIndex);
  1120. end;
  1121. Procedure TResult.Setsnippet(AIndex : Integer; const AValue : String);
  1122. begin
  1123. If (Fsnippet=AValue) then exit;
  1124. Fsnippet:=AValue;
  1125. MarkPropertyChanged(AIndex);
  1126. end;
  1127. Procedure TResult.Settitle(AIndex : Integer; const AValue : String);
  1128. begin
  1129. If (Ftitle=AValue) then exit;
  1130. Ftitle:=AValue;
  1131. MarkPropertyChanged(AIndex);
  1132. end;
  1133. //2.6.4. bug workaround
  1134. {$IFDEF VER2_6}
  1135. Procedure TResult.SetArrayLength(Const AName : String; ALength : Longint);
  1136. begin
  1137. Case AName of
  1138. 'labels' : SetLength(Flabels,ALength);
  1139. else
  1140. Inherited SetArrayLength(AName,ALength);
  1141. end;
  1142. end;
  1143. {$ENDIF VER2_6}
  1144. { --------------------------------------------------------------------
  1145. TSearchTypequeries
  1146. --------------------------------------------------------------------}
  1147. Class Function TSearchTypequeries.AllowAdditionalProperties : Boolean;
  1148. begin
  1149. Result:=True;
  1150. end;
  1151. { --------------------------------------------------------------------
  1152. TSearchTypesearchInformation
  1153. --------------------------------------------------------------------}
  1154. Procedure TSearchTypesearchInformation.SetformattedSearchTime(AIndex : Integer; const AValue : String);
  1155. begin
  1156. If (FformattedSearchTime=AValue) then exit;
  1157. FformattedSearchTime:=AValue;
  1158. MarkPropertyChanged(AIndex);
  1159. end;
  1160. Procedure TSearchTypesearchInformation.SetformattedTotalResults(AIndex : Integer; const AValue : String);
  1161. begin
  1162. If (FformattedTotalResults=AValue) then exit;
  1163. FformattedTotalResults:=AValue;
  1164. MarkPropertyChanged(AIndex);
  1165. end;
  1166. Procedure TSearchTypesearchInformation.SetsearchTime(AIndex : Integer; const AValue : double);
  1167. begin
  1168. If (FsearchTime=AValue) then exit;
  1169. FsearchTime:=AValue;
  1170. MarkPropertyChanged(AIndex);
  1171. end;
  1172. Procedure TSearchTypesearchInformation.SettotalResults(AIndex : Integer; const AValue : String);
  1173. begin
  1174. If (FtotalResults=AValue) then exit;
  1175. FtotalResults:=AValue;
  1176. MarkPropertyChanged(AIndex);
  1177. end;
  1178. { --------------------------------------------------------------------
  1179. TSearchTypespelling
  1180. --------------------------------------------------------------------}
  1181. Procedure TSearchTypespelling.SetcorrectedQuery(AIndex : Integer; const AValue : String);
  1182. begin
  1183. If (FcorrectedQuery=AValue) then exit;
  1184. FcorrectedQuery:=AValue;
  1185. MarkPropertyChanged(AIndex);
  1186. end;
  1187. Procedure TSearchTypespelling.SethtmlCorrectedQuery(AIndex : Integer; const AValue : String);
  1188. begin
  1189. If (FhtmlCorrectedQuery=AValue) then exit;
  1190. FhtmlCorrectedQuery:=AValue;
  1191. MarkPropertyChanged(AIndex);
  1192. end;
  1193. { --------------------------------------------------------------------
  1194. TSearchTypeurl
  1195. --------------------------------------------------------------------}
  1196. Procedure TSearchTypeurl.Settemplate(AIndex : Integer; const AValue : String);
  1197. begin
  1198. If (Ftemplate=AValue) then exit;
  1199. Ftemplate:=AValue;
  1200. MarkPropertyChanged(AIndex);
  1201. end;
  1202. Procedure TSearchTypeurl.Set_type(AIndex : Integer; const AValue : String);
  1203. begin
  1204. If (F_type=AValue) then exit;
  1205. F_type:=AValue;
  1206. MarkPropertyChanged(AIndex);
  1207. end;
  1208. Class Function TSearchTypeurl.ExportPropertyName(Const AName : String) :String;
  1209. begin
  1210. Case AName of
  1211. '_type' : Result:='type';
  1212. else
  1213. Result:=Inherited ExportPropertyName(AName);
  1214. end;
  1215. end;
  1216. { --------------------------------------------------------------------
  1217. TSearch
  1218. --------------------------------------------------------------------}
  1219. Procedure TSearch.Setcontext(AIndex : Integer; const AValue : TContext);
  1220. begin
  1221. If (Fcontext=AValue) then exit;
  1222. Fcontext:=AValue;
  1223. MarkPropertyChanged(AIndex);
  1224. end;
  1225. Procedure TSearch.Setitems(AIndex : Integer; const AValue : TSearchTypeitemsArray);
  1226. begin
  1227. If (Fitems=AValue) then exit;
  1228. Fitems:=AValue;
  1229. MarkPropertyChanged(AIndex);
  1230. end;
  1231. Procedure TSearch.Setkind(AIndex : Integer; const AValue : String);
  1232. begin
  1233. If (Fkind=AValue) then exit;
  1234. Fkind:=AValue;
  1235. MarkPropertyChanged(AIndex);
  1236. end;
  1237. Procedure TSearch.Setpromotions(AIndex : Integer; const AValue : TSearchTypepromotionsArray);
  1238. begin
  1239. If (Fpromotions=AValue) then exit;
  1240. Fpromotions:=AValue;
  1241. MarkPropertyChanged(AIndex);
  1242. end;
  1243. Procedure TSearch.Setqueries(AIndex : Integer; const AValue : TSearchTypequeries);
  1244. begin
  1245. If (Fqueries=AValue) then exit;
  1246. Fqueries:=AValue;
  1247. MarkPropertyChanged(AIndex);
  1248. end;
  1249. Procedure TSearch.SetsearchInformation(AIndex : Integer; const AValue : TSearchTypesearchInformation);
  1250. begin
  1251. If (FsearchInformation=AValue) then exit;
  1252. FsearchInformation:=AValue;
  1253. MarkPropertyChanged(AIndex);
  1254. end;
  1255. Procedure TSearch.Setspelling(AIndex : Integer; const AValue : TSearchTypespelling);
  1256. begin
  1257. If (Fspelling=AValue) then exit;
  1258. Fspelling:=AValue;
  1259. MarkPropertyChanged(AIndex);
  1260. end;
  1261. Procedure TSearch.Seturl(AIndex : Integer; const AValue : TSearchTypeurl);
  1262. begin
  1263. If (Furl=AValue) then exit;
  1264. Furl:=AValue;
  1265. MarkPropertyChanged(AIndex);
  1266. end;
  1267. //2.6.4. bug workaround
  1268. {$IFDEF VER2_6}
  1269. Procedure TSearch.SetArrayLength(Const AName : String; ALength : Longint);
  1270. begin
  1271. Case AName of
  1272. 'items' : SetLength(Fitems,ALength);
  1273. 'promotions' : SetLength(Fpromotions,ALength);
  1274. else
  1275. Inherited SetArrayLength(AName,ALength);
  1276. end;
  1277. end;
  1278. {$ENDIF VER2_6}
  1279. { --------------------------------------------------------------------
  1280. TCseResource
  1281. --------------------------------------------------------------------}
  1282. Class Function TCseResource.ResourceName : String;
  1283. begin
  1284. Result:='cse';
  1285. end;
  1286. Class Function TCseResource.DefaultAPI : TGoogleAPIClass;
  1287. begin
  1288. Result:=TcustomsearchAPI;
  1289. end;
  1290. Function TCseResource.List(AQuery : string = '') : TSearch;
  1291. Const
  1292. _HTTPMethod = 'GET';
  1293. _Path = 'v1';
  1294. _Methodid = 'search.cse.list';
  1295. begin
  1296. Result:=ServiceCall(_HTTPMethod,_Path,AQuery,Nil,TSearch) as TSearch;
  1297. end;
  1298. Function TCseResource.List(AQuery : TCselistOptions) : TSearch;
  1299. Var
  1300. _Q : String;
  1301. begin
  1302. _Q:='';
  1303. AddToQuery(_Q,'c2coff',AQuery.c2coff);
  1304. AddToQuery(_Q,'cr',AQuery.cr);
  1305. AddToQuery(_Q,'cref',AQuery.cref);
  1306. AddToQuery(_Q,'cx',AQuery.cx);
  1307. AddToQuery(_Q,'dateRestrict',AQuery.dateRestrict);
  1308. AddToQuery(_Q,'exactTerms',AQuery.exactTerms);
  1309. AddToQuery(_Q,'excludeTerms',AQuery.excludeTerms);
  1310. AddToQuery(_Q,'fileType',AQuery.fileType);
  1311. AddToQuery(_Q,'filter',AQuery.filter);
  1312. AddToQuery(_Q,'gl',AQuery.gl);
  1313. AddToQuery(_Q,'googlehost',AQuery.googlehost);
  1314. AddToQuery(_Q,'highRange',AQuery.highRange);
  1315. AddToQuery(_Q,'hl',AQuery.hl);
  1316. AddToQuery(_Q,'hq',AQuery.hq);
  1317. AddToQuery(_Q,'imgColorType',AQuery.imgColorType);
  1318. AddToQuery(_Q,'imgDominantColor',AQuery.imgDominantColor);
  1319. AddToQuery(_Q,'imgSize',AQuery.imgSize);
  1320. AddToQuery(_Q,'imgType',AQuery.imgType);
  1321. AddToQuery(_Q,'linkSite',AQuery.linkSite);
  1322. AddToQuery(_Q,'lowRange',AQuery.lowRange);
  1323. AddToQuery(_Q,'lr',AQuery.lr);
  1324. AddToQuery(_Q,'num',AQuery.num);
  1325. AddToQuery(_Q,'orTerms',AQuery.orTerms);
  1326. AddToQuery(_Q,'q',AQuery.q);
  1327. AddToQuery(_Q,'relatedSite',AQuery.relatedSite);
  1328. AddToQuery(_Q,'rights',AQuery.rights);
  1329. AddToQuery(_Q,'safe',AQuery.safe);
  1330. AddToQuery(_Q,'searchType',AQuery.searchType);
  1331. AddToQuery(_Q,'siteSearch',AQuery.siteSearch);
  1332. AddToQuery(_Q,'siteSearchFilter',AQuery.siteSearchFilter);
  1333. AddToQuery(_Q,'sort',AQuery.sort);
  1334. AddToQuery(_Q,'start',AQuery.start);
  1335. Result:=List(_Q);
  1336. end;
  1337. { --------------------------------------------------------------------
  1338. TCustomsearchAPI
  1339. --------------------------------------------------------------------}
  1340. Class Function TCustomsearchAPI.APIName : String;
  1341. begin
  1342. Result:='customsearch';
  1343. end;
  1344. Class Function TCustomsearchAPI.APIVersion : String;
  1345. begin
  1346. Result:='v1';
  1347. end;
  1348. Class Function TCustomsearchAPI.APIRevision : String;
  1349. begin
  1350. Result:='20160411';
  1351. end;
  1352. Class Function TCustomsearchAPI.APIID : String;
  1353. begin
  1354. Result:='customsearch:v1';
  1355. end;
  1356. Class Function TCustomsearchAPI.APITitle : String;
  1357. begin
  1358. Result:='CustomSearch API';
  1359. end;
  1360. Class Function TCustomsearchAPI.APIDescription : String;
  1361. begin
  1362. Result:='Lets you search over a website or collection of websites';
  1363. end;
  1364. Class Function TCustomsearchAPI.APIOwnerDomain : String;
  1365. begin
  1366. Result:='google.com';
  1367. end;
  1368. Class Function TCustomsearchAPI.APIOwnerName : String;
  1369. begin
  1370. Result:='Google';
  1371. end;
  1372. Class Function TCustomsearchAPI.APIIcon16 : String;
  1373. begin
  1374. Result:='http://www.google.com/images/icons/product/search-16.gif';
  1375. end;
  1376. Class Function TCustomsearchAPI.APIIcon32 : String;
  1377. begin
  1378. Result:='http://www.google.com/images/icons/product/search-32.gif';
  1379. end;
  1380. Class Function TCustomsearchAPI.APIdocumentationLink : String;
  1381. begin
  1382. Result:='https://developers.google.com/custom-search/v1/using_rest';
  1383. end;
  1384. Class Function TCustomsearchAPI.APIrootUrl : string;
  1385. begin
  1386. Result:='https://www.googleapis.com/';
  1387. end;
  1388. Class Function TCustomsearchAPI.APIbasePath : string;
  1389. begin
  1390. Result:='/customsearch/';
  1391. end;
  1392. Class Function TCustomsearchAPI.APIbaseURL : String;
  1393. begin
  1394. Result:='https://www.googleapis.com/customsearch/';
  1395. end;
  1396. Class Function TCustomsearchAPI.APIProtocol : string;
  1397. begin
  1398. Result:='rest';
  1399. end;
  1400. Class Function TCustomsearchAPI.APIservicePath : string;
  1401. begin
  1402. Result:='customsearch/';
  1403. end;
  1404. Class Function TCustomsearchAPI.APIbatchPath : String;
  1405. begin
  1406. Result:='batch';
  1407. end;
  1408. Class Function TCustomsearchAPI.APIAuthScopes : TScopeInfoArray;
  1409. begin
  1410. SetLength(Result,0);
  1411. end;
  1412. Class Function TCustomsearchAPI.APINeedsAuth : Boolean;
  1413. begin
  1414. Result:=False;
  1415. end;
  1416. Class Procedure TCustomsearchAPI.RegisterAPIResources;
  1417. begin
  1418. TContextTypefacetsItemItem.RegisterObject;
  1419. TContext.RegisterObject;
  1420. TPromotionTypebodyLinesItem.RegisterObject;
  1421. TPromotionTypeimage.RegisterObject;
  1422. TPromotion.RegisterObject;
  1423. TQuery.RegisterObject;
  1424. TResultTypeimage.RegisterObject;
  1425. TResultTypelabelsItem.RegisterObject;
  1426. TResultTypepagemap.RegisterObject;
  1427. TResult.RegisterObject;
  1428. TSearchTypequeries.RegisterObject;
  1429. TSearchTypesearchInformation.RegisterObject;
  1430. TSearchTypespelling.RegisterObject;
  1431. TSearchTypeurl.RegisterObject;
  1432. TSearch.RegisterObject;
  1433. end;
  1434. Function TCustomsearchAPI.GetCseInstance : TCseResource;
  1435. begin
  1436. if (FCseInstance=Nil) then
  1437. FCseInstance:=CreateCseResource;
  1438. Result:=FCseInstance;
  1439. end;
  1440. Function TCustomsearchAPI.CreateCseResource : TCseResource;
  1441. begin
  1442. Result:=CreateCseResource(Self);
  1443. end;
  1444. Function TCustomsearchAPI.CreateCseResource(AOwner : TComponent) : TCseResource;
  1445. begin
  1446. Result:=TCseResource.Create(AOwner);
  1447. Result.API:=Self.API;
  1448. end;
  1449. initialization
  1450. TCustomsearchAPI.RegisterAPI;
  1451. end.