Added std:: to vector

This commit is contained in:
Zdenko Podobn?? 2016-12-07 17:04:42 +01:00 committed by Zdenko Podobný
parent 82529e31dd
commit 5307204f93
3 changed files with 30 additions and 27 deletions

View File

@ -49,7 +49,8 @@ void BoxChar::AddBox(int x, int y, int width, int height) {
}
/* static */
void BoxChar::TranslateBoxes(int xshift, int yshift, vector<BoxChar*>* boxes) {
void BoxChar::TranslateBoxes(int xshift, int yshift,
std::vector<BoxChar*>* boxes) {
for (int i = 0; i < boxes->size(); ++i) {
BOX* box = (*boxes)[i]->box_;
if (box != NULL) {
@ -62,7 +63,7 @@ void BoxChar::TranslateBoxes(int xshift, int yshift, vector<BoxChar*>* boxes) {
// Prepares for writing the boxes to a file by inserting newlines, spaces,
// and re-ordering so the boxes are strictly left-to-right.
/* static */
void BoxChar::PrepareToWrite(vector<BoxChar*>* boxes) {
void BoxChar::PrepareToWrite(std::vector<BoxChar*>* boxes) {
bool rtl_rules = ContainsMostlyRTL(*boxes);
bool vertical_rules = MostlyVertical(*boxes);
InsertNewlines(rtl_rules, vertical_rules, boxes);
@ -78,7 +79,7 @@ void BoxChar::PrepareToWrite(vector<BoxChar*>* boxes) {
// Inserts newline (tab) characters into the vector at newline positions.
/* static */
void BoxChar::InsertNewlines(bool rtl_rules, bool vertical_rules,
vector<BoxChar*>* boxes) {
std::vector<BoxChar*>* boxes) {
int prev_i = -1;
int max_shift = 0;
for (int i = 0; i < boxes->size(); ++i) {
@ -141,7 +142,7 @@ void BoxChar::InsertNewlines(bool rtl_rules, bool vertical_rules,
// Converts NULL boxes to space characters, with appropriate bounding boxes.
/* static */
void BoxChar::InsertSpaces(bool rtl_rules, bool vertical_rules,
vector<BoxChar*>* boxes) {
std::vector<BoxChar*>* boxes) {
// After InsertNewlines, any remaining null boxes are not newlines, and are
// singletons, so add a box to each remaining null box.
for (int i = 1; i + 1 < boxes->size(); ++i) {
@ -197,7 +198,7 @@ void BoxChar::InsertSpaces(bool rtl_rules, bool vertical_rules,
// Reorders text in a right-to-left script in left-to-right order.
/* static */
void BoxChar::ReorderRTLText(vector<BoxChar*>* boxes) {
void BoxChar::ReorderRTLText(std::vector<BoxChar*>* boxes) {
// After adding newlines and spaces, this task is simply a matter of sorting
// by left each group of boxes between newlines.
BoxCharPtrSort sorter;
@ -211,7 +212,7 @@ void BoxChar::ReorderRTLText(vector<BoxChar*>* boxes) {
// Returns true if the vector contains mostly RTL characters.
/* static */
bool BoxChar::ContainsMostlyRTL(const vector<BoxChar*>& boxes) {
bool BoxChar::ContainsMostlyRTL(const std::vector<BoxChar*>& boxes) {
int num_rtl = 0, num_ltr = 0;
for (int i = 0; i < boxes.size(); ++i) {
// Convert the unichar to UTF32 representation
@ -240,7 +241,7 @@ bool BoxChar::ContainsMostlyRTL(const vector<BoxChar*>& boxes) {
// Returns true if the text is mostly laid out vertically.
/* static */
bool BoxChar::MostlyVertical(const vector<BoxChar*>& boxes) {
bool BoxChar::MostlyVertical(const std::vector<BoxChar*>& boxes) {
inT64 total_dx = 0, total_dy = 0;
for (int i = 1; i < boxes.size(); ++i) {
if (boxes[i - 1]->box_ != NULL && boxes[i]->box_ != NULL &&
@ -259,7 +260,7 @@ bool BoxChar::MostlyVertical(const vector<BoxChar*>& boxes) {
// Returns the total length of all the strings in the boxes.
/* static */
int BoxChar::TotalByteLength(const vector<BoxChar*>& boxes) {
int BoxChar::TotalByteLength(const std::vector<BoxChar*>& boxes) {
int total_length = 0;
for (int i = 0; i < boxes.size(); ++i) total_length += boxes[i]->ch_.size();
return total_length;
@ -269,7 +270,8 @@ int BoxChar::TotalByteLength(const vector<BoxChar*>& boxes) {
// The rotation is in radians clockwise about the given center.
/* static */
void BoxChar::RotateBoxes(float rotation, int xcenter, int ycenter,
int start_box, int end_box, vector<BoxChar*>* boxes) {
int start_box, int end_box,
std::vector<BoxChar*>* boxes) {
Boxa* orig = boxaCreate(0);
for (int i = start_box; i < end_box; ++i) {
BOX* box = (*boxes)[i]->box_;
@ -289,13 +291,14 @@ void BoxChar::RotateBoxes(float rotation, int xcenter, int ycenter,
const int kMaxLineLength = 1024;
/* static */
void BoxChar::WriteTesseractBoxFile(const string& filename, int height,
const vector<BoxChar*>& boxes) {
const std::vector<BoxChar*>& boxes) {
string output = GetTesseractBoxStr(height, boxes);
File::WriteStringToFileOrDie(output, filename);
}
/* static */
string BoxChar::GetTesseractBoxStr(int height, const vector<BoxChar*>& boxes) {
string BoxChar::GetTesseractBoxStr(int height,
const std::vector<BoxChar*>& boxes) {
string output;
char buffer[kMaxLineLength];
for (int i = 0; i < boxes.size(); ++i) {

View File

@ -80,7 +80,7 @@ class PangoFontInfo {
// If true, returns individual graphemes. Any whitespace characters in the
// original string are also included in the list.
bool CanRenderString(const char* utf8_word, int len,
vector<string>* graphemes) const;
std::vector<string>* graphemes) const;
bool CanRenderString(const char* utf8_word, int len) const;
// Retrieves the x_bearing and x_advance for the given utf8 character in the
@ -169,29 +169,29 @@ class FontUtils {
// best_match is not NULL, the closest matching font is returned there.
static bool IsAvailableFont(const char* font_desc, string* best_match);
// Outputs description names of available fonts.
static const vector<string>& ListAvailableFonts();
static const std::vector<string>& ListAvailableFonts();
// Picks font among available fonts that covers and can render the given word,
// and returns the font description name and the decomposition of the word to
// graphemes. Returns false if no suitable font was found.
static bool SelectFont(const char* utf8_word, const int utf8_len,
string* font_name, vector<string>* graphemes);
string* font_name, std::vector<string>* graphemes);
// Picks font among all_fonts that covers and can render the given word,
// and returns the font description name and the decomposition of the word to
// graphemes. Returns false if no suitable font was found.
static bool SelectFont(const char* utf8_word, const int utf8_len,
const vector<string>& all_fonts,
string* font_name, vector<string>* graphemes);
const std::vector<string>& all_fonts,
string* font_name, std::vector<string>* graphemes);
// Returns a bitmask where the value of true at index 'n' implies that unicode
// value 'n' is renderable by at least one available font.
static void GetAllRenderableCharacters(vector<bool>* unichar_bitmap);
static void GetAllRenderableCharacters(std::vector<bool>* unichar_bitmap);
// Variant of the above function that inspects only the provided font names.
static void GetAllRenderableCharacters(const vector<string>& font_names,
vector<bool>* unichar_bitmap);
static void GetAllRenderableCharacters(const std::vector<string>& font_names,
std::vector<bool>* unichar_bitmap);
static void GetAllRenderableCharacters(const string& font_name,
vector<bool>* unichar_bitmap);
std::vector<bool>* unichar_bitmap);
// NOTE: The following utilities were written to be backward compatible with
// StringRender.
@ -204,7 +204,7 @@ class FontUtils {
// The return string is a list of the acceptable fonts that were used.
static string BestFonts(
const TessHashMap<char32, inT64>& ch_map,
vector<std::pair<const char*, vector<bool> > >* font_flag);
std::vector<std::pair<const char*, std::vector<bool> > >* font_flag);
// FontScore returns the weighted renderability score of the given
// hash map character table in the given font. The unweighted score
@ -213,13 +213,13 @@ class FontUtils {
// corresponding character (in order of iterating ch_map) can be rendered.
static int FontScore(const TessHashMap<char32, inT64>& ch_map,
const string& fontname, int* raw_score,
vector<bool>* ch_flags);
std::vector<bool>* ch_flags);
// PangoFontInfo is reinitialized, so clear the static list of fonts.
static void ReInit();
private:
static vector<string> available_fonts_; // cache list
static std::vector<string> available_fonts_; // cache list
};
} // namespace tesseract

View File

@ -135,7 +135,7 @@ class StringRenderer {
// Get the boxchars of all clusters rendered thus far (or since the last call
// to ClearBoxes()).
const vector<BoxChar*>& GetBoxes() const;
const std::vector<BoxChar*>& GetBoxes() const;
// Get the rendered page bounding boxes of all pages created thus far (or
// since last call to ClearBoxes()).
Boxa* GetPageBoxes() const;
@ -171,8 +171,8 @@ class StringRenderer {
void SetWordUnderlineAttributes(const string& page_text);
// Compute bounding boxes around grapheme clusters.
void ComputeClusterBoxes();
void CorrectBoxPositionsToLayout(vector<BoxChar*>* boxchars);
bool GetClusterStrings(vector<string>* cluster_text);
void CorrectBoxPositionsToLayout(std::vector<BoxChar*>* boxchars);
bool GetClusterStrings(std::vector<string>* cluster_text);
int FindFirstPageBreakOffset(const char* text, int text_length);
PangoFontInfo font_;
@ -204,7 +204,7 @@ class StringRenderer {
int page_;
// Boxes and associated text for all pages rendered with RenderToImage() since
// the last call to ClearBoxes().
vector<BoxChar*> boxchars_;
std::vector<BoxChar*> boxchars_;
int box_padding_;
// Bounding boxes for pages since the last call to ClearBoxes().
Boxa* page_boxes_;