home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / modules / rdf / src / query.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  3.9 KB  |  114 lines

  1. /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18.  
  19. #ifndef query_h___
  20. #define query_h___
  21.  
  22. /* the RDF Query API. */
  23.  
  24. #include "rdf.h"
  25.  
  26. typedef uint8 RDF_TermType; /* type of a term */
  27.  
  28. /* values of RDF_TermType */
  29. #define RDF_VARIABLE_TERM_TYPE 1
  30. #define RDF_RESOURCE_TERM_TYPE 2
  31. #define RDF_CONSTANT_TERM_TYPE 3
  32.  
  33. typedef struct _RDF_VariableStruc {
  34.     void* value;
  35.     RDF_ValueType type;
  36.     char* id;
  37.     PRBool isResult;
  38.     struct _RDF_QueryStruc* query;
  39. } RDF_VariableStruc;
  40.  
  41. typedef RDF_VariableStruc* RDF_Variable;
  42.  
  43. typedef struct _RDF_VariableListStruc {
  44.     RDF_Variable element;
  45.     struct _RDF_VariableListStruc* next;
  46. } RDF_VariableListStruc;
  47.  
  48. typedef RDF_VariableListStruc* RDF_VariableList;
  49.  
  50. PR_PUBLIC_API(PRBool) RDF_IsResultVariable(RDF_Variable var);
  51. PR_PUBLIC_API(void) RDF_SetResultVariable(RDF_Variable var, PRBool isResult);
  52. PR_PUBLIC_API(void*) RDF_GetVariableValue(RDF_Variable var);
  53. PR_PUBLIC_API(void) RDF_SetVariableValue(RDF_Variable var, void* value, RDF_ValueType type);
  54.  
  55. typedef struct _Term {
  56.     void* value;
  57.     RDF_TermType type;
  58. } TermStruc;
  59.  
  60. typedef struct TermStruc* RDF_Term;
  61.  
  62. typedef struct _LiteralStruc {
  63.     TermStruc u;
  64.     RDF_Resource s;
  65.     TermStruc* v;
  66.     uint8 valueCount; /* disjunction */
  67.     RDF_Cursor c;
  68.     PRBool tv;
  69.     PRBool bt;
  70.     RDF_Variable variable;
  71.     RDF_ValueType valueType;
  72. } LiteralStruc;
  73.  
  74. typedef LiteralStruc* RDF_Literal;
  75.  
  76. typedef struct _RDF_LiteralListStruc {
  77.     RDF_Literal element;
  78.     struct _RDF_LiteralListStruc* next;
  79. } RDF_LiteralListStruc;
  80.  
  81. typedef RDF_LiteralListStruc* RDF_LiteralList;
  82.  
  83. typedef struct _RDF_QueryStruc {
  84.   struct _RDF_VariableListStruc* variables;
  85.   struct _RDF_LiteralListStruc* literals;
  86.   uint16 numLiterals;
  87.   uint16 index;
  88.   PRBool conjunctsOrdered;
  89.   PRBool queryRunning;
  90.   RDF rdf;
  91. } RDF_QueryStruc;
  92.  
  93. typedef RDF_QueryStruc* RDF_Query;
  94.  
  95. /* Note: the API assumes that the query parameter is non-NULL. */
  96. PR_PUBLIC_API(RDF_Query) RDF_CreateQuery(RDF rdf);
  97. PR_PUBLIC_API(void) RDF_DestroyQuery(RDF_Query q);
  98. PR_PUBLIC_API(RDF_Variable) RDF_GetVariable(RDF_Query q, char* name);
  99. PR_PUBLIC_API(PRBool) RDF_RunQuery (RDF_Query q);
  100. PR_PUBLIC_API(PRBool) RDF_GetNextElement(RDF_Query q);
  101. PR_PUBLIC_API(void) RDF_EndQuery (RDF_Query q);
  102. PR_PUBLIC_API(RDF_VariableList) RDF_GetVariableList(RDF_Query q);
  103. PR_PUBLIC_API(uint16) RDF_GetVariableListCount(RDF_Query q);
  104. PR_PUBLIC_API(RDF_Variable) RDF_GetNthVariable(RDF_Query q, uint16 index);
  105. PR_PUBLIC_API(RDF_Error) RDF_AddConjunctVRV(RDF_Query q, RDF_Variable arg1, RDF_Resource s, RDF_Variable arg2, RDF_ValueType type);
  106. PR_PUBLIC_API(RDF_Error) RDF_AddConjunctVRO(RDF_Query q, RDF_Variable arg1, RDF_Resource s, void* arg2, RDF_ValueType type);
  107. PR_PUBLIC_API(RDF_Error) RDF_AddConjunctRRO(RDF_Query q, RDF_Resource arg1, RDF_Resource s, void* arg2, RDF_ValueType type);
  108. PR_PUBLIC_API(RDF_Error) RDF_AddConjunctVRR(RDF_Query q, RDF_Variable arg1, RDF_Resource s, RDF_Resource arg2);
  109. PR_PUBLIC_API(RDF_Error) RDF_AddConjunctRRV(RDF_Query q, RDF_Resource arg1, RDF_Resource s, RDF_Variable arg2, RDF_ValueType type);
  110. PR_PUBLIC_API(RDF_Error) RDF_AddConjunctVRL(RDF_Query q, RDF_Variable arg1, RDF_Resource s, RDF_Term arg2, RDF_ValueType type, uint8 count);
  111.  
  112. #endif /* query_h___ */
  113.  
  114.