ghc-8.0.2: The GHC API

Safe Haskell | None
Language | Haskell2010

StringBuffer

Contents

- Creation/destruction
- Inspection
- Moving and comparison
- Conversion
- Parsing integers

Synopsis

- data StringBuffer = StringBuffer {
  - buf :: !(ForeignPtr Word8)
  - len :: !Int
  - cur :: !Int
  }
- hGetStringBuffer :: FilePath -> IO StringBuffer
- hGetStringBufferBlock :: Handle -> Int -> IO StringBuffer
- appendStringBuffers :: StringBuffer -> StringBuffer -> IO StringBuffer
- stringToStringBuffer :: String -> StringBuffer
- nextChar :: StringBuffer -> (Char, StringBuffer)
- currentChar :: StringBuffer -> Char
- prevChar :: StringBuffer -> Char -> Char
- atEnd :: StringBuffer -> Bool
- stepOn :: StringBuffer -> StringBuffer
- offsetBytes :: Int -> StringBuffer -> StringBuffer
- byteDiff :: StringBuffer -> StringBuffer -> Int
- lexemeToString :: StringBuffer -> Int -> String
- lexemeToFastString :: StringBuffer -> Int -> FastString
- parseUnsignedInteger :: StringBuffer -> Int -> Integer -> (Char -> Int) -> Integer

# Documentation

data StringBuffer Source #

A StringBuffer is an internal pointer to a sized chunk of bytes. The bytes are intended to be *immutable*. There are pure operations to read the contents of a StringBuffer.

A StringBuffer may have a finalizer, depending on how it was obtained.

Constructors

StringBuffer |
Fields buf :: !(ForeignPtr Word8) len :: !Int cur :: !Int

Instances

Show StringBuffer # |
Methods showsPrec :: Int -> StringBuffer -> ShowS Source # show :: StringBuffer -> String Source # showList :: [StringBuffer] -> ShowS Source #

# Creation/destruction

hGetStringBuffer :: FilePath -> IO StringBuffer Source #

hGetStringBufferBlock :: Handle -> Int -> IO StringBuffer Source #

appendStringBuffers :: StringBuffer -> StringBuffer -> IO StringBuffer Source #

stringToStringBuffer :: String -> StringBuffer Source #

# Inspection

nextChar :: StringBuffer -> (Char, StringBuffer) Source #

currentChar :: StringBuffer -> Char Source #

prevChar :: StringBuffer -> Char -> Char Source #

atEnd :: StringBuffer -> Bool Source #

# Moving and comparison

stepOn :: StringBuffer -> StringBuffer Source #

offsetBytes :: Int -> StringBuffer -> StringBuffer Source #

byteDiff :: StringBuffer -> StringBuffer -> Int Source #

# Conversion

lexemeToString :: StringBuffer -> Int -> String Source #

lexemeToFastString :: StringBuffer -> Int -> FastString Source #

# Parsing integers

parseUnsignedInteger :: StringBuffer -> Int -> Integer -> (Char -> Int) -> Integer Source #