plist.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564
  1. /*************************************************************************/
  2. /* plist.cpp */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /*************************************************************************/
  30. #include "plist.h"
  31. Ref<PListNode> PListNode::new_array() {
  32. Ref<PListNode> node = memnew(PListNode());
  33. ERR_FAIL_COND_V(node.is_null(), Ref<PListNode>());
  34. node->data_type = PList::PLNodeType::PL_NODE_TYPE_ARRAY;
  35. return node;
  36. }
  37. Ref<PListNode> PListNode::new_dict() {
  38. Ref<PListNode> node = memnew(PListNode());
  39. ERR_FAIL_COND_V(node.is_null(), Ref<PListNode>());
  40. node->data_type = PList::PLNodeType::PL_NODE_TYPE_DICT;
  41. return node;
  42. }
  43. Ref<PListNode> PListNode::new_string(const String &p_string) {
  44. Ref<PListNode> node = memnew(PListNode());
  45. ERR_FAIL_COND_V(node.is_null(), Ref<PListNode>());
  46. node->data_type = PList::PLNodeType::PL_NODE_TYPE_STRING;
  47. node->data_string = p_string.utf8();
  48. return node;
  49. }
  50. Ref<PListNode> PListNode::new_data(const String &p_string) {
  51. Ref<PListNode> node = memnew(PListNode());
  52. ERR_FAIL_COND_V(node.is_null(), Ref<PListNode>());
  53. node->data_type = PList::PLNodeType::PL_NODE_TYPE_DATA;
  54. node->data_string = p_string.utf8();
  55. return node;
  56. }
  57. Ref<PListNode> PListNode::new_date(const String &p_string) {
  58. Ref<PListNode> node = memnew(PListNode());
  59. ERR_FAIL_COND_V(node.is_null(), Ref<PListNode>());
  60. node->data_type = PList::PLNodeType::PL_NODE_TYPE_DATE;
  61. node->data_string = p_string.utf8();
  62. return node;
  63. }
  64. Ref<PListNode> PListNode::new_bool(bool p_bool) {
  65. Ref<PListNode> node = memnew(PListNode());
  66. ERR_FAIL_COND_V(node.is_null(), Ref<PListNode>());
  67. node->data_type = PList::PLNodeType::PL_NODE_TYPE_BOOLEAN;
  68. node->data_bool = p_bool;
  69. return node;
  70. }
  71. Ref<PListNode> PListNode::new_int(int32_t p_int) {
  72. Ref<PListNode> node = memnew(PListNode());
  73. ERR_FAIL_COND_V(node.is_null(), Ref<PListNode>());
  74. node->data_type = PList::PLNodeType::PL_NODE_TYPE_INTEGER;
  75. node->data_int = p_int;
  76. return node;
  77. }
  78. Ref<PListNode> PListNode::new_real(float p_real) {
  79. Ref<PListNode> node = memnew(PListNode());
  80. ERR_FAIL_COND_V(node.is_null(), Ref<PListNode>());
  81. node->data_type = PList::PLNodeType::PL_NODE_TYPE_REAL;
  82. node->data_real = p_real;
  83. return node;
  84. }
  85. bool PListNode::push_subnode(const Ref<PListNode> &p_node, const String &p_key) {
  86. ERR_FAIL_COND_V(p_node.is_null(), false);
  87. if (data_type == PList::PLNodeType::PL_NODE_TYPE_DICT) {
  88. ERR_FAIL_COND_V(p_key.is_empty(), false);
  89. ERR_FAIL_COND_V(data_dict.has(p_key), false);
  90. data_dict[p_key] = p_node;
  91. return true;
  92. } else if (data_type == PList::PLNodeType::PL_NODE_TYPE_ARRAY) {
  93. data_array.push_back(p_node);
  94. return true;
  95. } else {
  96. ERR_FAIL_V_MSG(false, "PList: Invalid parent node type, should be DICT or ARRAY.");
  97. }
  98. }
  99. size_t PListNode::get_asn1_size(uint8_t p_len_octets) const {
  100. // Get size of all data, excluding type and size information.
  101. switch (data_type) {
  102. case PList::PLNodeType::PL_NODE_TYPE_NIL: {
  103. return 0;
  104. } break;
  105. case PList::PLNodeType::PL_NODE_TYPE_DATA:
  106. case PList::PLNodeType::PL_NODE_TYPE_DATE: {
  107. ERR_FAIL_V_MSG(0, "PList: DATE and DATA nodes are not supported by ASN.1 serialization.");
  108. } break;
  109. case PList::PLNodeType::PL_NODE_TYPE_STRING: {
  110. return data_string.length();
  111. } break;
  112. case PList::PLNodeType::PL_NODE_TYPE_BOOLEAN: {
  113. return 1;
  114. } break;
  115. case PList::PLNodeType::PL_NODE_TYPE_INTEGER:
  116. case PList::PLNodeType::PL_NODE_TYPE_REAL: {
  117. return 4;
  118. } break;
  119. case PList::PLNodeType::PL_NODE_TYPE_ARRAY: {
  120. size_t size = 0;
  121. for (int i = 0; i < data_array.size(); i++) {
  122. size += 1 + _asn1_size_len(p_len_octets) + data_array[i]->get_asn1_size(p_len_octets);
  123. }
  124. return size;
  125. } break;
  126. case PList::PLNodeType::PL_NODE_TYPE_DICT: {
  127. size_t size = 0;
  128. for (const KeyValue<String, Ref<PListNode>> &E : data_dict) {
  129. size += 1 + _asn1_size_len(p_len_octets); // Sequence.
  130. size += 1 + _asn1_size_len(p_len_octets) + E.key.utf8().length(); //Key.
  131. size += 1 + _asn1_size_len(p_len_octets) + E.value->get_asn1_size(p_len_octets); // Value.
  132. }
  133. return size;
  134. } break;
  135. default: {
  136. return 0;
  137. } break;
  138. }
  139. }
  140. int PListNode::_asn1_size_len(uint8_t p_len_octets) {
  141. if (p_len_octets > 1) {
  142. return p_len_octets + 1;
  143. } else {
  144. return 1;
  145. }
  146. }
  147. void PListNode::store_asn1_size(PackedByteArray &p_stream, uint8_t p_len_octets) const {
  148. uint32_t size = get_asn1_size(p_len_octets);
  149. if (p_len_octets > 1) {
  150. p_stream.push_back(0x80 + p_len_octets);
  151. }
  152. for (int i = p_len_octets - 1; i >= 0; i--) {
  153. uint8_t x = (size >> i * 8) & 0xFF;
  154. p_stream.push_back(x);
  155. }
  156. }
  157. bool PListNode::store_asn1(PackedByteArray &p_stream, uint8_t p_len_octets) const {
  158. // Convert to binary ASN1 stream.
  159. bool valid = true;
  160. switch (data_type) {
  161. case PList::PLNodeType::PL_NODE_TYPE_NIL: {
  162. // Nothing to store.
  163. } break;
  164. case PList::PLNodeType::PL_NODE_TYPE_DATE:
  165. case PList::PLNodeType::PL_NODE_TYPE_DATA: {
  166. ERR_FAIL_V_MSG(false, "PList: DATE and DATA nodes are not supported by ASN.1 serialization.");
  167. } break;
  168. case PList::PLNodeType::PL_NODE_TYPE_STRING: {
  169. p_stream.push_back(0x0C);
  170. store_asn1_size(p_stream, p_len_octets);
  171. for (int i = 0; i < data_string.size(); i++) {
  172. p_stream.push_back(data_string[i]);
  173. }
  174. } break;
  175. case PList::PLNodeType::PL_NODE_TYPE_BOOLEAN: {
  176. p_stream.push_back(0x01);
  177. store_asn1_size(p_stream, p_len_octets);
  178. if (data_bool) {
  179. p_stream.push_back(0x01);
  180. } else {
  181. p_stream.push_back(0x00);
  182. }
  183. } break;
  184. case PList::PLNodeType::PL_NODE_TYPE_INTEGER: {
  185. p_stream.push_back(0x02);
  186. store_asn1_size(p_stream, p_len_octets);
  187. for (int i = 4; i >= 0; i--) {
  188. uint8_t x = (data_int >> i * 8) & 0xFF;
  189. p_stream.push_back(x);
  190. }
  191. } break;
  192. case PList::PLNodeType::PL_NODE_TYPE_REAL: {
  193. p_stream.push_back(0x03);
  194. store_asn1_size(p_stream, p_len_octets);
  195. for (int i = 4; i >= 0; i--) {
  196. uint8_t x = (data_int >> i * 8) & 0xFF;
  197. p_stream.push_back(x);
  198. }
  199. } break;
  200. case PList::PLNodeType::PL_NODE_TYPE_ARRAY: {
  201. p_stream.push_back(0x30); // Sequence.
  202. store_asn1_size(p_stream, p_len_octets);
  203. for (int i = 0; i < data_array.size(); i++) {
  204. valid = valid && data_array[i]->store_asn1(p_stream, p_len_octets);
  205. }
  206. } break;
  207. case PList::PLNodeType::PL_NODE_TYPE_DICT: {
  208. p_stream.push_back(0x31); // Set.
  209. store_asn1_size(p_stream, p_len_octets);
  210. for (const KeyValue<String, Ref<PListNode>> &E : data_dict) {
  211. CharString cs = E.key.utf8();
  212. uint32_t size = cs.length();
  213. // Sequence.
  214. p_stream.push_back(0x30);
  215. uint32_t seq_size = 2 * (1 + _asn1_size_len(p_len_octets)) + size + E.value->get_asn1_size(p_len_octets);
  216. if (p_len_octets > 1) {
  217. p_stream.push_back(0x80 + p_len_octets);
  218. }
  219. for (int i = p_len_octets - 1; i >= 0; i--) {
  220. uint8_t x = (seq_size >> i * 8) & 0xFF;
  221. p_stream.push_back(x);
  222. }
  223. // Key.
  224. p_stream.push_back(0x0C);
  225. if (p_len_octets > 1) {
  226. p_stream.push_back(0x80 + p_len_octets);
  227. }
  228. for (int i = p_len_octets - 1; i >= 0; i--) {
  229. uint8_t x = (size >> i * 8) & 0xFF;
  230. p_stream.push_back(x);
  231. }
  232. for (uint32_t i = 0; i < size; i++) {
  233. p_stream.push_back(cs[i]);
  234. }
  235. // Value.
  236. valid = valid && E.value->store_asn1(p_stream, p_len_octets);
  237. }
  238. } break;
  239. }
  240. return valid;
  241. }
  242. void PListNode::store_text(String &p_stream, uint8_t p_indent) const {
  243. // Convert to text XML stream.
  244. switch (data_type) {
  245. case PList::PLNodeType::PL_NODE_TYPE_NIL: {
  246. // Nothing to store.
  247. } break;
  248. case PList::PLNodeType::PL_NODE_TYPE_DATA: {
  249. p_stream += String("\t").repeat(p_indent);
  250. p_stream += "<data>\n";
  251. p_stream += String("\t").repeat(p_indent);
  252. p_stream += data_string + "\n";
  253. p_stream += String("\t").repeat(p_indent);
  254. p_stream += "</data>\n";
  255. } break;
  256. case PList::PLNodeType::PL_NODE_TYPE_DATE: {
  257. p_stream += String("\t").repeat(p_indent);
  258. p_stream += "<date>";
  259. p_stream += data_string;
  260. p_stream += "</date>\n";
  261. } break;
  262. case PList::PLNodeType::PL_NODE_TYPE_STRING: {
  263. p_stream += String("\t").repeat(p_indent);
  264. p_stream += "<string>";
  265. p_stream += String::utf8(data_string);
  266. p_stream += "</string>\n";
  267. } break;
  268. case PList::PLNodeType::PL_NODE_TYPE_BOOLEAN: {
  269. p_stream += String("\t").repeat(p_indent);
  270. if (data_bool) {
  271. p_stream += "<true/>\n";
  272. } else {
  273. p_stream += "<false/>\n";
  274. }
  275. } break;
  276. case PList::PLNodeType::PL_NODE_TYPE_INTEGER: {
  277. p_stream += String("\t").repeat(p_indent);
  278. p_stream += "<integer>";
  279. p_stream += itos(data_int);
  280. p_stream += "</integer>\n";
  281. } break;
  282. case PList::PLNodeType::PL_NODE_TYPE_REAL: {
  283. p_stream += String("\t").repeat(p_indent);
  284. p_stream += "<real>";
  285. p_stream += rtos(data_real);
  286. p_stream += "</real>\n";
  287. } break;
  288. case PList::PLNodeType::PL_NODE_TYPE_ARRAY: {
  289. p_stream += String("\t").repeat(p_indent);
  290. p_stream += "<array>\n";
  291. for (int i = 0; i < data_array.size(); i++) {
  292. data_array[i]->store_text(p_stream, p_indent + 1);
  293. }
  294. p_stream += String("\t").repeat(p_indent);
  295. p_stream += "</array>\n";
  296. } break;
  297. case PList::PLNodeType::PL_NODE_TYPE_DICT: {
  298. p_stream += String("\t").repeat(p_indent);
  299. p_stream += "<dict>\n";
  300. for (const KeyValue<String, Ref<PListNode>> &E : data_dict) {
  301. p_stream += String("\t").repeat(p_indent + 1);
  302. p_stream += "<key>";
  303. p_stream += E.key;
  304. p_stream += "</key>\n";
  305. E.value->store_text(p_stream, p_indent + 1);
  306. }
  307. p_stream += String("\t").repeat(p_indent);
  308. p_stream += "</dict>\n";
  309. } break;
  310. }
  311. }
  312. /*************************************************************************/
  313. PList::PList() {
  314. root = PListNode::new_dict();
  315. }
  316. PList::PList(const String &p_string) {
  317. load_string(p_string);
  318. }
  319. bool PList::load_file(const String &p_filename) {
  320. root = Ref<PListNode>();
  321. Ref<FileAccess> fb = FileAccess::open(p_filename, FileAccess::READ);
  322. if (fb.is_null()) {
  323. return false;
  324. }
  325. unsigned char magic[8];
  326. fb->get_buffer(magic, 8);
  327. if (String((const char *)magic, 8) == "bplist00") {
  328. ERR_FAIL_V_MSG(false, "PList: Binary property lists are not supported.");
  329. } else {
  330. // Load text plist.
  331. Error err;
  332. Vector<uint8_t> array = FileAccess::get_file_as_array(p_filename, &err);
  333. ERR_FAIL_COND_V(err != OK, false);
  334. String ret;
  335. ret.parse_utf8((const char *)array.ptr(), array.size());
  336. return load_string(ret);
  337. }
  338. }
  339. bool PList::load_string(const String &p_string) {
  340. root = Ref<PListNode>();
  341. int pos = 0;
  342. bool in_plist = false;
  343. bool done_plist = false;
  344. List<Ref<PListNode>> stack;
  345. String key;
  346. while (pos >= 0) {
  347. int open_token_s = p_string.find("<", pos);
  348. if (open_token_s == -1) {
  349. ERR_FAIL_V_MSG(false, "PList: Unexpected end of data. No tags found.");
  350. }
  351. int open_token_e = p_string.find(">", open_token_s);
  352. pos = open_token_e;
  353. String token = p_string.substr(open_token_s + 1, open_token_e - open_token_s - 1);
  354. if (token.is_empty()) {
  355. ERR_FAIL_V_MSG(false, "PList: Invalid token name.");
  356. }
  357. String value;
  358. if (token[0] == '?' || token[0] == '!') { // Skip <?xml ... ?> and <!DOCTYPE ... >
  359. int end_token_e = p_string.find(">", open_token_s);
  360. pos = end_token_e;
  361. continue;
  362. }
  363. if (token.find("plist", 0) == 0) {
  364. in_plist = true;
  365. continue;
  366. }
  367. if (token == "/plist") {
  368. done_plist = true;
  369. break;
  370. }
  371. if (!in_plist) {
  372. ERR_FAIL_V_MSG(false, "PList: Node outside of <plist> tag.");
  373. }
  374. if (token == "dict") {
  375. if (!stack.is_empty()) {
  376. // Add subnode end enter it.
  377. Ref<PListNode> dict = PListNode::new_dict();
  378. dict->data_type = PList::PLNodeType::PL_NODE_TYPE_DICT;
  379. if (!stack.back()->get()->push_subnode(dict, key)) {
  380. ERR_FAIL_V_MSG(false, "PList: Can't push subnode, invalid parent type.");
  381. }
  382. stack.push_back(dict);
  383. } else {
  384. // Add root node.
  385. if (!root.is_null()) {
  386. ERR_FAIL_V_MSG(false, "PList: Root node already set.");
  387. }
  388. Ref<PListNode> dict = PListNode::new_dict();
  389. stack.push_back(dict);
  390. root = dict;
  391. }
  392. continue;
  393. }
  394. if (token == "/dict") {
  395. // Exit current dict.
  396. if (stack.is_empty() || stack.back()->get()->data_type != PList::PLNodeType::PL_NODE_TYPE_DICT) {
  397. ERR_FAIL_V_MSG(false, "PList: Mismatched </dict> tag.");
  398. }
  399. stack.pop_back();
  400. continue;
  401. }
  402. if (token == "array") {
  403. if (!stack.is_empty()) {
  404. // Add subnode end enter it.
  405. Ref<PListNode> arr = PListNode::new_array();
  406. if (!stack.back()->get()->push_subnode(arr, key)) {
  407. ERR_FAIL_V_MSG(false, "PList: Can't push subnode, invalid parent type.");
  408. }
  409. stack.push_back(arr);
  410. } else {
  411. // Add root node.
  412. if (!root.is_null()) {
  413. ERR_FAIL_V_MSG(false, "PList: Root node already set.");
  414. }
  415. Ref<PListNode> arr = PListNode::new_array();
  416. stack.push_back(arr);
  417. root = arr;
  418. }
  419. continue;
  420. }
  421. if (token == "/array") {
  422. // Exit current array.
  423. if (stack.is_empty() || stack.back()->get()->data_type != PList::PLNodeType::PL_NODE_TYPE_ARRAY) {
  424. ERR_FAIL_V_MSG(false, "PList: Mismatched </array> tag.");
  425. }
  426. stack.pop_back();
  427. continue;
  428. }
  429. if (token[token.length() - 1] == '/') {
  430. token = token.substr(0, token.length() - 1);
  431. } else {
  432. int end_token_s = p_string.find("</", pos);
  433. if (end_token_s == -1) {
  434. ERR_FAIL_V_MSG(false, vformat("PList: Mismatched <%s> tag.", token));
  435. }
  436. int end_token_e = p_string.find(">", end_token_s);
  437. pos = end_token_e;
  438. String end_token = p_string.substr(end_token_s + 2, end_token_e - end_token_s - 2);
  439. if (end_token != token) {
  440. ERR_FAIL_V_MSG(false, vformat("PList: Mismatched <%s> and <%s> token pair.", token, end_token));
  441. }
  442. value = p_string.substr(open_token_e + 1, end_token_s - open_token_e - 1);
  443. }
  444. if (token == "key") {
  445. key = value;
  446. } else {
  447. Ref<PListNode> var = nullptr;
  448. if (token == "true") {
  449. var = PListNode::new_bool(true);
  450. } else if (token == "false") {
  451. var = PListNode::new_bool(false);
  452. } else if (token == "integer") {
  453. var = PListNode::new_int(value.to_int());
  454. } else if (token == "real") {
  455. var = PListNode::new_real(value.to_float());
  456. } else if (token == "string") {
  457. var = PListNode::new_string(value);
  458. } else if (token == "data") {
  459. var = PListNode::new_data(value);
  460. } else if (token == "date") {
  461. var = PListNode::new_date(value);
  462. } else {
  463. ERR_FAIL_V_MSG(false, "PList: Invalid value type.");
  464. }
  465. if (stack.is_empty() || !stack.back()->get()->push_subnode(var, key)) {
  466. ERR_FAIL_V_MSG(false, "PList: Can't push subnode, invalid parent type.");
  467. }
  468. }
  469. }
  470. if (!stack.is_empty() || !done_plist) {
  471. ERR_FAIL_V_MSG(false, "PList: Unexpected end of data. Root node is not closed.");
  472. }
  473. return true;
  474. }
  475. PackedByteArray PList::save_asn1() const {
  476. if (root == nullptr) {
  477. ERR_FAIL_V_MSG(PackedByteArray(), "PList: Invalid PList, no root node.");
  478. }
  479. size_t size = root->get_asn1_size(1);
  480. uint8_t len_octets = 0;
  481. if (size < 0x80) {
  482. len_octets = 1;
  483. } else {
  484. size = root->get_asn1_size(2);
  485. if (size < 0xFFFF) {
  486. len_octets = 2;
  487. } else {
  488. size = root->get_asn1_size(3);
  489. if (size < 0xFFFFFF) {
  490. len_octets = 3;
  491. } else {
  492. size = root->get_asn1_size(4);
  493. if (size < 0xFFFFFFFF) {
  494. len_octets = 4;
  495. } else {
  496. ERR_FAIL_V_MSG(PackedByteArray(), "PList: Data is too big for ASN.1 serializer, should be < 4 GiB.");
  497. }
  498. }
  499. }
  500. }
  501. PackedByteArray ret;
  502. if (!root->store_asn1(ret, len_octets)) {
  503. ERR_FAIL_V_MSG(PackedByteArray(), "PList: ASN.1 serializer error.");
  504. }
  505. return ret;
  506. }
  507. String PList::save_text() const {
  508. if (root == nullptr) {
  509. ERR_FAIL_V_MSG(String(), "PList: Invalid PList, no root node.");
  510. }
  511. String ret;
  512. ret += "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
  513. ret += "<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n";
  514. ret += "<plist version=\"1.0\">\n";
  515. root->store_text(ret, 0);
  516. ret += "</plist>\n\n";
  517. return ret;
  518. }
  519. Ref<PListNode> PList::get_root() {
  520. return root;
  521. }