diff options
Diffstat (limited to 'src/Data.cpp')
| -rw-r--r-- | src/Data.cpp | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/src/Data.cpp b/src/Data.cpp new file mode 100644 index 0000000..2ce610d --- /dev/null +++ b/src/Data.cpp | |||
| @@ -0,0 +1,57 @@ | |||
| 1 | /* | ||
| 2 | * Data.cpp | ||
| 3 | * | ||
| 4 | * Copyright (c) 2009 Jonathan Beck All Rights Reserved. | ||
| 5 | * | ||
| 6 | * This library is free software; you can redistribute it and/or | ||
| 7 | * modify it under the terms of the GNU Lesser General Public | ||
| 8 | * License as published by the Free Software Foundation; either | ||
| 9 | * version 2.1 of the License, or (at your option) any later version. | ||
| 10 | * | ||
| 11 | * This library is distributed in the hope that it will be useful, | ||
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 14 | * Lesser General Public License for more details. | ||
| 15 | * | ||
| 16 | * You should have received a copy of the GNU Lesser General Public | ||
| 17 | * License along with this library; if not, write to the Free Software | ||
| 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 19 | */ | ||
| 20 | |||
| 21 | #include <stdlib.h> | ||
| 22 | #include <plist/Data.h> | ||
| 23 | |||
| 24 | namespace PList | ||
| 25 | { | ||
| 26 | |||
| 27 | Data::Data() : Node(PLIST_DATA) | ||
| 28 | { | ||
| 29 | } | ||
| 30 | |||
| 31 | Data::Data(std::vector<char>& buff) : Node(PLIST_DATA) | ||
| 32 | { | ||
| 33 | plist_set_data_val(_node, &buff[0], buff.size()); | ||
| 34 | } | ||
| 35 | |||
| 36 | Data::~Data() | ||
| 37 | { | ||
| 38 | } | ||
| 39 | |||
| 40 | void Data::SetValue(std::vector<char>& buff) | ||
| 41 | { | ||
| 42 | plist_set_data_val(_node, &buff[0], buff.size()); | ||
| 43 | } | ||
| 44 | |||
| 45 | std::vector<char> Data::GetValue() | ||
| 46 | { | ||
| 47 | char* buff = NULL; | ||
| 48 | uint64_t length = 0; | ||
| 49 | plist_get_data_val(_node, &buff, &length); | ||
| 50 | std::vector<char> ret(buff, buff + length); | ||
| 51 | free(buff); | ||
| 52 | return ret; | ||
| 53 | } | ||
| 54 | |||
| 55 | |||
| 56 | |||
| 57 | }; | ||
