Start of BString and BList support by Eric
This commit is contained in:
510
bepascal/bepascal/be/support/BString.pp
Normal file
510
bepascal/bepascal/be/support/BString.pp
Normal file
@@ -0,0 +1,510 @@
|
|||||||
|
{ BePascal - A pascal wrapper around the BeOS API
|
||||||
|
Copyright (C) 2002 Eric Jourde
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Library General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Library General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Library General Public
|
||||||
|
License along with this library; if not, write to the Free
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
}
|
||||||
|
|
||||||
|
unit BString;
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
uses
|
||||||
|
beobj, SupportDefs, os;
|
||||||
|
|
||||||
|
type
|
||||||
|
TString = class(TBeObject)
|
||||||
|
private
|
||||||
|
public
|
||||||
|
constructor Create; override;
|
||||||
|
// constructor Create(value : PChar); override;
|
||||||
|
destructor Destroy; override;
|
||||||
|
|
||||||
|
function CountChars : integer;
|
||||||
|
function length : integer;
|
||||||
|
function String_pchar : PChar;
|
||||||
|
|
||||||
|
// Affectation
|
||||||
|
procedure SetTo(value:PChar; lenght : cardinal);
|
||||||
|
procedure SetTo( from: TString);
|
||||||
|
procedure SetTo( value:TString; length1: cardinal);
|
||||||
|
procedure Adopt( from:TString);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
function BString_Create(AObject : TBeObject):TCPlusObject; cdecl; external BePascalLibName name 'BString_Create';
|
||||||
|
function BString_Create(AObject : TBeObject;value : PChar):TCPlusObject; cdecl; external BePascalLibName name 'BString_Create_1';
|
||||||
|
procedure BString_Free(AObject : TCPlusObject);cdecl; external BePascalLibName name 'BString_Free';
|
||||||
|
function BString_CountChars(AObject : TCPlusObject): cardinal;cdecl; external BePascalLibName name 'BString_CountChars';
|
||||||
|
function BString_Length(AObject : TCPlusObject): cardinal;cdecl; external BePascalLibName name 'BString_Length';
|
||||||
|
function BString_String(AObject : TCPlusObject): Pchar;cdecl; external BePascalLibName name 'BString_String';
|
||||||
|
|
||||||
|
procedure BString_SetTo(AObject : TCPlusObject;value:Pchar;length:cardinal);cdecl; external BePascalLibName name 'BString_SetTo';
|
||||||
|
procedure BString_SetTo_1(AObject : TCPlusObject; from: TBeObject);cdecl; external BePascalLibName name 'BString_SetTo_1';
|
||||||
|
procedure BString_SetTo_2(AObject : TCPlusObject; value:TBeObject;length: cardinal);cdecl; external BePascalLibName name 'BString_SetTo_2';
|
||||||
|
|
||||||
|
procedure BString_Adopt(AObject : TCPlusObject; from:TBeObject);cdecl; external BePascalLibName name 'BString_Adopt';
|
||||||
|
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
BString &
|
||||||
|
BString_Adopt_1(BString *String, BString &from,
|
||||||
|
int32 length)
|
||||||
|
|
||||||
|
BString &
|
||||||
|
BString_SetTo_3(BString *String, char value,
|
||||||
|
int32 count)
|
||||||
|
|
||||||
|
|
||||||
|
BString &
|
||||||
|
BString_CopyInto(BString *String, BString &into,
|
||||||
|
int32 fromOffset,
|
||||||
|
int32 length)
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BString_CopyInto_1
|
||||||
|
(BString *String, char *into,
|
||||||
|
int32 fromOffset,
|
||||||
|
int32 length)
|
||||||
|
|
||||||
|
|
||||||
|
BString &
|
||||||
|
BString_Append(BString *String, const BString &value,
|
||||||
|
int32 length)
|
||||||
|
|
||||||
|
BString &
|
||||||
|
BString_Append_1
|
||||||
|
(BString *String, const char *value,
|
||||||
|
int32 length)
|
||||||
|
|
||||||
|
BString &
|
||||||
|
BString_Append_2
|
||||||
|
(BString *String, char value,
|
||||||
|
int32 count)
|
||||||
|
|
||||||
|
BString &
|
||||||
|
BString_Prepend(BString *String, const char *value)
|
||||||
|
|
||||||
|
BString &
|
||||||
|
BString_Prepend_1
|
||||||
|
(BString *String, const BString &value)
|
||||||
|
|
||||||
|
BString &
|
||||||
|
BString_Prepend_2
|
||||||
|
(BString *String, const char *value,
|
||||||
|
int32 length)
|
||||||
|
|
||||||
|
BString &
|
||||||
|
BString_Prepend_3
|
||||||
|
(BString *String, const BString &value,
|
||||||
|
int32 length)
|
||||||
|
|
||||||
|
BString &
|
||||||
|
BString_Prepend_4
|
||||||
|
(BString *String, char value,
|
||||||
|
int32 count)
|
||||||
|
|
||||||
|
BString &
|
||||||
|
BString_Insert(BString *String, const char *value,
|
||||||
|
int32 pos)
|
||||||
|
|
||||||
|
BString &
|
||||||
|
BString_Insert_1
|
||||||
|
(BString *String, const char *value,
|
||||||
|
int32 length,
|
||||||
|
int32 pos)
|
||||||
|
|
||||||
|
BString &
|
||||||
|
BString_Insert_2
|
||||||
|
(BString *String, const char *value,
|
||||||
|
int32 fromOffset,
|
||||||
|
int32 length,
|
||||||
|
int32 pos)
|
||||||
|
|
||||||
|
BString &
|
||||||
|
BString_Insert_3
|
||||||
|
(BString *String, const BString &value,
|
||||||
|
int32 pos)
|
||||||
|
|
||||||
|
BString &
|
||||||
|
BString_Insert_4
|
||||||
|
(BString *String, const BString &value,
|
||||||
|
int32 length,
|
||||||
|
int32 pos)
|
||||||
|
|
||||||
|
BString &
|
||||||
|
BString_Insert_5
|
||||||
|
(BString *String, const BString &value,
|
||||||
|
int32 fromOffset,
|
||||||
|
int32 length,
|
||||||
|
int32 pos)
|
||||||
|
|
||||||
|
BString &
|
||||||
|
BString_Insert_6
|
||||||
|
(BString *String, char value,
|
||||||
|
int32 count,
|
||||||
|
int32 pos)
|
||||||
|
|
||||||
|
BString &
|
||||||
|
BString_Truncate(BString *String, int32 newLength,
|
||||||
|
bool lazy)
|
||||||
|
|
||||||
|
BString &
|
||||||
|
BString_Remove(BString *String, int32 from,
|
||||||
|
int32 length)
|
||||||
|
|
||||||
|
BString &
|
||||||
|
BString_RemoveFirst_1
|
||||||
|
(BString *String, const BString &value)
|
||||||
|
|
||||||
|
BString &
|
||||||
|
BString_RemoveLast(BString *String, const BString &value)
|
||||||
|
|
||||||
|
BString &
|
||||||
|
BString_RemoveAll(BString *String, const BString &value)
|
||||||
|
|
||||||
|
BString &
|
||||||
|
BString_RemoveFirst(BString *String, const char *value)
|
||||||
|
|
||||||
|
BString &
|
||||||
|
BString_RemoveLast_1(BString *String, const char *value)
|
||||||
|
|
||||||
|
BString &
|
||||||
|
BString_RemoveAll_1(BString *String, const char *value)
|
||||||
|
|
||||||
|
BString &
|
||||||
|
BString_RemoveSet(BString *String, const char *setOfCharsToRemove)
|
||||||
|
|
||||||
|
BString &
|
||||||
|
BString_MoveInto(BString *String, BString &into,
|
||||||
|
int32 from,
|
||||||
|
int32 length)
|
||||||
|
|
||||||
|
void
|
||||||
|
BString_MoveInto_1
|
||||||
|
(BString *String, char *into,
|
||||||
|
int32 from,
|
||||||
|
int32 length)
|
||||||
|
|
||||||
|
int
|
||||||
|
BString_Compare(BString *String, const BString &value)
|
||||||
|
|
||||||
|
int
|
||||||
|
BString_Compare_1
|
||||||
|
(BString *String, const char *value)
|
||||||
|
|
||||||
|
int
|
||||||
|
BString_Compare_2
|
||||||
|
(BString *String, const BString &value,
|
||||||
|
int32 n)
|
||||||
|
|
||||||
|
int
|
||||||
|
BString_Compare_3
|
||||||
|
(BString *String, const char *value,
|
||||||
|
int32 n)
|
||||||
|
|
||||||
|
int
|
||||||
|
BString_ICompare(BString *String, const BString &value)
|
||||||
|
|
||||||
|
int
|
||||||
|
BString_ICompare_1
|
||||||
|
(BString *String, const char *value)
|
||||||
|
|
||||||
|
int
|
||||||
|
BString_ICompare_2
|
||||||
|
(BString *String, const BString &value,
|
||||||
|
int32 n)
|
||||||
|
|
||||||
|
int
|
||||||
|
BString_ICompare_3
|
||||||
|
(BString *String, const char *value,
|
||||||
|
int32 n)
|
||||||
|
|
||||||
|
int32
|
||||||
|
BString_FindFirst(BString *String, const BString &value)
|
||||||
|
|
||||||
|
int32
|
||||||
|
BString_FindFirst_1
|
||||||
|
(BString *String, const char *value)
|
||||||
|
|
||||||
|
int32
|
||||||
|
BString_FindFirst_2
|
||||||
|
(BString *String, const BString &value,
|
||||||
|
int32 fromOffset)
|
||||||
|
|
||||||
|
int32
|
||||||
|
BString_FindFirst_3
|
||||||
|
(BString *String, const char *value,
|
||||||
|
int32 fromOffset)
|
||||||
|
|
||||||
|
int32
|
||||||
|
BString_FindFirst_4
|
||||||
|
(BString *String, char value)
|
||||||
|
|
||||||
|
int32
|
||||||
|
BString_FindFirst_5
|
||||||
|
(BString *String, char value,
|
||||||
|
int32 fromOffset)
|
||||||
|
|
||||||
|
int32
|
||||||
|
BString_FindLast(BString *String, const BString &value)
|
||||||
|
|
||||||
|
int32
|
||||||
|
BString_FindLast_1
|
||||||
|
(BString *String, const char *value)
|
||||||
|
|
||||||
|
int32
|
||||||
|
BString_FindLast_2
|
||||||
|
(BString *String, const BString &value,
|
||||||
|
int32 beforeOffset)
|
||||||
|
|
||||||
|
int32
|
||||||
|
BString_FindLast_3
|
||||||
|
(BString *String, const char *value,
|
||||||
|
int32 beforeOffset)
|
||||||
|
|
||||||
|
int32
|
||||||
|
BString_FindLast_4
|
||||||
|
(BString *String, char value)
|
||||||
|
|
||||||
|
int32
|
||||||
|
BString_FindLast_5
|
||||||
|
(BString *String, char value,
|
||||||
|
int32 fromOffset)
|
||||||
|
|
||||||
|
int32
|
||||||
|
BString_IFindFirst(BString *String, const BString &value)
|
||||||
|
|
||||||
|
int32
|
||||||
|
BString_IFindFirst_1
|
||||||
|
(BString *String, const char *value)
|
||||||
|
|
||||||
|
int32
|
||||||
|
BString_IFindFirst_2
|
||||||
|
(BString *String, const BString &value,
|
||||||
|
int32 fromOffset)
|
||||||
|
|
||||||
|
int32
|
||||||
|
BString_IFindFirst_3
|
||||||
|
(BString *String, const char *value,
|
||||||
|
int32 fromOffset)
|
||||||
|
|
||||||
|
int32
|
||||||
|
BString_IFindLast(BString *String, const BString &value)
|
||||||
|
|
||||||
|
int32
|
||||||
|
BString_IFindLast_1
|
||||||
|
(BString *String, const char *value)
|
||||||
|
|
||||||
|
int32
|
||||||
|
BString_IFindLast_2
|
||||||
|
(BString *String, const BString &value,
|
||||||
|
int32 beforeOffset)
|
||||||
|
|
||||||
|
int32
|
||||||
|
BString_IFindLast_3
|
||||||
|
(BString *String, const char *value,
|
||||||
|
int32 beforeOffset)
|
||||||
|
|
||||||
|
BString &
|
||||||
|
BString_ReplaceFirst(BString *String, char replaceThis,
|
||||||
|
char withThis)
|
||||||
|
|
||||||
|
BString &
|
||||||
|
BString_ReplaceLast(BString *String, char replaceThis,
|
||||||
|
char withThis)
|
||||||
|
|
||||||
|
BString &
|
||||||
|
BString_ReplaceAll(BString *String, char replaceThis,
|
||||||
|
char withThis,
|
||||||
|
int32 fromOffset)
|
||||||
|
|
||||||
|
BString &
|
||||||
|
BString_Replace(BString *String, char replaceThis,
|
||||||
|
char withThis,
|
||||||
|
int32 maxReplaceCount,
|
||||||
|
int32 fromOffset)
|
||||||
|
|
||||||
|
BString &
|
||||||
|
BString_ReplaceFirst_1
|
||||||
|
(BString *String, const char *replaceThis,
|
||||||
|
const char *withThis)
|
||||||
|
|
||||||
|
BString &
|
||||||
|
BString_ReplaceLast_1(BString *String, const char *replaceThis,
|
||||||
|
const char *withThis)
|
||||||
|
|
||||||
|
BString &
|
||||||
|
BString_ReplaceAll_1(BString *String, const char *replaceThis,
|
||||||
|
const char *withThis,
|
||||||
|
int32 fromOffset)
|
||||||
|
|
||||||
|
BString &
|
||||||
|
BString_Replace_1(BString *String, const char *replaceThis,
|
||||||
|
const char *withThis,
|
||||||
|
int32 maxReplaceCount,
|
||||||
|
int32 fromOffset)
|
||||||
|
|
||||||
|
BString &
|
||||||
|
BString_IReplaceFirst(BString *String, char replaceThis,
|
||||||
|
char withThis)
|
||||||
|
|
||||||
|
BString &
|
||||||
|
BString_IReplaceLast(BString *String, char replaceThis,
|
||||||
|
char withThis)
|
||||||
|
|
||||||
|
BString &
|
||||||
|
BString_IReplaceAll(BString *String, char replaceThis,
|
||||||
|
char withThis,
|
||||||
|
int32 fromOffset)
|
||||||
|
|
||||||
|
BString &
|
||||||
|
BString_IReplace(BString *String, char replaceThis,
|
||||||
|
char withThis,
|
||||||
|
int32 maxReplaceCount,
|
||||||
|
int32 fromOffset)
|
||||||
|
|
||||||
|
BString &
|
||||||
|
BString_IReplaceFirst_1
|
||||||
|
(BString *String, const char *replaceThis,
|
||||||
|
const char *withThis)
|
||||||
|
|
||||||
|
BString &
|
||||||
|
BString_IReplaceLast_1(BString *String, const char *replaceThis,
|
||||||
|
const char *withThis)
|
||||||
|
|
||||||
|
BString &
|
||||||
|
BString_IReplaceAll_1(BString *String, const char *replaceThis,
|
||||||
|
const char *withThis,
|
||||||
|
int32 fromOffset)
|
||||||
|
|
||||||
|
BString &
|
||||||
|
BString_IReplace_1(BString *String, const char *replaceThis,
|
||||||
|
const char *withThis,
|
||||||
|
int32 maxReplaceCount,
|
||||||
|
int32 fromOffset)
|
||||||
|
|
||||||
|
BString &
|
||||||
|
BString_ReplaceSet(BString *String, const char *setOfChars,
|
||||||
|
char with)
|
||||||
|
|
||||||
|
BString &
|
||||||
|
BString_ReplaceSet_1
|
||||||
|
(BString *String, const char *setOfChars,
|
||||||
|
const char *with)
|
||||||
|
|
||||||
|
char *
|
||||||
|
BString_LockBuffer(BString *String, int32 maxLength)
|
||||||
|
|
||||||
|
BString &
|
||||||
|
BString_UnlockBuffer(BString *String, int32 length)
|
||||||
|
|
||||||
|
BString &
|
||||||
|
BString_ToLower(BString *String)
|
||||||
|
|
||||||
|
BString &
|
||||||
|
BString_ToUpper(BString *String)
|
||||||
|
|
||||||
|
BString &
|
||||||
|
BString_Capitalize(BString *String)
|
||||||
|
|
||||||
|
BString &
|
||||||
|
BString_CapitalizeEachWord_1
|
||||||
|
(BString *String)
|
||||||
|
|
||||||
|
BString &
|
||||||
|
BString_CharacterEscape(BString *String, const char *original,
|
||||||
|
const char *setOfCharsToEscape,
|
||||||
|
char escapeWith)
|
||||||
|
|
||||||
|
BString &
|
||||||
|
BString_CharacterEscape_1
|
||||||
|
(BString *String, const char *setOfCharsToEscape,
|
||||||
|
char escapeWith)
|
||||||
|
|
||||||
|
BString &
|
||||||
|
BString_CharacterDeescape(BString *String, const char *original,
|
||||||
|
char escapeChar)
|
||||||
|
|
||||||
|
BString &
|
||||||
|
BString_CharacterDeescape_1
|
||||||
|
(BString *String, char escapeChar)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
|
||||||
|
constructor TString.Create;
|
||||||
|
begin
|
||||||
|
inherited;
|
||||||
|
CPlusObject := BString_Create(Self);
|
||||||
|
end;
|
||||||
|
|
||||||
|
{constructor TString.Create_1(value:PChar);
|
||||||
|
begin
|
||||||
|
inherited;
|
||||||
|
CPlusObject := BString_Create_1(Self,value);
|
||||||
|
end;
|
||||||
|
}
|
||||||
|
destructor TString.Destroy;
|
||||||
|
begin
|
||||||
|
if CPlusObject <> nil then
|
||||||
|
BString_Free(CPlusObject);
|
||||||
|
inherited;
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TString.CountChars : integer;
|
||||||
|
begin
|
||||||
|
result:=BString_CountChars(CPlusObject);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TString.length : integer;
|
||||||
|
begin
|
||||||
|
result:=BString_Length(CPlusObject);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TString.String_pchar : PChar;
|
||||||
|
begin
|
||||||
|
result:=BString_String(CPlusObject);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TString.SetTo(value:PChar; lenght : cardinal);
|
||||||
|
begin
|
||||||
|
BString_SetTo(CPlusObject,value,lenght);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure TString.SetTo( from: TString);
|
||||||
|
begin
|
||||||
|
BString_SetTo_1(CPlusObject, from);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TString.SetTo( value:TString;length1: cardinal);
|
||||||
|
begin
|
||||||
|
BString_SetTo_2(CPlusObject, value,length1);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TString.Adopt( from:TString);
|
||||||
|
begin
|
||||||
|
BString_Adopt(CPlusObject, from);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
end.
|
||||||
|
|
||||||
346
bepascal/bepascal/be/support/List.cpp
Normal file
346
bepascal/bepascal/be/support/List.cpp
Normal file
@@ -0,0 +1,346 @@
|
|||||||
|
/* BePascal - A pascal wrapper around the BeOS API
|
||||||
|
Copyright (C) 2002 Eric Jourde
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Library General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Library General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Library General Public
|
||||||
|
License along with this library; if not, write to the Free
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
#ifndef _LIST_CPP_
|
||||||
|
#define _LIST_CPP_
|
||||||
|
|
||||||
|
#include "List.h"
|
||||||
|
#include <beobj.h>
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Method: BList::BList()
|
||||||
|
* Descr:
|
||||||
|
*/
|
||||||
|
TCPlusObject BList_Create( int32 itemsPerBlock)
|
||||||
|
{
|
||||||
|
return new BList( itemsPerBlock);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Method: BList::BList()
|
||||||
|
* Descr:
|
||||||
|
*/
|
||||||
|
/*TCPlusObject BList_Create_1
|
||||||
|
(TPasObject PasObject, const BList &)
|
||||||
|
{
|
||||||
|
return new BPList(PasObject, );
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Method: BList::~BList()
|
||||||
|
* Descr:
|
||||||
|
*/
|
||||||
|
void BList_Free(BList *List)
|
||||||
|
{
|
||||||
|
delete List;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Method: BList::operator=()
|
||||||
|
* Descr:
|
||||||
|
*/
|
||||||
|
/*BList &
|
||||||
|
BList_operator=(BList *List, const BList &from)
|
||||||
|
{
|
||||||
|
return List->operator=(from);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Method: BList::AddItem()
|
||||||
|
* Descr:
|
||||||
|
*/
|
||||||
|
bool
|
||||||
|
BList_AddItem(BList *List, void *item)
|
||||||
|
{
|
||||||
|
return List->AddItem(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Method: BList::AddItem()
|
||||||
|
* Descr:
|
||||||
|
*/
|
||||||
|
bool
|
||||||
|
BList_AddItem_1
|
||||||
|
(BList *List, void *item,
|
||||||
|
int32 atIndex)
|
||||||
|
{
|
||||||
|
return List->AddItem(item,
|
||||||
|
atIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Method: BList::AddList()
|
||||||
|
* Descr:
|
||||||
|
*/
|
||||||
|
bool
|
||||||
|
BList_AddList(BList *List, BList *newItems)
|
||||||
|
{
|
||||||
|
return List->AddList(newItems);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Method: BList::AddList()
|
||||||
|
* Descr:
|
||||||
|
*/
|
||||||
|
bool
|
||||||
|
BList_AddList_1
|
||||||
|
(BList *List, BList *newItems,
|
||||||
|
int32 atIndex)
|
||||||
|
{
|
||||||
|
return List->AddList(newItems,
|
||||||
|
atIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Method: BList::RemoveItem()
|
||||||
|
* Descr:
|
||||||
|
*/
|
||||||
|
bool
|
||||||
|
BList_RemoveItem(BList *List, void *item)
|
||||||
|
{
|
||||||
|
return List->RemoveItem(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Method: BList::RemoveItem()
|
||||||
|
* Descr:
|
||||||
|
*/
|
||||||
|
void *
|
||||||
|
BList_RemoveItem_1
|
||||||
|
(BList *List, int32 index)
|
||||||
|
{
|
||||||
|
return List->RemoveItem(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Method: BList::RemoveItems()
|
||||||
|
* Descr:
|
||||||
|
*/
|
||||||
|
bool
|
||||||
|
BList_RemoveItems_2
|
||||||
|
(BList *List, int32 index,
|
||||||
|
int32 count)
|
||||||
|
{
|
||||||
|
return List->RemoveItems(index,
|
||||||
|
count);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Method: BList::ReplaceItem()
|
||||||
|
* Descr:
|
||||||
|
*/
|
||||||
|
bool
|
||||||
|
BList_ReplaceItem(BList *List, int32 index,
|
||||||
|
void *newItem)
|
||||||
|
{
|
||||||
|
return List->ReplaceItem(index,
|
||||||
|
newItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Method: BList::MakeEmpty()
|
||||||
|
* Descr:
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
BList_MakeEmpty(BList *List)
|
||||||
|
{
|
||||||
|
List->MakeEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Method: BList::SwapItems()
|
||||||
|
* Descr:
|
||||||
|
*/
|
||||||
|
bool
|
||||||
|
BList_SwapItems(BList *List, int32 indexA,
|
||||||
|
int32 indexB)
|
||||||
|
{
|
||||||
|
return List->SwapItems(indexA,
|
||||||
|
indexB);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Method: BList::MoveItem()
|
||||||
|
* Descr:
|
||||||
|
*/
|
||||||
|
bool
|
||||||
|
BList_MoveItem(BList *List, int32 fromIndex,
|
||||||
|
int32 toIndex)
|
||||||
|
{
|
||||||
|
return List->MoveItem(fromIndex,
|
||||||
|
toIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Method: BList::ItemAt()
|
||||||
|
* Descr:
|
||||||
|
*/
|
||||||
|
void *
|
||||||
|
BList_ItemAt(BList *List, int32 at)
|
||||||
|
{
|
||||||
|
return List->ItemAt(at);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Method: BList::ItemAtFast()
|
||||||
|
* Descr:
|
||||||
|
*/
|
||||||
|
void *
|
||||||
|
BList_ItemAtFast_1
|
||||||
|
(BList *List, int32 at)
|
||||||
|
{
|
||||||
|
return List->ItemAtFast(at);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Method: BList::FirstItem()
|
||||||
|
* Descr:
|
||||||
|
*/
|
||||||
|
void *
|
||||||
|
BList_FirstItem(BList *List)
|
||||||
|
{
|
||||||
|
return List->FirstItem();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Method: BList::LastItem()
|
||||||
|
* Descr:
|
||||||
|
*/
|
||||||
|
void *
|
||||||
|
BList_LastItem(BList *List)
|
||||||
|
{
|
||||||
|
return List->LastItem();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Method: BList::Items()
|
||||||
|
* Descr:
|
||||||
|
*/
|
||||||
|
void *
|
||||||
|
BList_Items(BList *List)
|
||||||
|
{
|
||||||
|
return List->Items();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Method: BList::HasItem()
|
||||||
|
* Descr:
|
||||||
|
*/
|
||||||
|
bool
|
||||||
|
BList_HasItem(BList *List, void *item)
|
||||||
|
{
|
||||||
|
return List->HasItem(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Method: BList::IndexOf()
|
||||||
|
* Descr:
|
||||||
|
*/
|
||||||
|
int32
|
||||||
|
BList_IndexOf(BList *List, void *item)
|
||||||
|
{
|
||||||
|
return List->IndexOf(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Method: BList::CountItems()
|
||||||
|
* Descr:
|
||||||
|
*/
|
||||||
|
int32
|
||||||
|
BList_CountItems(BList *List)
|
||||||
|
{
|
||||||
|
return List->CountItems();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Method: BList::IsEmpty()
|
||||||
|
* Descr:
|
||||||
|
*/
|
||||||
|
bool
|
||||||
|
BList_IsEmpty(BList *List)
|
||||||
|
{
|
||||||
|
return List->IsEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Method: BList::_ReservedList1()
|
||||||
|
* Descr:
|
||||||
|
*/
|
||||||
|
/*void
|
||||||
|
BList__ReservedList1(BList *List)
|
||||||
|
{
|
||||||
|
List->_ReservedList1();
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Method: BList::_ReservedList2()
|
||||||
|
* Descr:
|
||||||
|
*/
|
||||||
|
/*void
|
||||||
|
BList__ReservedList2(BList *List)
|
||||||
|
{
|
||||||
|
List->_ReservedList2();
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Method: BList::Resize()
|
||||||
|
* Descr:
|
||||||
|
*/
|
||||||
|
/*void
|
||||||
|
BList_Resize(BList *List, int32 count)
|
||||||
|
{
|
||||||
|
List->Resize(count);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _LIST_CPP_ */
|
||||||
|
|
||||||
|
|
||||||
1746
bepascal/bepascal/be/support/String.cpp
Normal file
1746
bepascal/bepascal/be/support/String.cpp
Normal file
File diff suppressed because it is too large
Load Diff
187
bepascal/bepascal/be/support/list.pp
Normal file
187
bepascal/bepascal/be/support/list.pp
Normal file
@@ -0,0 +1,187 @@
|
|||||||
|
{ BePascal - A pascal wrapper around the BeOS API
|
||||||
|
Copyright (C) 2002 Eric Jourde
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Library General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Library General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Library General Public
|
||||||
|
License along with this library; if not, write to the Free
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
}
|
||||||
|
|
||||||
|
unit List;
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
uses
|
||||||
|
beobj, SupportDefs, os;
|
||||||
|
|
||||||
|
type
|
||||||
|
TList = class(TBeObject)
|
||||||
|
private
|
||||||
|
public
|
||||||
|
constructor Create; override;
|
||||||
|
destructor Destroy; override;
|
||||||
|
|
||||||
|
function AddItem(item : pointer): boolean;
|
||||||
|
function AddItem(item : pointer; atindex : cardinal): boolean;
|
||||||
|
function AddList(newitem : TCPlusObject): boolean;
|
||||||
|
function ItemAt(at : cardinal): pointer;
|
||||||
|
function ItemAtFast(at : cardinal): pointer;
|
||||||
|
function RemoveItem(item : pointer) : boolean;
|
||||||
|
function RemoveItem(index : cardinal) : boolean;
|
||||||
|
function RemoveItems(index,count : cardinal) : boolean;
|
||||||
|
procedure MakeEmpty;
|
||||||
|
function FirstItem : pointer;
|
||||||
|
function LastItem : pointer;
|
||||||
|
function HasItem (item : pointer) : boolean;
|
||||||
|
function IndexOf(item : pointer) : cardinal;
|
||||||
|
function CountItems : cardinal;
|
||||||
|
function IsEmpty : boolean;
|
||||||
|
function ReplaceItem(index : cardinal; newItem : pointer): boolean;
|
||||||
|
function SwapItems(IndexA,IndexB : cardinal) : boolean;
|
||||||
|
function MoveItem(FromIndex,ToIndex : cardinal) : boolean;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
function BList_Create( itemsPerBlock: cardinal) : TCPlusObject; cdecl; external BePascalLibName name 'BList_Create';
|
||||||
|
procedure BList_Free(AObject : TCPlusObject); cdecl; external BePascalLibName name 'BList_Free';
|
||||||
|
|
||||||
|
function BList_AddItem(AObject : TCPlusObject; item : pointer):boolean;cdecl; external BePascalLibName name 'BList_AddItem';
|
||||||
|
function BList_AddItem(AObject : TCPlusObject; item : pointer; atIndex : cardinal):boolean;cdecl; external BePascalLibName name 'BList_AddItem_1';
|
||||||
|
function BList_AddList(AObject : TCPlusObject; newitem : TCPlusObject): boolean;cdecl; external BePascalLibName name 'BList_AddList';
|
||||||
|
function BList_ItemAt(AObject : TCPlusObject; at : cardinal) : pointer;cdecl; external BePascalLibName name 'BList_ItemAt';
|
||||||
|
function BList_ItemAtFast(AObject : TCPlusObject; at : cardinal) : pointer;cdecl; external BePascalLibName name 'BList_ItemAtFast_1';
|
||||||
|
function BList_RemoveItem(AObject : TCPlusObject; item : pointer): boolean;cdecl; external BePascalLibName name 'BList_RemoveItem';
|
||||||
|
function BList_RemoveItem(AObject : TCPlusObject; index : cardinal): boolean;cdecl; external BePascalLibName name 'BList_RemoveItem_1';
|
||||||
|
function BList_RemoveItems(AObject : TCPlusObject; index,count : cardinal): boolean;cdecl; external BePascalLibName name 'BList_RemoveItems_2';
|
||||||
|
procedure BList_MakeEmpty(AObject : TCPlusObject);cdecl; external BePascalLibName name 'BList_MakeEmpty';
|
||||||
|
function BList_FirstItem(AObject : TCPlusObject): pointer; cdecl; external BePascalLibName name 'BList_FirstItem';
|
||||||
|
function BList_LastItem(AObject : TCPlusObject): pointer; cdecl; external BePascalLibName name 'BList_LastItem';
|
||||||
|
function BList_HasItem(AObject : TCPlusObject; item : pointer) : boolean; cdecl; external BePascalLibName name 'BList_HasItem';
|
||||||
|
function BList_IndexOf(AObject : TCPlusObject; item : pointer) : cardinal;cdecl; external BePascalLibName name 'BList_IndexOf';
|
||||||
|
function BList_CountItems(AObject : TCPlusObject) : cardinal;cdecl; external BePascalLibName name 'BList_CountItems';
|
||||||
|
function BList_IsEmpty(AObject : TCPlusObject) : boolean;cdecl; external BePascalLibName name 'BList_IsEmpty';
|
||||||
|
|
||||||
|
function BList_ReplaceItem(AObject : TCPlusObject; index : cardinal; newItem: pointer): boolean;cdecl; external BePascalLibName name 'BList_ReplaceItem';
|
||||||
|
function BList_SwapItems(AObject : TCPlusObject; indexA : cardinal; indexB : cardinal) : boolean;cdecl; external BePascalLibName name 'BList_SwapItems';
|
||||||
|
function BList_MoveItem(AObject : TCPlusObject; fromindex : cardinal; Toindex : cardinal) : boolean;cdecl; external BePascalLibName name 'BList_MoveItem';
|
||||||
|
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
constructor TList.Create;
|
||||||
|
begin
|
||||||
|
inherited;
|
||||||
|
CPlusObject:=BList_Create( 10); // we can't made a parametre under a constructor -> error : init with 10 items per blocks
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
destructor TList.Destroy;
|
||||||
|
begin
|
||||||
|
if CPlusObject <> nil then
|
||||||
|
BList_Free(CPlusObject);
|
||||||
|
inherited;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TList.AddItem(item : pointer): boolean;
|
||||||
|
begin
|
||||||
|
result := BList_AddItem(CPlusObject, item );
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TList.AddItem(item : pointer; atindex : cardinal): boolean;
|
||||||
|
begin
|
||||||
|
result := BList_AddItem(CPlusObject, item , atindex);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TList.AddList(newitem : TCPlusObject): boolean;
|
||||||
|
begin
|
||||||
|
result:=BList_AddList(CPlusObject, newitem );
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
function TList.ItemAt(at : cardinal): pointer;
|
||||||
|
begin
|
||||||
|
result:=BList_ItemAt(CPlusObject, at );
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TList.ItemAtFast(at : cardinal): pointer;
|
||||||
|
begin
|
||||||
|
result:=BList_ItemAtFast(CPlusObject, at );
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TList.RemoveItem(item : pointer) : boolean;
|
||||||
|
begin
|
||||||
|
result:=BList_RemoveItem(CPlusObject, item);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TList.RemoveItem(index : cardinal) : boolean;
|
||||||
|
begin
|
||||||
|
result:=BList_RemoveItem(CPlusObject, index);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TList.RemoveItems(index,count : cardinal) : boolean;
|
||||||
|
begin
|
||||||
|
result:=BList_RemoveItems(CPlusObject, index,count);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TList.MakeEmpty;
|
||||||
|
begin
|
||||||
|
BList_MakeEmpty(CPlusObject);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TList.FirstItem : pointer;
|
||||||
|
begin
|
||||||
|
result:=BList_FirstItem(CPlusObject);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TList.LastItem : pointer;
|
||||||
|
begin
|
||||||
|
result:=BList_LastItem(CPlusObject);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TList.HasItem(item : pointer) : boolean;
|
||||||
|
begin
|
||||||
|
result:=BList_HasItem(CPlusObject,item);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TList.IndexOf(item : pointer) : cardinal;
|
||||||
|
begin
|
||||||
|
result:=BList_IndexOf(CPlusObject,item);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TList.CountItems : cardinal;
|
||||||
|
begin
|
||||||
|
result:=BList_CountItems(CPlusObject);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TList.IsEmpty : boolean;
|
||||||
|
begin
|
||||||
|
result:=BList_IsEmpty(CPlusObject);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TList.ReplaceItem(index : cardinal; newItem : pointer): boolean;
|
||||||
|
begin
|
||||||
|
result:=BList_ReplaceItem(CPlusObject, index , newItem);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TList.SwapItems(IndexA,IndexB : cardinal) : boolean;
|
||||||
|
begin
|
||||||
|
result:=BList_SwapItems(CPlusObject,indexA,indexB);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TList.MoveItem(FromIndex,ToIndex : cardinal) : boolean;
|
||||||
|
begin
|
||||||
|
result:=BList_MoveItem(CPlusObject,Fromindex,Toindex);
|
||||||
|
end;
|
||||||
|
|
||||||
|
end.
|
||||||
Binary file not shown.
Reference in New Issue
Block a user