NCBI C++ ToolKit
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 
35 
37 
39  : m_History(history), m_CurPos(m_History.end()),
40  m_TaxonTextCompleter (new CTaxonTextCompleter()),
41  m_HaveTaxons(false)
42 {
43 }
44 
46 {
47  delete m_TaxonTextCompleter;
48 }
49 
50 
52 {
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 
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 
#define false
Definition: bool.h:36
list< string >::const_iterator m_CurPos
CTaxonTextCompleter * m_TaxonTextCompleter
virtual bool Start(const wxString &prefix)
CAssemblyTermCompleter(const list< string > &history)
virtual bool Start(const wxString &prefix)
virtual wxString GetNext()
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
bool AStrEquiv(const Arg1 &x, const Arg2 &y, Pred pr)
Check equivalence of arguments using predicate.
Definition: ncbistr.hpp:5036
static const char * prefix[]
Definition: pcregrep.c:405
string ToStdString(const wxString &s)
Definition: wx_utils.hpp:161
Modified on Sat Dec 02 09:20:55 2023 by modify_doxy.py rev. 669887