plist.cpp 18 KB

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