blob: 55d568a9937bda1bf98603c6fd36d0dda4e996ea [file] [log] [blame]
Elliott Hughes872d4ec2011-10-21 17:07:15 -07001/*
2 * Copyright (C) 2008 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16/*
17 * Expanding byte buffer, with primitives for appending basic data types.
18 */
19#ifndef ART_JDWP_EXPANDBUF_H_
20#define ART_JDWP_EXPANDBUF_H_
21
22#include <stddef.h>
23#include <stdint.h>
24
25namespace art {
26
27namespace JDWP {
28
29struct ExpandBuf; /* private */
30
31/* create a new struct */
32ExpandBuf* expandBufAlloc();
33/* free storage */
34void expandBufFree(ExpandBuf* pBuf);
35
36/*
37 * Accessors. The buffer pointer and length will only be valid until more
38 * data is added.
39 */
40uint8_t* expandBufGetBuffer(ExpandBuf* pBuf);
41size_t expandBufGetLength(ExpandBuf* pBuf);
42
43/*
44 * The "add" operations allocate additional storage and append the data.
45 *
46 * There are no "get" operations included with this "class", other than
47 * GetBuffer(). If you want to get or set data from a position other
48 * than the end, get a pointer to the buffer and use the inline functions
49 * defined elsewhere.
50 *
51 * expandBufAddSpace() returns a pointer to the *start* of the region
52 * added.
53 */
54uint8_t* expandBufAddSpace(ExpandBuf* pBuf, int gapSize);
55void expandBufAdd1(ExpandBuf* pBuf, uint8_t val);
56void expandBufAdd2BE(ExpandBuf* pBuf, uint16_t val);
57void expandBufAdd4BE(ExpandBuf* pBuf, uint32_t val);
58void expandBufAdd8BE(ExpandBuf* pBuf, uint64_t val);
Elliott Hughes4740cdf2011-12-07 14:07:12 -080059void expandBufAddUtf8String(ExpandBuf* pBuf, const char* s);
60void expandBufAddUtf8String(ExpandBuf* pBuf, const std::string& s);
Elliott Hughes872d4ec2011-10-21 17:07:15 -070061
62} // namespace JDWP
63
64} // namespace art
65
66#endif // ART_JDWP_EXPANDBUF_H_