- Visual C++源码
- Visual Basic源码
- C++ Builder源码
- Java源码
- Delphi源码
- C/C++源码
- PHP源码
- Perl源码
- Python源码
- Asm源码
- Pascal源码
- Borland C++源码
- Others源码
- SQL源码
- VBScript源码
- JavaScript源码
- ASP/ASPX源码
- C#源码
- Flash/ActionScript源码
- matlab源码
- PowerBuilder源码
- LabView源码
- Flex源码
- MathCAD源码
- VBA源码
- IDL源码
- Lisp/Scheme源码
- VHDL源码
- Objective-C源码
- Fortran源码
- tcl/tk源码
- QT源码
- /* Copyright (C) 1998, 1999 State University of New York at Stony Brook
- Author: Andrew V. Shuvalov ( andrew@ecsl.cs.sunysb.edu )
- Software license is located in file "COPYING"
- */
- #ifndef _string_of_text_h_
- #define _string_of_text_h_
- #include <vector>
- #include <string>
- #include <time.h>
- /**
- */
- class StringOfText {
- string text;
- struct tm _time;
- /** just the same time as time_t */
- time_t _time_t;
- public:
- StringOfText() {}
- StringOfText( const StringOfText &s ) {
- *this = s;
- }
- const StringOfText &operator =( const StringOfText &s ) {
- if( this != &s ) {
- text = s.text;
- _time = s._time;
- _time_t = s._time_t;
- }
- return *this;
- }
- void set( const string &t, const struct tm &tim ) {
- text = t;
- _time = tim;
- _time_t = mktime( ( struct tm *) &tim );
- }
- const string &get_text() const { return text; }
- const struct tm &get_time() const { return _time; }
- time_t get_time_t() const { return _time_t; }
- };
- /** item for list of all places where the word occured
- */
- class WordOccurence {
- unsigned int movieId;
- unsigned int textLine;
- unsigned int posInLine;
- public:
- WordOccurence() {}
- WordOccurence( unsigned int mId, unsigned int tl, unsigned int pil )
- : movieId( mId ), textLine( tl ), posInLine( pil ) {}
- WordOccurence( const WordOccurence &w ) {
- *this = w;
- }
- const WordOccurence & operator =( const WordOccurence &w ) {
- if( this != &w ) {
- movieId = w.movieId;
- textLine = w.textLine;
- posInLine = w.posInLine;
- }
- return *this;
- }
- /** sometimes we need to sort them */
- bool operator <( const WordOccurence &w ) const
- {
- if( movieId < w.movieId )
- return true;
- if( movieId > w.movieId )
- return false;
- if( textLine < w.textLine )
- return true;
- if( textLine > w.textLine )
- return false;
- if( posInLine < w.posInLine )
- return true;
- if( posInLine > w.posInLine )
- return false;
- return true;
- }
- bool is_near( const WordOccurence &w ) const
- {
- if( movieId != w.movieId )
- return false;
- if( textLine + 5 < w.textLine )
- return false;
- if( textLine - 5 > w.textLine )
- return false;
- return true;
- }
- unsigned int get_movie_id() const { return movieId; }
- unsigned int get_text_line() const { return textLine; }
- };
- /** list of word occurencies */
- typedef vector< WordOccurence > WordOccurencesT;
- #endif // _string_of_text_h_