aboutsummaryrefslogtreecommitdiffstats
path: root/include/cow_inline.hrl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2019-12-18 21:13:04 +0100
committerLoïc Hoguin <[email protected]>2019-12-18 21:13:04 +0100
commit34291d5bb42c03d92522dfa18d38aa0d22bcb8ec (patch)
treeb92165de0f6afb89f596d93fa9ad95d8f87231ff /include/cow_inline.hrl
parent8aa74cb77a672b5b0ba528df77e8b9d0e53ee8a7 (diff)
downloadcowlib-34291d5bb42c03d92522dfa18d38aa0d22bcb8ec.tar.gz
cowlib-34291d5bb42c03d92522dfa18d38aa0d22bcb8ec.tar.bz2
cowlib-34291d5bb42c03d92522dfa18d38aa0d22bcb8ec.zip
Add cow_uri_templates
Implements RFC6570 level 4.
Diffstat (limited to 'include/cow_inline.hrl')
-rw-r--r--include/cow_inline.hrl56
1 files changed, 56 insertions, 0 deletions
diff --git a/include/cow_inline.hrl b/include/cow_inline.hrl
index e4e6c89..f0d12eb 100644
--- a/include/cow_inline.hrl
+++ b/include/cow_inline.hrl
@@ -388,4 +388,60 @@ end).
C -> Function(Rest, A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, << Acc/binary, C >>)
end).
+%% HEX(C)
+
+-define(HEX(C), (?HEXHL(C bsr 4)), (?HEXHL(C band 16#0f))).
+
+-define(HEXHL(HL),
+ case HL of
+ 0 -> $0;
+ 1 -> $1;
+ 2 -> $2;
+ 3 -> $3;
+ 4 -> $4;
+ 5 -> $5;
+ 6 -> $6;
+ 7 -> $7;
+ 8 -> $8;
+ 9 -> $9;
+ 10 -> $A;
+ 11 -> $B;
+ 12 -> $C;
+ 13 -> $D;
+ 14 -> $E;
+ 15 -> $F
+ end
+).
+
+%% UNHEX(H, L)
+
+-define(UNHEX(H, L), (?UNHEX(H) bsl 4 bor ?UNHEX(L))).
+
+-define(UNHEX(C),
+ case C of
+ $0 -> 0;
+ $1 -> 1;
+ $2 -> 2;
+ $3 -> 3;
+ $4 -> 4;
+ $5 -> 5;
+ $6 -> 6;
+ $7 -> 7;
+ $8 -> 8;
+ $9 -> 9;
+ $A -> 10;
+ $B -> 11;
+ $C -> 12;
+ $D -> 13;
+ $E -> 14;
+ $F -> 15;
+ $a -> 10;
+ $b -> 11;
+ $c -> 12;
+ $d -> 13;
+ $e -> 14;
+ $f -> 15
+ end
+).
+
-endif.