[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/livecodeali/livecode/develop/libscript/src/binary.lcb [Back]  [Original]

/* Copyright (C) 2003-2015 LiveCode Ltd.
 
 This file is part of LiveCode.
 
 LiveCode is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License v3 as published by the Free
 Software Foundation.
 
 LiveCode 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 General Public License
 for more details.
 
 You should have received a copy of the GNU General Public License
 along with LiveCode.  If not see .  */

/**
This library consists of the operations on binary strings provided by the standard library of LiveCode Builder.
*/

module com.livecode.binary

use com.livecode.foreign

public foreign handler MCBinaryExecPutBytesBefore(in Source as Data, inout Target as Data) returns nothing binds to ""
public foreign handler MCBinaryExecPutBytesAfter(in Source as Data, inout Target as Data) returns nothing binds to ""

public foreign handler MCBinaryEvalConcatenateBytes(in Left as Data, in Right as Data, out Result as Data) returns nothing binds to ""

/* No implementation
public foreign handler MCBinaryEvalContainsBytes(in Target as Data, in Needle as Data, out Value as CBool) returns nothing binds to ""
*/

public foreign handler MCBinaryEvalIsEqualTo(in Left as Data, in Right as Data, out Value as CBool) returns nothing binds to ""
public foreign handler MCBinaryEvalIsNotEqualTo(in Left as Data, in Right as Data, out Value as CBool) returns nothing binds to ""
public foreign handler MCBinaryEvalIsLessThan(in Left as Data, in Right as Data, out Value as CBool) returns nothing binds to ""
public foreign handler MCBinaryEvalIsGreaterThan(in Left as Data, in Right as Data, out Value as CBool) returns nothing binds to ""

public foreign handler MCDataEvalEmpty(out Value as Data) returns nothing binds to ""
--

/**
Summary:            Prepends  bytes to  bytes.

Source: 			An expression which evaluates to binary data.
Target: 			An expression which evaluates to a binary container.
	
Description:
Use to insert bytes into data without replacement. Can be used either with a chunk expression to insert at a specified location, or without to prepend to the target data.

Tags: Binary
*/

syntax PutBytesBefore is statement
    "put"  "before" 
begin
    MCBinaryExecPutBytesBefore(Source, Target)
end syntax

/**
Summary:            Appends  bytes to  bytes.

Source: 			An expression which evaluates to binary data.
Target: 			An expression which evaluates to a binary container.

Related: 			PutBytesAfter

Description:
Use to insert bytes into data without replacement. Can be used either with a chunk expression to insert at a specified location, or without to append to the target data.

Tags: Binary
*/

syntax PutBytesAfter is statement
    "put"  "after" 
begin
    MCBinaryExecPutBytesAfter(Source, Target)
end syntax

--

/**
Summary:            Concatenates  and .

Left: 				An expression which evaluates to binary data.
Right: 				An expression which evaluates to binary data.

Returns:			Binary data consisting of the value of the left hand expression with the value of the right hand expression appended to the end.

Description:
The result consists of the bytes of  followed by those of .

Tags: Binary
*/

syntax ConcatenateBytes is left binary operator with concatenation precedence
     "&" 
begin
    MCBinaryEvalConcatenateBytes(Left, Right, output)
end syntax

--

/**
Summary:    Determines whether  and  are equal or not.

Left:       An expression which evaluates to binary data.
Right:      An expression which evaluates to binary data.

Returns: 	Returns true if the result of evaluating  is the same as that of , and false otherwise.

Description:
Performs a byte by byte comparison of  and , returning false if there is any difference.

Tags: Binary
*/

syntax DataIsData is neutral binary operator with comparison precedence
     "is" 
begin
    MCBinaryEvalIsEqualTo(Left, Right, output)
end syntax

/**
Summary:    Determines whether  and  are equal or not.

Left:       An expression which evaluates to binary data.
Right:      An expression which evaluates to binary data.

Returns: 	Returns false if the result of evaluating  is the same as that of , and true otherwise.

Description:
Performs a byte by byte comparison of  and , returning true if there is any difference.

Tags: Binary
*/

syntax DataIsNotData is neutral binary operator with comparison precedence
     "is not" 
begin
    MCBinaryEvalIsNotEqualTo(Left, Right, output)
end syntax

/**
Summary:    Determines whether  is less than  under a byte by byte comparison

Left:       An expression which evaluates to binary data.
Right:      An expression which evaluates to binary data.


Returns: 	True if  is less than , and false otherwise.

Description:
 is less than  if they are not equal, and the first byte in  that is not equal to the corresponding byte in  is of greater value.
            
Tags: Binary
*/

syntax DataIsLessThanData is neutral binary operator with comparison precedence
     "" 
begin
    MCBinaryEvalIsGreaterThan(Left, Right, output)
end syntax

--

/**

Summary: 		Designates data of length 0.

Example:
	variable tVar as Data
	variable tCount as Number
	put the empty data into tVar
	put the number of bytes in tVar into tCount -- tCount is 0
	
Description:
Use ```the empty data``` to initialise a data variable.

Tags: Binary

*/

syntax EmptyData is expression
	"the" "empty" "data"
begin
	MCDataEvalEmpty(output)
end syntax

end module

Web Proxy Viewer  |  New URL  |  Original Page