plist.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570
  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 "modules/modules_enabled.gen.h" // For regex.
  31. #include "plist.h"
  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.is_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 KeyValue<String, Ref<PListNode>> &E : data_dict) {
  131. size += 1 + _asn1_size_len(p_len_octets); // Sequence.
  132. size += 1 + _asn1_size_len(p_len_octets) + E.key.utf8().length(); //Key.
  133. size += 1 + _asn1_size_len(p_len_octets) + E.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(PackedByteArray &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(PackedByteArray &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 KeyValue<String, Ref<PListNode>> &E : data_dict) {
  213. CharString cs = E.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 + E.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 && E.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 KeyValue<String, Ref<PListNode>> &E : data_dict) {
  303. p_stream += String("\t").repeat(p_indent + 1);
  304. p_stream += "<key>";
  305. p_stream += E.key;
  306. p_stream += "</key>\n";
  307. E.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. Ref<FileAccess> fb = FileAccess::open(p_filename, FileAccess::READ);
  324. if (fb.is_null()) {
  325. return false;
  326. }
  327. unsigned char magic[8];
  328. fb->get_buffer(magic, 8);
  329. if (String((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.is_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. done_plist = true;
  371. break;
  372. }
  373. if (!in_plist) {
  374. ERR_FAIL_V_MSG(false, "PList: Node outside of <plist> tag.");
  375. }
  376. if (token == "dict") {
  377. if (!stack.is_empty()) {
  378. // Add subnode end enter it.
  379. Ref<PListNode> dict = PListNode::new_dict();
  380. dict->data_type = PList::PLNodeType::PL_NODE_TYPE_DICT;
  381. if (!stack.back()->get()->push_subnode(dict, key)) {
  382. ERR_FAIL_V_MSG(false, "PList: Can't push subnode, invalid parent type.");
  383. }
  384. stack.push_back(dict);
  385. } else {
  386. // Add root node.
  387. if (!root.is_null()) {
  388. ERR_FAIL_V_MSG(false, "PList: Root node already set.");
  389. }
  390. Ref<PListNode> dict = PListNode::new_dict();
  391. stack.push_back(dict);
  392. root = dict;
  393. }
  394. continue;
  395. }
  396. if (token == "/dict") {
  397. // Exit current dict.
  398. if (stack.is_empty() || stack.back()->get()->data_type != PList::PLNodeType::PL_NODE_TYPE_DICT) {
  399. ERR_FAIL_V_MSG(false, "PList: Mismatched </dict> tag.");
  400. }
  401. stack.pop_back();
  402. continue;
  403. }
  404. if (token == "array") {
  405. if (!stack.is_empty()) {
  406. // Add subnode end enter it.
  407. Ref<PListNode> arr = PListNode::new_array();
  408. if (!stack.back()->get()->push_subnode(arr, key)) {
  409. ERR_FAIL_V_MSG(false, "PList: Can't push subnode, invalid parent type.");
  410. }
  411. stack.push_back(arr);
  412. } else {
  413. // Add root node.
  414. if (!root.is_null()) {
  415. ERR_FAIL_V_MSG(false, "PList: Root node already set.");
  416. }
  417. Ref<PListNode> arr = PListNode::new_array();
  418. stack.push_back(arr);
  419. root = arr;
  420. }
  421. continue;
  422. }
  423. if (token == "/array") {
  424. // Exit current array.
  425. if (stack.is_empty() || stack.back()->get()->data_type != PList::PLNodeType::PL_NODE_TYPE_ARRAY) {
  426. ERR_FAIL_V_MSG(false, "PList: Mismatched </array> tag.");
  427. }
  428. stack.pop_back();
  429. continue;
  430. }
  431. if (token[token.length() - 1] == '/') {
  432. token = token.substr(0, token.length() - 1);
  433. } else {
  434. int end_token_s = p_string.find("</", pos);
  435. if (end_token_s == -1) {
  436. ERR_FAIL_V_MSG(false, vformat("PList: Mismatched <%s> tag.", token));
  437. }
  438. int end_token_e = p_string.find(">", end_token_s);
  439. pos = end_token_e;
  440. String end_token = p_string.substr(end_token_s + 2, end_token_e - end_token_s - 2);
  441. if (end_token != token) {
  442. ERR_FAIL_V_MSG(false, vformat("PList: Mismatched <%s> and <%s> token pair.", token, end_token));
  443. }
  444. value = p_string.substr(open_token_e + 1, end_token_s - open_token_e - 1);
  445. }
  446. if (token == "key") {
  447. key = value;
  448. } else {
  449. Ref<PListNode> var = nullptr;
  450. if (token == "true") {
  451. var = PListNode::new_bool(true);
  452. } else if (token == "false") {
  453. var = PListNode::new_bool(false);
  454. } else if (token == "integer") {
  455. var = PListNode::new_int(value.to_int());
  456. } else if (token == "real") {
  457. var = PListNode::new_real(value.to_float());
  458. } else if (token == "string") {
  459. var = PListNode::new_string(value);
  460. } else if (token == "data") {
  461. var = PListNode::new_data(value);
  462. } else if (token == "date") {
  463. var = PListNode::new_date(value);
  464. } else {
  465. ERR_FAIL_V_MSG(false, "PList: Invalid value type.");
  466. }
  467. if (stack.is_empty() || !stack.back()->get()->push_subnode(var, key)) {
  468. ERR_FAIL_V_MSG(false, "PList: Can't push subnode, invalid parent type.");
  469. }
  470. }
  471. }
  472. if (!stack.is_empty() || !done_plist) {
  473. ERR_FAIL_V_MSG(false, "PList: Unexpected end of data. Root node is not closed.");
  474. }
  475. return true;
  476. }
  477. PackedByteArray PList::save_asn1() const {
  478. if (root == nullptr) {
  479. ERR_FAIL_V_MSG(PackedByteArray(), "PList: Invalid PList, no root node.");
  480. }
  481. size_t size = root->get_asn1_size(1);
  482. uint8_t len_octets = 0;
  483. if (size < 0x80) {
  484. len_octets = 1;
  485. } else {
  486. size = root->get_asn1_size(2);
  487. if (size < 0xFFFF) {
  488. len_octets = 2;
  489. } else {
  490. size = root->get_asn1_size(3);
  491. if (size < 0xFFFFFF) {
  492. len_octets = 3;
  493. } else {
  494. size = root->get_asn1_size(4);
  495. if (size < 0xFFFFFFFF) {
  496. len_octets = 4;
  497. } else {
  498. ERR_FAIL_V_MSG(PackedByteArray(), "PList: Data is too big for ASN.1 serializer, should be < 4 GiB.");
  499. }
  500. }
  501. }
  502. }
  503. PackedByteArray ret;
  504. if (!root->store_asn1(ret, len_octets)) {
  505. ERR_FAIL_V_MSG(PackedByteArray(), "PList: ASN.1 serializer error.");
  506. }
  507. return ret;
  508. }
  509. String PList::save_text() const {
  510. if (root == nullptr) {
  511. ERR_FAIL_V_MSG(String(), "PList: Invalid PList, no root node.");
  512. }
  513. String ret;
  514. ret += "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
  515. ret += "<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n";
  516. ret += "<plist version=\"1.0\">\n";
  517. root->store_text(ret, 0);
  518. ret += "</plist>\n\n";
  519. return ret;
  520. }
  521. Ref<PListNode> PList::get_root() {
  522. return root;
  523. }
  524. #endif // MODULE_REGEX_ENABLED