PreviousUpNext

15.3.465  src/lib/std/src/byte.api

## byte.api

# Compiled by:
#     src/lib/std/src/standard-core.sublib



###                   "Aristotle maintained that women have fewer teeth than men;
###                    although he was twice married, it never occurred to him
###                    to verify this statement by examining his wives' mouths."
###
###                                                -- Bertrand Russell 


stipulate
    package w8  =  one_byte_unt;                        # one_byte_unt                          is from   src/lib/std/types-only/basis-structs.pkg
    package s1u =     vector_slice_of_one_byte_unts;    #    vector_slice_of_one_byte_unts      is from   src/lib/std/src/vector-slice-of-one-byte-unts.pkg
    package t1u =  rw_vector_slice_of_one_byte_unts;    # rw_vector_slice_of_one_byte_unts      is from   src/lib/std/src/rw-vector-slice-of-one-byte-unts.pkg
    package v1u =     vector_of_one_byte_unts;          #    vector_of_one_byte_unts            is from   src/lib/std/src/vector-of-one-byte-unts.pkg
    package w1u =  rw_vector_of_one_byte_unts;          # rw_vector_of_one_byte_unts            is from   src/lib/std/src/rw-vector-of-one-byte-unts.pkg
herein

    # This api is implemented by:
    #
    #     src/lib/std/src/byte.pkg

    api Byte {
        #
        byte_to_char:  one_byte_unt::Unt -> Char;
        char_to_byte:  Char -> one_byte_unt::Unt;

        bytes_to_string:  vector_of_one_byte_unts::Vector -> String;
        string_to_bytes:  String -> vector_of_one_byte_unts::Vector;

        unpack_string_vector:   s1u::Slice -> String;
        unpack_string:       t1u::Slice -> String;
        pack_string:       (w1u::Rw_Vector, Int, substring::Substring) -> Void;

        reverse_byte_bits:  w8::Unt -> w8::Unt;

        string_to_hex:      String -> String;           # Convert "abc" -> "61.62.63." etc.
        bytes_to_hex:  v1u::Vector -> String;           # As above, starting with byte-vector.

        string_to_ascii:    String -> String;           # Show printing chars verbatim, everything else as '.', per hexdump tradition.
        bytes_to_ascii:  v1u::Vector -> String;         # As above, starting with byte-vector.
    };
end;

## COPYRIGHT (c) 1995 AT&T Bell Laboratories.
## Subsequent changes by Jeff Prothero Copyright (c) 2010-2015,
## released per terms of SMLNJ-COPYRIGHT.


Comments and suggestions to: bugs@mythryl.org

PreviousUpNext