File: zstring.cpp

package info (click to toggle)
mozzemberek 0.1.5-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 168 kB
  • ctags: 111
  • sloc: cpp: 686; makefile: 111
file content (80 lines) | stat: -rw-r--r-- 1,470 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*
  Copyright (c) 2004, TUBITAK/UEKAE

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.

  Please read the COPYING file.
*/

#include <iostream>
#include <sstream>

#include "zstring.h"

ZString::ZString(const string& str, int offset )
    : _str(str), _offset(offset),
      _status(Z_UNKNOWN)
{}


/* set */
void ZString::setStatus( enum Z_CHECK_RESULT status )
{
    _status = status;
}

void ZString::setSuggestions( const vector<string>& suggestions)
{
    _suggestions = suggestions;
}

void ZString::addSuggestion( const string& suggestion )
{
    _suggestions.push_back( suggestion );
}

/* get */
int ZString::offset() const
{
    return _offset;
}

const string& ZString::str() const
{
    return _str;
}

enum Z_CHECK_RESULT ZString::status() const
{
    return _status;
}

int ZString::suggestionCount() const
{
    return _suggestions.size();
}

const string ZString::suggestionString() const
{
    stringstream sstr;

    vector<string>::const_iterator it = _suggestions.begin();
    int len = _suggestions.size();
    for (int i=0 ; i < len ; ++i, ++it ) {
        sstr << *it;
        if ( i < len-1 ) {
            sstr << ", ";
        }
    }

    return sstr.str();
}

const vector<string>& ZString::suggestions() const
{
    return _suggestions;
}