Roll src/third_party/WebKit d9c6159:8139f33 (svn 201974:201975)
[chromium-blink-merge.git] / device / bluetooth / uribeacon / uri_encoder.h
blob30d27d65e7c4930e2ea6f763fedeba0b8cbc12e0
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.
5 #ifndef DEVICE_BLUETOOTH_URIBEACON_URI_ENCODER_H_
6 #define DEVICE_BLUETOOTH_URIBEACON_URI_ENCODER_H_
8 #include <string>
9 #include <vector>
11 #include "base/strings/string_piece.h"
13 namespace device {
15 // The following functions EncodeUriBeaconUri() and DecodeUriBeaconUri() helps
16 // encoding/decoding URI with the UriBeacon encoding.
18 // Example usage:
20 // std::vector<uint8_t> encoded;
21 // EncodeUriBeaconUri("http://web.mit.edu/", encoded)
22 // // encoded -> {2, 'w', 'e', 'b', '.', 'm', 'i', 't', 2}
24 // const char encodedUri[] = {0, 'u', 'r', 'i', 'b', 'e', 'a', 'c', 'o', 'n',
25 // 8};
26 // const std::vector<uint8_t> kEncodedUri(encodedUri, encodedUri +
27 // sizeof(encodedUri));
28 // std::string decoded;
29 // DecodeUriBeaconUri(kEncodedUri, decoded)
30 // // decoded -> "http://uribeacon.org"
32 // Encodes the input string using URI encoding described in UriBeacon
33 // specifications. |input| must be ASCII characters.
34 void EncodeUriBeaconUri(const std::string& input, std::vector<uint8_t>& output);
36 // Decodes the input string using URI encoding described in UriBeacon
37 // specifications.
38 void DecodeUriBeaconUri(const std::vector<uint8_t>& input, std::string& output);
40 } // namespace device
42 #endif