filepath-1.4.100.0: Library for manipulating FilePaths in a cross platform way.
Copyright© 2022 Julian Ospald
LicenseMIT
MaintainerJulian Ospald <hasufell@posteo.de>
Stabilityexperimental
Portabilityportable
Safe HaskellSafe-Inferred
LanguageHaskell2010

System.OsPath.Data.ByteString.Short.Internal

Description

Internal low-level utilities mostly for Word16, such as byte-array operations and other stuff not meant to be exported from Word16 module.

Synopsis

Documentation

word16ToChar :: Word16 -> Char Source #

Total conversion to char.

create :: Int -> (forall s. MBA s -> ST s ()) -> ShortByteString Source #

data BA Source #

Constructors

BA# ByteArray# 

data MBA s Source #

Constructors

MBA# (MutableByteArray# s) 

copyByteArray :: BA -> Int -> MBA s -> Int -> Int -> ST s () Source #

packCWString :: Ptr Word16 -> IO ShortByteString Source #

O(n). Construct a new ShortByteString from a CWString. The resulting ShortByteString is an immutable copy of the original CWString, and is managed on the Haskell heap. The original CWString must be null terminated.

Since: filepath-0.10.10.0

packCWStringLen :: (Ptr Word16, Int) -> IO ShortByteString Source #

O(n). Construct a new ShortByteString from a CWStringLen. The resulting ShortByteString is an immutable copy of the original CWStringLen. The ShortByteString is a normal Haskell value and will be managed on the Haskell heap.

Since: filepath-0.10.10.0

useAsCWString :: ShortByteString -> (Ptr Word16 -> IO a) -> IO a Source #

O(n) construction. Use a ShortByteString with a function requiring a null-terminated CWString. The CWString is a copy and will be freed automatically; it must not be stored or used after the subcomputation finishes.

Since: filepath-0.10.10.0

useAsCWStringLen :: ShortByteString -> ((Ptr Word16, Int) -> IO a) -> IO a Source #

O(n) construction. Use a ShortByteString with a function requiring a CWStringLen. As for useAsCWString this function makes a copy of the original ShortByteString. It must not be stored or used after the subcomputation finishes.

Since: filepath-0.10.10.0

newCWString :: ShortByteString -> IO (Ptr Word16) Source #

O(n) construction. Use a ShortByteString with a function requiring a CWStringLen. As for useAsCWString this function makes a copy of the original ShortByteString. It must not be stored or used after the subcomputation finishes.

Since: filepath-0.10.10.0

writeWord16Array Source #

Arguments

:: MBA s 
-> Int

Word8 index (not Word16)

-> Word16 
-> ST s () 

This isn't strictly Word16 array write. Instead it's two consecutive Word8 array writes to avoid endianness issues due to primops doing automatic alignment based on host platform. We want to always write LE to the byte array.

indexWord16Array Source #

Arguments

:: BA 
-> Int

Word8 index (not Word16)

-> Word16 

This isn't strictly Word16 array read. Instead it's two Word8 array reads to avoid endianness issues due to primops doing automatic alignment based on host platform. We expect the byte array to be LE always.

encodeWord16LE# Source #

Arguments

:: Word16#

Word16

-> (# Word8#, Word8# #)

Word8 (LSB, MSB)

decodeWord16LE# Source #

Arguments

:: (# Word8#, Word8# #)

Word8 (LSB, MSB)

-> Word16#

Word16

setByteArray :: MBA s -> Int -> Int -> Int -> ST s () Source #

copyMutableByteArray :: MBA s -> Int -> MBA s -> Int -> Int -> ST s () Source #

createAndTrim :: Int -> (forall s. MBA s -> ST s (Int, a)) -> (ShortByteString, a) Source #

Given the maximum size needed and a function to make the contents of a ShortByteString, createAndTrim makes the ShortByteString. The generating function is required to return the actual final size (<= the maximum size) and the result value. The resulting byte array is realloced to this size.

createAndTrim' :: Int -> (forall s. MBA s -> ST s Int) -> ShortByteString Source #

createAndTrim'' :: Int -> (forall s. MBA s -> MBA s -> ST s (Int, Int)) -> (ShortByteString, ShortByteString) Source #

findFromEndUntil :: (Word16 -> Bool) -> ShortByteString -> Int Source #

Returns the length of the substring matching, not the index. If no match, returns 0.