| OLD | NEW |
| (Empty) |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef DEVICE_BLUETOOTH_URIBEACON_URI_ENCODER_H_ | |
| 6 #define DEVICE_BLUETOOTH_URIBEACON_URI_ENCODER_H_ | |
| 7 | |
| 8 #include <stdint.h> | |
| 9 | |
| 10 #include <string> | |
| 11 #include <vector> | |
| 12 | |
| 13 #include "base/strings/string_piece.h" | |
| 14 | |
| 15 namespace device { | |
| 16 | |
| 17 // The following functions EncodeUriBeaconUri() and DecodeUriBeaconUri() helps | |
| 18 // encoding/decoding URI with the UriBeacon encoding. | |
| 19 // | |
| 20 // Example usage: | |
| 21 // | |
| 22 // std::vector<uint8_t> encoded; | |
| 23 // EncodeUriBeaconUri("http://web.mit.edu/", encoded) | |
| 24 // // encoded -> {2, 'w', 'e', 'b', '.', 'm', 'i', 't', 2} | |
| 25 // | |
| 26 // const char encodedUri[] = {0, 'u', 'r', 'i', 'b', 'e', 'a', 'c', 'o', 'n', | |
| 27 // 8}; | |
| 28 // const std::vector<uint8_t> kEncodedUri(encodedUri, encodedUri + | |
| 29 // sizeof(encodedUri)); | |
| 30 // std::string decoded; | |
| 31 // DecodeUriBeaconUri(kEncodedUri, decoded) | |
| 32 // // decoded -> "http://uribeacon.org" | |
| 33 | |
| 34 // Encodes the input string using URI encoding described in UriBeacon | |
| 35 // specifications. |input| must be ASCII characters. | |
| 36 void EncodeUriBeaconUri(const std::string& input, std::vector<uint8_t>& output); | |
| 37 | |
| 38 // Decodes the input string using URI encoding described in UriBeacon | |
| 39 // specifications. | |
| 40 void DecodeUriBeaconUri(const std::vector<uint8_t>& input, std::string& output); | |
| 41 | |
| 42 } // namespace device | |
| 43 | |
| 44 #endif | |
| OLD | NEW |