text::Position Class Reference

Position type for text plugin. More...

#include <text_base_types.h>

Public Member Functions

 Position (unsigned int paragraph_index=0, unsigned int offset=0)
 Constructors and destructors.
 Position (const std::string &from_string)
 Position (const Position &r)
Positionoperator= (const Position &r)
 ~Position ()
std::string to_string () const
 Convert internel position type to string. The string-based position can be used as anchors.

Data Fields

unsigned int paragraph
unsigned int offset

Friends

bool operator== (const Position &l, const Position &r)
bool operator!= (const Position &l, const Position &r)
bool operator< (const Position &l, const Position &r)
bool operator> (const Position &l, const Position &r)
bool operator<= (const Position &l, const Position &r)
bool operator>= (const Position &l, const Position &r)

Detailed Description

Position type for text plugin.

Definition at line 60 of file text_base_types.h.


Constructor & Destructor Documentation

text::Position::Position ( unsigned int  paragraph_index = 0,
unsigned int  offset = 0 
) [explicit]

Constructors and destructors.

Definition at line 33 of file text_base_types.cpp.

00034 : paragraph(paragraph_index),
00035   offset(offset)
00036 {
00037 }

text::Position::Position ( const std::string &  from_string  )  [explicit]

Definition at line 39 of file text_base_types.cpp.

References ERRORPRINTF, offset, and paragraph.

00040 {
00041     if (from_string == "")
00042     {
00043         paragraph = offset = 0;
00044     }
00045     else
00046     {
00047         if (2 != sscanf(from_string.c_str(), "txt://%d:%d", &paragraph, &offset))
00048         {
00049             // Invalid anchor.
00050             ERRORPRINTF("Invalid text anchor detected!");
00051             paragraph = offset = 0;
00052         }
00053     }
00054 }

text::Position::Position ( const Position r  )  [inline]

Definition at line 67 of file text_base_types.h.

References offset, and paragraph.

00068     {
00069         if (this != &r)
00070         {
00071             this->paragraph = r.paragraph;
00072             this->offset    = r.offset;
00073         }
00074     }

text::Position::~Position (  ) 

Definition at line 56 of file text_base_types.cpp.

00057 {
00058 }


Member Function Documentation

Position& text::Position::operator= ( const Position r  )  [inline]

Definition at line 76 of file text_base_types.h.

References offset, and paragraph.

00077     {
00078         if (this != &r)
00079         {
00080             this->paragraph = r.paragraph;
00081             this->offset    = r.offset;
00082         }
00083         return *this;
00084     }

std::string text::Position::to_string (  )  const

Convert internel position type to string. The string-based position can be used as anchors.

Definition at line 60 of file text_base_types.cpp.

References offset, and paragraph.

Referenced by text::PluginViewImpl::get_anchor_from_coordinates_impl(), text::TextModel::get_words_from_range(), and text::RangeImpl::RangeImpl().

00061 {
00062     char buf[32];
00063     g_snprintf(buf, 32, "txt://%d:%d", paragraph, offset);
00064     return std::string(buf);
00065 }

Here is the caller graph for this function:


Friends And Related Function Documentation

bool operator!= ( const Position l,
const Position r 
) [friend]

Definition at line 91 of file text_base_types.h.

00092     {
00093         return (l.paragraph != r.paragraph) || (l.offset != r.offset);
00094     }

bool operator< ( const Position l,
const Position r 
) [friend]

Definition at line 96 of file text_base_types.h.

00097     {
00098         return (l.paragraph < r.paragraph) ||
00099                (l.paragraph == r.paragraph && l.offset < r.offset);
00100     }

bool operator<= ( const Position l,
const Position r 
) [friend]

Definition at line 108 of file text_base_types.h.

00109     {
00110         return (l.paragraph < r.paragraph) ||
00111                (l.paragraph == r.paragraph && l.offset <= r.offset);
00112     }

bool operator== ( const Position l,
const Position r 
) [friend]

Definition at line 86 of file text_base_types.h.

00087     {
00088         return (l.paragraph == r.paragraph) && (l.offset == r.offset);
00089     }

bool operator> ( const Position l,
const Position r 
) [friend]

Definition at line 102 of file text_base_types.h.

00103     {
00104         return (l.paragraph > r.paragraph) ||
00105                (l.paragraph == r.paragraph && l.offset > r.offset);
00106     }

bool operator>= ( const Position l,
const Position r 
) [friend]

Definition at line 114 of file text_base_types.h.

00115     {
00116         return (l.paragraph > r.paragraph) ||
00117                (l.paragraph == r.paragraph && l.offset >= r.offset);
00118     }


Field Documentation

unsigned int text::Position::offset

The documentation for this class was generated from the following files:
Generated by  doxygen 1.6.2-20100208