diff options
author | Eric Blossom <eb@comsec.com> | 2009-08-18 22:44:05 -0700 |
---|---|---|
committer | Eric Blossom <eb@comsec.com> | 2009-08-18 22:44:05 -0700 |
commit | 6213d97eba31b66f8234357c6f030124f417f74d (patch) | |
tree | 2301c62e23207a4703b92f188286d4d518c1fe07 /gruel/src/lib/pmt/pmt.cc | |
parent | 4425cea2297d29f7cb90ac045b39928358cff1e4 (diff) |
Add blobs and shorthand pmt pseudo-constructors.
blobs == Binary Large Object. Very handy for passing around
uninterpreted data. The shorthand constructors were implemented by
overloading the pmt_t mp(foo) function in the pmt namespace.
I originally called "mp" "pmt", but that caused a conflict with the
pmt namespace.
Diffstat (limited to 'gruel/src/lib/pmt/pmt.cc')
-rw-r--r-- | gruel/src/lib/pmt/pmt.cc | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/gruel/src/lib/pmt/pmt.cc b/gruel/src/lib/pmt/pmt.cc index 42f25b9de9..e50e218380 100644 --- a/gruel/src/lib/pmt/pmt.cc +++ b/gruel/src/lib/pmt/pmt.cc @@ -917,6 +917,39 @@ pmt_msg_accepter_ref(const pmt_t &obj) //////////////////////////////////////////////////////////////////////////// +// Binary Large Object -- currently a u8vector +//////////////////////////////////////////////////////////////////////////// + +bool +pmt_is_blob(pmt_t x) +{ + // return pmt_is_u8vector(x); + return pmt_is_uniform_vector(x); +} + +pmt_t +pmt_make_blob(const void *buf, size_t len_in_bytes) +{ + return pmt_init_u8vector(len_in_bytes, (const uint8_t *) buf); +} + +const void * +pmt_blob_data(pmt_t blob) +{ + size_t len; + return pmt_uniform_vector_elements(blob, len); +} + +size_t +pmt_blob_length(pmt_t blob) +{ + size_t len; + pmt_uniform_vector_elements(blob, len); + return len; +} + + +//////////////////////////////////////////////////////////////////////////// // General Functions //////////////////////////////////////////////////////////////////////////// |