3 /// Internal record manipulation functions for JDWP classes
7 Copyright (C) 2009, Nicolas VIVIEN
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 See the GNU General Public License in the COPYING file at the
19 root directory of this project for more details.
22 #include "record-internal.h"
24 #include "protostructs.h"
27 using namespace Barry::Protocol
;
31 //////////////////////////////////////////////////////////////////////////////
32 // JDWField builder helper functions
34 void AddJDWByte(Data
&data
, size_t &size
, const uint8_t value
)
36 size_t fieldsize
= sizeof(uint8_t);
37 unsigned char *pd
= data
.GetBuffer(size
+ fieldsize
) + size
;
39 uint8_t *field
= (uint8_t *) pd
;
43 size
+= sizeof(uint8_t);
47 void AddJDWInt(Data
&data
, size_t &size
, const uint32_t value
)
49 size_t fieldsize
= sizeof(uint32_t);
50 unsigned char *pd
= data
.GetBuffer(size
+ fieldsize
) + size
;
52 uint32_t *field
= (uint32_t *) pd
;
56 size
+= sizeof(uint32_t);
60 void AddJDWChar(Data
&data
, size_t &size
, const void *buf
, size_t bufsize
)
62 size_t fieldsize
= JDWP_FIELD_HEADER_SIZE
+ bufsize
;
63 unsigned char *pd
= data
.GetBuffer(size
+ fieldsize
) + size
;
65 JDWField
*field
= (JDWField
*) pd
;
67 field
->size
= be_htobl(bufsize
);
68 memcpy(field
->u
.raw
, buf
, bufsize
);
74 void AddJDWString(Data
&data
, size_t &size
, const std::string
&str
)
76 AddJDWChar(data
, size
, str
.c_str(), str
.size());