Skip to content

Commit

Permalink
see issue 44
Browse files Browse the repository at this point in the history
  • Loading branch information
stijnsanders committed Aug 20, 2017
1 parent f112b98 commit c0643bb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
10 changes: 8 additions & 2 deletions bsonTools.pas
Expand Up @@ -51,7 +51,9 @@ TBSONDocArray=class(TJSONImplBaseObj, IJSONArray, IJSONDocArray,
function Get_Item(Index: integer): Variant; stdcall;
procedure Set_Item(Index: integer; const Value: Variant); stdcall;
function Count: integer; stdcall;
function ToString: WideString; stdcall;
function JSONToString: WideString; stdcall;
function IJSONArray.ToString=JSONToString;
function IJSONDocArray.ToString=JSONToString;
function v0(Index: integer): pointer; stdcall;
property Item[Idx: integer]: Variant read Get_Item write Set_Item; default;
//IJSONDocArray
Expand Down Expand Up @@ -316,6 +318,8 @@ procedure LoadBSON(Data: TStream; const Doc: IJSONDocument);
d0:=0;
IsArray:=false;
d:=Doc;
sl:=0;
ss:='';
while (ltotal<ltmax) and (stackIndex<>-1) do
begin
i:=0;
Expand Down Expand Up @@ -815,6 +819,8 @@ procedure SaveBSON(const Doc: IJSONDocument; Data: TStream);
pp:pointer absolute o;
bb:byte;
begin
stackIndex:=0;
stackLength:=0;
lstart:=Data.Position;//may not be 0!
ltotal:=0;
i:=0;//write now, fill in later
Expand Down Expand Up @@ -1109,7 +1115,7 @@ procedure TBSONDocArray.Set_Item(Index: integer; const Value: Variant);
FRef[Index]:=p;
end;

function TBSONDocArray.ToString: WideString;
function TBSONDocArray.JSONToString: WideString;
var
i:integer;
d:IJSONDocument;
Expand Down
3 changes: 2 additions & 1 deletion demo/example1/mwx1Main.pas
Expand Up @@ -64,7 +64,8 @@ procedure TMainForm.FormShow(Sender: TObject);
begin
try
if ConnectionForm.ShowModal=mrOk then
FMongoWire.Open(ConnectionForm.txtHost.Text,StrToInt(ConnectionForm.txtPort.Text))
FMongoWire.Open(AnsiString(ConnectionForm.txtHost.Text),
StrToInt(ConnectionForm.txtPort.Text))
else

raise Exception.Create('User abort');
Expand Down
6 changes: 4 additions & 2 deletions jsonDoc.pas
Expand Up @@ -355,13 +355,15 @@ TJSONDocArray = class(TJSONImplBaseObj, IJSONArray, IJSONDocArray)
function Get_Item(Index: integer): Variant; stdcall;
procedure Set_Item(Index: integer; const Value: Variant); stdcall;
function Count: integer; stdcall;
function ToString: WideString; stdcall;
function JSONToString: WideString; stdcall;
function IJSONArray.ToString=JSONToString;
function v0(Index: integer): pointer; stdcall;
//function IJSONArray.ToString=JSONToString;
//IJSONDocArray
function Add(const Doc: IJSONDocument): integer; stdcall;
function AddJson(const Data: WideString): integer; stdcall;
procedure LoadItem(Index: integer; const Doc: IJSONDocument); stdcall;
function IJSONDocArray.ToString=JSONToString;
procedure Clear; stdcall;
public
constructor Create;
Expand Down Expand Up @@ -2262,7 +2264,7 @@ procedure TJSONDocArray.LoadItem(Index: integer; const Doc: IJSONDocument);
{$ENDIF}
end;

function TJSONDocArray.ToString: WideString;
function TJSONDocArray.JSONToString: WideString;
var
i,x,l:integer;
begin
Expand Down

0 comments on commit c0643bb

Please sign in to comment.