Minor tweaks to the PO details
[barry.git] / src / j_record.cc
blob660cada67a8bbc33e93d9ed1e77fc65794ec71ed
1 ///
2 /// \file j_record.cc
3 /// Internal record manipulation functions for JDWP classes
4 ///
6 /*
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"
23 #include "data.h"
24 #include "protostructs.h"
25 #include <string.h>
27 using namespace Barry::Protocol;
29 namespace Barry {
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;
41 *field = value;
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;
54 *field = value;
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);
70 size += fieldsize;
74 void AddJDWString(Data &data, size_t &size, const std::string &str)
76 AddJDWChar(data, size, str.c_str(), str.size());
79 } // namespace Barry