Reads all boxes from the string. Otherwise, as ReadAllBoxes.
| 63 | |
| 64 | // Reads all boxes from the string. Otherwise, as ReadAllBoxes. |
| 65 | bool ReadMemBoxes(int target_page, bool skip_blanks, const char* box_data, |
| 66 | GenericVector<TBOX>* boxes, |
| 67 | GenericVector<STRING>* texts, |
| 68 | GenericVector<STRING>* box_texts, |
| 69 | GenericVector<int>* pages) { |
| 70 | STRING box_str(box_data); |
| 71 | GenericVector<STRING> lines; |
| 72 | box_str.split('\n', &lines); |
| 73 | if (lines.empty()) return false; |
| 74 | int num_boxes = 0; |
| 75 | for (int i = 0; i < lines.size(); ++i) { |
| 76 | int page = 0; |
| 77 | STRING utf8_str; |
| 78 | TBOX box; |
| 79 | if (!ParseBoxFileStr(lines[i].string(), &page, &utf8_str, &box)) { |
| 80 | continue; |
| 81 | } |
| 82 | if (skip_blanks && (utf8_str == " " || utf8_str == "\t")) continue; |
| 83 | if (target_page >= 0 && page != target_page) continue; |
| 84 | if (boxes != NULL) boxes->push_back(box); |
| 85 | if (texts != NULL) texts->push_back(utf8_str); |
| 86 | if (box_texts != NULL) { |
| 87 | STRING full_text; |
| 88 | MakeBoxFileStr(utf8_str.string(), box, target_page, &full_text); |
| 89 | box_texts->push_back(full_text); |
| 90 | } |
| 91 | if (pages != NULL) pages->push_back(page); |
| 92 | ++num_boxes; |
| 93 | } |
| 94 | return num_boxes > 0; |
| 95 | } |
| 96 | |
| 97 | // Returns the box file name corresponding to the given image_filename. |
| 98 | STRING BoxFileName(const STRING& image_filename) { |
no test coverage detected