NCBI C++ ToolKit
src
gui
widgets
loaders
assembly_term_completer.cpp
Go to the documentation of this file.
Go to the SVN repository for this file.
1
/* $Id: assembly_term_completer.cpp 28562 2013-08-02 15:03:07Z katargir $
2
* ===========================================================================
3
*
4
* PUBLIC DOMAIN NOTICE
5
* National Center for Biotechnology Information
6
*
7
* This software/database is a "United States Government Work" under the
8
* terms of the United States Copyright Act. It was written as part of
9
* the author's official duties as a United States Government employee and
10
* thus cannot be copyrighted. This software/database is freely available
11
* to the public for use. The National Library of Medicine and the U.S.
12
* Government have not placed any restriction on its use or reproduction.
13
*
14
* Although all reasonable efforts have been taken to ensure the accuracy
15
* and reliability of the software and data, the NLM and the U.S.
16
* Government do not and cannot warrant the performance or results that
17
* may be obtained by using this software or data. The NLM and the U.S.
18
* Government disclaim all warranties, express or implied, including
19
* warranties of performance, merchantability or fitness for any particular
20
* purpose.
21
*
22
* Please cite the author in any work or product based on this material.
23
*
24
* ===========================================================================
25
*
26
* Authors: Roman Katargin
27
*
28
*/
29
30
#include <
ncbi_pch.hpp
>
31
32
#include <
gui/widgets/loaders/assembly_term_completer.hpp
>
33
#include <
gui/widgets/wx/taxon_text_completer.hpp
>
34
#include <
gui/widgets/wx/wx_utils.hpp
>
35
36
BEGIN_NCBI_SCOPE
37
38
CAssemblyTermCompleter::CAssemblyTermCompleter
(
const
list<string>& history)
39
: m_History(history), m_CurPos(m_History.end()),
40
m_TaxonTextCompleter (new
CTaxonTextCompleter
()),
41
m_HaveTaxons(
false
)
42
{
43
}
44
45
CAssemblyTermCompleter::~CAssemblyTermCompleter
()
46
{
47
delete
m_TaxonTextCompleter
;
48
}
49
50
51
bool
CAssemblyTermCompleter::Start
(
const
wxString&
prefix
)
52
{
53
m_Prefix
=
ToStdString
(
prefix
);
54
m_HaveTaxons
=
m_TaxonTextCompleter
->
Start
(
prefix
);
55
m_CurPos
=
m_History
.begin();
56
57
if
(
m_Prefix
.empty()) {
58
return
m_History
.size() > 0 ||
m_HaveTaxons
;
59
}
60
61
size_t
length =
m_Prefix
.length();
62
while
(
m_CurPos
!=
m_History
.end()) {
63
if
(
m_CurPos
->length() >= length &&
64
AStrEquiv
(
m_CurPos
->substr(0, length),
m_Prefix
,
PNocase
())) {
65
return
true
;
66
}
67
++
m_CurPos
;
68
}
69
70
return
m_HaveTaxons
;
71
}
72
73
wxString
CAssemblyTermCompleter::GetNext
()
74
{
75
size_t
length =
m_Prefix
.length();
76
while
(
m_CurPos
!=
m_History
.end()) {
77
if
(
m_CurPos
->length() >= length &&
78
AStrEquiv
(
m_CurPos
->substr(0, length),
m_Prefix
,
PNocase
())) {
79
return
*
m_CurPos
++;
80
}
81
++
m_CurPos
;
82
}
83
84
return
m_HaveTaxons
?
m_TaxonTextCompleter
->
GetNext
() : wxString();
85
}
86
87
END_NCBI_SCOPE
assembly_term_completer.hpp
false
#define false
Definition:
bool.h:36
CAssemblyTermCompleter::m_CurPos
list< string >::const_iterator m_CurPos
Definition:
assembly_term_completer.hpp:66
CAssemblyTermCompleter::m_Prefix
string m_Prefix
Definition:
assembly_term_completer.hpp:64
CAssemblyTermCompleter::m_TaxonTextCompleter
CTaxonTextCompleter * m_TaxonTextCompleter
Definition:
assembly_term_completer.hpp:67
CAssemblyTermCompleter::m_History
list< string > m_History
Definition:
assembly_term_completer.hpp:65
CAssemblyTermCompleter::GetNext
virtual wxString GetNext()
Definition:
assembly_term_completer.cpp:73
CAssemblyTermCompleter::m_HaveTaxons
bool m_HaveTaxons
Definition:
assembly_term_completer.hpp:68
CAssemblyTermCompleter::Start
virtual bool Start(const wxString &prefix)
Definition:
assembly_term_completer.cpp:51
CAssemblyTermCompleter::~CAssemblyTermCompleter
~CAssemblyTermCompleter()
Definition:
assembly_term_completer.cpp:45
CAssemblyTermCompleter::CAssemblyTermCompleter
CAssemblyTermCompleter(const list< string > &history)
Definition:
assembly_term_completer.cpp:38
CTaxonTextCompleter
Definition:
taxon_text_completer.hpp:50
CTaxonTextCompleter::Start
virtual bool Start(const wxString &prefix)
Definition:
taxon_text_completer.cpp:65
CTaxonTextCompleter::GetNext
virtual wxString GetNext()
Definition:
taxon_text_completer.cpp:81
END_NCBI_SCOPE
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition:
ncbistl.hpp:103
BEGIN_NCBI_SCOPE
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition:
ncbistl.hpp:100
AStrEquiv
bool AStrEquiv(const Arg1 &x, const Arg2 &y, Pred pr)
Check equivalence of arguments using predicate.
Definition:
ncbistr.hpp:5036
ncbi_pch.hpp
prefix
static const char * prefix[]
Definition:
pcregrep.c:405
PNocase_Generic< string >
taxon_text_completer.hpp
wx_utils.hpp
ToStdString
string ToStdString(const wxString &s)
Definition:
wx_utils.hpp:161
Generated by
1.9.0
Modified on Sat Dec 02 09:20:55 2023 by modify_doxy.py rev. 669887