unit djson_sax;

interface

uses
  derror,
  dstrings,
  dstrnum,
  dparser,
  dstream,
  dtokenizer;

type
PJsonParser = ^TJsonParser;
TJsonParser = object
protected
  FDepth: LongInt;
  FError: TError;
  FLookupReader: TLookupReader;
  procedure OnNull(Res: Pointer); virtual;
  procedure OnBoolean(B: Boolean; Res: Pointer); virtual;
  procedure OnInteger(I: Int64; Res: Pointer); virtual;
  procedure OnString(const S: TAnsiBuf; Res: Pointer); virtual;
  procedure OnFloat(F: Double; Res: Pointer); virtual;
  function OnOpenArray(Res: Pointer): Boolean; virtual; // call ParseArray inside
  procedure OnCloseArray(Res: Pointer); virtual;
  function OnOpenObject(Res: Pointer): Boolean; virtual; // call ParseObject inside
  procedure OnCloseObject(Res: Pointer); virtual;
  procedure OnKey(const Key: TAnsiBuf; Res: Pointer); virtual;
  function ParseIdentifier(Res: Pointer): Boolean; // "key": "value"
  function ParsePair(Res: Pointer): Boolean; // "key": "value"
  function ParseObject(Res: Pointer): Boolean; // pair,* }
  function ParseArray(Res: Pointer): Boolean; // value,* ]
  property Depth: LongInt read FDepth;
public
  constructor Init;
  destructor Done; virtual;
  function Parse(Data: TData): Boolean; // parse json value
  property Error: TError read FError;
end;

implementation

constructor TJsonParser.Init;
begin
  FDepth := 0;
end;

destructor TJsonParser.Done;
begin
end;

procedure TJsonParser.OnNull(Res: Pointer);
begin
end;

procedure TJsonParser.OnBoolean(B: Boolean; Res: Pointer);
begin
end;

procedure TJsonParser.OnInteger(I: Int64; Res: Pointer);
begin
end;

procedure TJsonParser.OnString(const S: TAnsiBuf; Res: Pointer);
begin
end;

procedure TJsonParser.OnFloat(F: Double; Res: Pointer);
begin
end;

function TJsonParser.OnOpenArray(Res: Pointer): Boolean;
begin
  Result := ParseArray(Res);
end;

procedure TJsonParser.OnCloseArray(Res: Pointer);
begin
end;

function TJsonParser.OnOpenObject(Res: Pointer): Boolean;
begin
  Result := ParseObject(Res);
end;

procedure TJsonParser.OnCloseObject(Res: Pointer);
begin
end;

procedure TJsonParser.OnKey(const Key: TAnsiBuf; Res: Pointer);
begin
end;

function TJsonParser.ParseIdentifier(Res: Pointer): Boolean;
begin
  Result := False;
end;

function TJsonParser.ParsePair(Res: Pointer): Boolean;
begin
  Result := False;
end;

function TJsonParser.ParseObject(Res: Pointer): Boolean;
begin
  Result := False;
end;

function TJsonParser.ParseArray(Res: Pointer): Boolean;
begin
  Result := False;
end;

function TJsonParser.Parse(Data: TData): Boolean;
begin
  Result := False;
end;

end.
