Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uw-maps sync with master #28

Merged
merged 17 commits into from
Apr 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,24 @@
deps/
.rebar3
_*
.eunit
*.o
*.beam
*.plt
*.swp
*.swo
.erlang.cookie
log
erl_crash.dump
.rebar
logs
_build
Barrel.nonode@nohost
*.iml
.idea
deps
.eunit/
ebin/
ebin
*~
*/*~
erl_crash.dump
current_counterexample.eqc
current_counterexample.eqc
4 changes: 3 additions & 1 deletion NOTICE
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
Original author: Ulf Wiger <ulf.wiger@erlang-solutions.com> 2009
Original author: Ulf Wiger, Erlang Solutions, 2009

Copyright transfered to Ulf Wiger 2014
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


# The sext application #

__Authors:__ Ulf Wiger ([`ulf@wiger.net`](mailto:ulf@wiger.net)).
Expand All @@ -10,7 +8,7 @@ preserves the Erlang term order.

```

Copyright 2010 Erlang Solutions Ltd.
Copyright 2014 Ulf Wiger

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
68 changes: 21 additions & 47 deletions doc/sext.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@


Sortable serialization library.
__Authors:__ Ulf Wiger ([`ulf.wiger@erlang-solutions.com`](mailto:ulf.wiger@erlang-solutions.com)).
__Authors:__ Ulf Wiger ([`ulf@wiger.net`](mailto:ulf@wiger.net)).
<a name="index"></a>

## Function Index ##


<table width="100%" border="1" cellspacing="0" cellpadding="2" summary="function index"><tr><td valign="top"><a href="#decode-1">decode/1</a></td><td>Decodes a binary generated using the function <a href="sext.md#encode-1"><code>sext:encode/1</code></a>.</td></tr><tr><td valign="top"><a href="#decode_hex-1">decode_hex/1</a></td><td></td></tr><tr><td valign="top"><a href="#decode_next-1">decode_next/1</a></td><td>Decode a binary stream, returning the next decoded term and the stream remainder.</td></tr><tr><td valign="top"><a href="#decode_sb32-1">decode_sb32/1</a></td><td>Decodes a binary generated using the function <a href="#encode_sb32-1"><code>encode_sb32/1</code></a>.</td></tr><tr><td valign="top"><a href="#encode-1">encode/1</a></td><td>Encodes any Erlang term into a binary.</td></tr><tr><td valign="top"><a href="#encode-2">encode/2</a></td><td>Encodes an Erlang term using legacy bignum encoding.</td></tr><tr><td valign="top"><a href="#encode_hex-1">encode_hex/1</a></td><td>Encodes any Erlang term into a hex-encoded binary.</td></tr><tr><td valign="top"><a href="#encode_sb32-1">encode_sb32/1</a></td><td>Encodes any Erlang term into an sb32-encoded binary.</td></tr><tr><td valign="top"><a href="#from_hex-1">from_hex/1</a></td><td>Converts from a hex-encoded binary into a 'normal' binary.</td></tr><tr><td valign="top"><a href="#from_sb32-1">from_sb32/1</a></td><td>Converts from an sb32-encoded bitstring into a 'normal' bitstring.</td></tr><tr><td valign="top"><a href="#partial_decode-1">partial_decode/1</a></td><td>Decode a sext-encoded term or prefix embedded in a byte stream.</td></tr><tr><td valign="top"><a href="#prefix-1">prefix/1</a></td><td>Encodes a binary for prefix matching of similar encoded terms.</td></tr><tr><td valign="top"><a href="#prefix_hex-1">prefix_hex/1</a></td><td>Generates a hex-encoded binary for prefix matching.</td></tr><tr><td valign="top"><a href="#prefix_sb32-1">prefix_sb32/1</a></td><td>Generates an sb32-encoded binary for prefix matching.</td></tr><tr><td valign="top"><a href="#to_hex-1">to_hex/1</a></td><td>Converts a binary into a hex-encoded binary
<table width="100%" border="1" cellspacing="0" cellpadding="2" summary="function index"><tr><td valign="top"><a href="#decode-1">decode/1</a></td><td>Decodes a binary generated using the function <a href="sext.md#encode-1"><code>sext:encode/1</code></a>.</td></tr><tr><td valign="top"><a href="#decode_hex-1">decode_hex/1</a></td><td></td></tr><tr><td valign="top"><a href="#decode_next-1">decode_next/1</a></td><td>Decode a binary stream, returning the next decoded term and the
stream remainder.</td></tr><tr><td valign="top"><a href="#decode_sb32-1">decode_sb32/1</a></td><td>Decodes a binary generated using the function <a href="#encode_sb32-1"><code>encode_sb32/1</code></a>.</td></tr><tr><td valign="top"><a href="#encode-1">encode/1</a></td><td>Encodes any Erlang term into a binary.</td></tr><tr><td valign="top"><a href="#encode-2">encode/2</a></td><td>Encodes an Erlang term using legacy bignum encoding.</td></tr><tr><td valign="top"><a href="#encode_hex-1">encode_hex/1</a></td><td>Encodes any Erlang term into a hex-encoded binary.</td></tr><tr><td valign="top"><a href="#encode_sb32-1">encode_sb32/1</a></td><td>Encodes any Erlang term into an sb32-encoded binary.</td></tr><tr><td valign="top"><a href="#from_hex-1">from_hex/1</a></td><td>Converts from a hex-encoded binary into a 'normal' binary.</td></tr><tr><td valign="top"><a href="#from_sb32-1">from_sb32/1</a></td><td>Converts from an sb32-encoded bitstring into a 'normal' bitstring.</td></tr><tr><td valign="top"><a href="#partial_decode-1">partial_decode/1</a></td><td>Decode a sext-encoded term or prefix embedded in a byte stream.</td></tr><tr><td valign="top"><a href="#prefix-1">prefix/1</a></td><td>Encodes a binary for prefix matching of similar encoded terms.</td></tr><tr><td valign="top"><a href="#prefix_hex-1">prefix_hex/1</a></td><td>Generates a hex-encoded binary for prefix matching.</td></tr><tr><td valign="top"><a href="#prefix_sb32-1">prefix_sb32/1</a></td><td>Generates an sb32-encoded binary for prefix matching.</td></tr><tr><td valign="top"><a href="#to_hex-1">to_hex/1</a></td><td>Converts a binary into a hex-encoded binary
This is conventional hex encoding, with the proviso that
only capital letters are used, e.g.</td></tr><tr><td valign="top"><a href="#to_sb32-1">to_sb32/1</a></td><td>Converts a bitstring into an sb-encoded bitstring.</td></tr></table>

Expand All @@ -30,9 +31,7 @@ only capital letters are used, e.g.</td></tr><tr><td valign="top"><a href="#to_s
<pre><code>
decode(B::binary()) -&gt; term()
</code></pre>

<br></br>

<br />

Decodes a binary generated using the function [`sext:encode/1`](sext.md#encode-1).
<a name="decode_hex-1"></a>
Expand All @@ -50,16 +49,15 @@ Decodes a binary generated using the function [`sext:encode/1`](sext.md#encode-1
<pre><code>
decode_next(X1::Bin) -&gt; {N, Rest}
</code></pre>

<br></br>

<br />


Decode a binary stream, returning the next decoded term and the stream remainder
Decode a binary stream, returning the next decoded term and the
stream remainder


This function will raise an exception if the beginning of `Bin` is not a valid
sext-encoded term.
This function will raise an exception if the beginning of `Bin` is not
a valid sext-encoded term.
<a name="decode_sb32-1"></a>

### decode_sb32/1 ###
Expand All @@ -75,9 +73,7 @@ Decodes a binary generated using the function [`encode_sb32/1`](#encode_sb32-1).
<pre><code>
encode(T::term()) -&gt; binary()
</code></pre>

<br></br>

<br />

Encodes any Erlang term into a binary.
The lexical sorting properties of the encoded binary match those of the
Expand All @@ -91,9 +87,7 @@ original terms would.
<pre><code>
encode(T::term(), Legacy::boolean()) -&gt; binary()
</code></pre>

<br></br>

<br />


Encodes an Erlang term using legacy bignum encoding.
Expand All @@ -117,9 +111,7 @@ Use only as transition support. This function will be deprecated in time.
<pre><code>
encode_hex(Term::any()) -&gt; binary()
</code></pre>

<br></br>

<br />


Encodes any Erlang term into a hex-encoded binary.
Expand All @@ -139,9 +131,7 @@ the sorting property).
<pre><code>
encode_sb32(Term::any()) -&gt; binary()
</code></pre>

<br></br>

<br />


Encodes any Erlang term into an sb32-encoded binary.
Expand All @@ -160,9 +150,7 @@ RFC3548, but uses a different alphabet in order to preserve the sort order.
<pre><code>
from_hex(Bin::binary()) -&gt; binary()
</code></pre>

<br></br>

<br />


Converts from a hex-encoded binary into a 'normal' binary
Expand All @@ -178,9 +166,7 @@ This function is the reverse of [`to_hex/1`](#to_hex-1).
<pre><code>
from_sb32(Bits::bitstring()) -&gt; bitstring()
</code></pre>

<br></br>

<br />


Converts from an sb32-encoded bitstring into a 'normal' bitstring
Expand All @@ -195,9 +181,7 @@ This function is the reverse of [`to_sb32/1`](#to_sb32-1).
<pre><code>
partial_decode(Other::Bytes) -&gt; {full | partial, DecodedTerm, Rest}
</code></pre>

<br></br>

<br />


Decode a sext-encoded term or prefix embedded in a byte stream.
Expand Down Expand Up @@ -237,9 +221,7 @@ after the first wildcard are replaced with wildcards.
<pre><code>
prefix(X::term()) -&gt; binary()
</code></pre>

<br></br>

<br />

Encodes a binary for prefix matching of similar encoded terms.
Lists and tuples can be prefixed by using the `'_'` marker,
Expand Down Expand Up @@ -282,9 +264,7 @@ a list where the first element is 1.
<pre><code>
prefix_hex(X::term()) -&gt; binary()
</code></pre>

<br></br>

<br />

Generates a hex-encoded binary for prefix matching.
This is similar to [`prefix/1`](#prefix-1), but generates a prefix for binaries
Expand All @@ -297,9 +277,7 @@ encoded with [`encode_hex/1`](#encode_hex-1), rather than [`encode/1`](#encode-1
<pre><code>
prefix_sb32(X::term()) -&gt; binary()
</code></pre>

<br></br>

<br />

Generates an sb32-encoded binary for prefix matching.
This is similar to [`prefix/1`](#prefix-1), but generates a prefix for binaries
Expand All @@ -312,9 +290,7 @@ encoded with [`encode_sb32/1`](#encode_sb32-1), rather than [`encode/1`](#encode
<pre><code>
to_hex(Bin::binary()) -&gt; binary()
</code></pre>

<br></br>

<br />

Converts a binary into a hex-encoded binary
This is conventional hex encoding, with the proviso that
Expand All @@ -327,9 +303,7 @@ only capital letters are used, e.g. `0..9A..F`.
<pre><code>
to_sb32(Bits::bitstring()) -&gt; binary()
</code></pre>

<br></br>

<br />


Converts a bitstring into an sb-encoded bitstring
Expand Down
28 changes: 19 additions & 9 deletions rebar.config
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
%% -*- erlang -*-
{erl_opts, [debug_info]}.
{deps, [{edown, ".*", {git, "git://github.com/esl/edown.git", "HEAD"}}]}.
{src_dirs, ["examples"]}.
{edoc_opts, [{doclet, edown_doclet},
{src_path, ["src/", "examples/"]},
{app_default, "http://www.erlang.org/doc/man"},
{top_level_readme,
{"./README.md",
"http://github.com/uwiger/sext"}}
]}.

{profiles, [{docs, [{deps,
[
{edown,
{git,
"https://github.com/uwiger/edown.git",
{tag,
"0.8"}}}
]},

{edoc_opts, [{doclet, edown_doclet},
{packages,
false},
{subpackages,
true},
{top_level_readme,
{"./README.md",
"http://github.com/uwiger/sext"}}]}]}
]}.
18 changes: 18 additions & 0 deletions rebar.config.script
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
%% -*- erlang -*-
IsRebar3 = erlang:function_exported(rebar3, main, 1),
case IsRebar3 of
true ->
CONFIG;
false ->
Rebar2Config = [
{deps, [{edown, ".*",
{git, "git://github.com/uwiger/edown.git", "HEAD"}}]},
{src_dirs, ["examples"]},
{edoc_opts, [{doclet, edown_doclet},
{src_path, ["src/", "examples/"]},
{app_default, "http://www.erlang.org/doc/man"},
{top_level_readme,
{"./README.md",
"http://github.com/uwiger/sext"}}]}],
CONFIG ++ Rebar2Config
end.
55 changes: 24 additions & 31 deletions src/sext.app.src
Original file line number Diff line number Diff line change
@@ -1,39 +1,32 @@
%%% -*- erlang -*-
%%% ----------------------------------------------------------------------------
%%% Copyright (c) 2009, Erlang Training and Consulting Ltd.
%%% All rights reserved.
%%%
%%% Redistribution and use in source and binary forms, with or without
%%% modification, are permitted provided that the following conditions are met:
%%% * Redistributions of source code must retain the above copyright
%%% notice, this list of conditions and the following disclaimer.
%%% * Redistributions in binary form must reproduce the above copyright
%%% notice, this list of conditions and the following disclaimer in the
%%% documentation and/or other materials provided with the distribution.
%%% * Neither the name of Erlang Training and Consulting Ltd. nor the
%%% names of its contributors may be used to endorse or promote products
%%% derived from this software without specific prior written permission.
%%%
%%% THIS SOFTWARE IS PROVIDED BY Erlang Training and Consulting Ltd. ''AS IS''
%%% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
%%% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
%%% ARE DISCLAIMED. IN NO EVENT SHALL Erlang Training and Consulting Ltd. BE
%%% LIABLE SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
%%% BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
%%% WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
%%% OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
%%% ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
%%% ----------------------------------------------------------------------------
%% -*- erlang-indent-level: 4; indent-tabs-mode: nil -*-
%%==============================================================================
%% Copyright 2014-16 Ulf Wiger
%%
%% Licensed under the Apache License, Version 2.0 (the "License");
%% you may not use this file except in compliance with the License.
%% You may obtain a copy of the License at
%%
%% http://www.apache.org/licenses/LICENSE-2.0
%%
%% Unless required by applicable law or agreed to in writing, software
%% distributed under the License is distributed on an "AS IS" BASIS,
%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
%% See the License for the specific language governing permissions and
%% limitations under the License.
%%==============================================================================

%%% @author Ulf Wiger <ulf.wiger@erlang-consulting.com>
%%% @doc This is a container for parse_trans modules.
%%% @end
%% @author Ulf Wiger <ulf@wiger.net>
%% @doc Sortable serialization of Erlang terms.
%% @end
{application, sext,
[{description, "Sortable serialization library"},
{vsn, git},
{modules, []},
{registered, []},
{applications, [kernel, stdlib]},
{env, []}
]}.
{env, []},

{maintainers, ["Ulf Wiger"]},
{licenses, ["Apache 2.0"]},
{links, [{"Github", "https://github.com/uwiger/sext"}]}
]}.
Loading