Orxonox  0.0.5 Codename: Arcturus
ArgumentCompletionListElement.h
Go to the documentation of this file.
1 /*
2  * ORXONOX - the hottest 3D action shooter ever to exist
3  * > www.orxonox.net <
4  *
5  *
6  * License notice:
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21  *
22  * Author:
23  * Fabian 'x3n' Landau
24  * Co-authors:
25  * ...
26  *
27  */
28 
35 #ifndef _ArgumentCompletionListElement_H__
36 #define _ArgumentCompletionListElement_H__
37 
38 #include "core/CorePrereqs.h"
39 
40 #include <list>
41 #include <string>
42 
43 namespace orxonox
44 {
45  const int ACL_MODE_NORMAL = 1;
46  const int ACL_MODE_COMPARABLE = 2;
47  const int ACL_MODE_DISPLAY = 4;
48 
49  typedef std::list<ArgumentCompletionListElement> ArgumentCompletionList;
50 
67  {
68  public:
70  ArgumentCompletionListElement(const std::string& normalcase) : mode_(ACL_MODE_NORMAL), normal_(normalcase) {}
72  ArgumentCompletionListElement(const std::string& normalcase, const std::string& lowercase) : mode_(ACL_MODE_NORMAL | ACL_MODE_COMPARABLE), normal_(normalcase), comparable_(lowercase) {}
74  ArgumentCompletionListElement(const std::string& normalcase, const std::string& lowercase, const std::string& display) : mode_(ACL_MODE_NORMAL | ACL_MODE_COMPARABLE | ACL_MODE_DISPLAY), normal_(normalcase), comparable_(lowercase), display_(display) {}
75 
77  const std::string& getString() const
78  { return this->normal_; }
80  const std::string& getComparable() const
81  { return (this->mode_ & ACL_MODE_COMPARABLE) ? this->comparable_ : this->normal_; }
83  const std::string& getDisplay() const
84  { return (this->mode_ & ACL_MODE_DISPLAY) ? this->display_ : this->normal_; }
85 
87  bool hasComparable() const
88  { return (this->mode_ & ACL_MODE_COMPARABLE); }
90  bool hasDisplay() const
91  { return (this->mode_ & ACL_MODE_DISPLAY); }
92 
94  bool operator<(const ArgumentCompletionListElement& other) const
95  { return (this->getComparable() < other.getComparable()); }
96 
97  private:
98  unsigned char mode_;
102  };
103 }
104 
105 #endif /* _ArgumentCompletionListElement_H__ */
const int ACL_MODE_NORMAL
A flag, used if there&#39;s a normal string.
Definition: ArgumentCompletionListElement.h:45
ArgumentCompletionListElement(const std::string &normalcase, const std::string &lowercase, const std::string &display)
Constructor: Normal, comparable, and display are all different strings.
Definition: ArgumentCompletionListElement.h:74
Shared library macros, enums, constants and forward declarations for the core library ...
::std::string string
Definition: gtest-port.h:756
bool operator<(const ArgumentCompletionListElement &other) const
Overloaded operator for usage in maps and sets.
Definition: ArgumentCompletionListElement.h:94
unsigned char mode_
The flags.
Definition: ArgumentCompletionListElement.h:98
ArgumentCompletionListElement(const std::string &normalcase)
Constructor: Normal, comparable, and display string are all the same.
Definition: ArgumentCompletionListElement.h:70
const std::string & getDisplay() const
Returns the display string which is used in the displayed list of possible arguments.
Definition: ArgumentCompletionListElement.h:83
const std::string & getComparable() const
Returns the comparable string which is used to compare arguments and user input.
Definition: ArgumentCompletionListElement.h:80
std::string display_
The string to display.
Definition: ArgumentCompletionListElement.h:101
const int ACL_MODE_COMPARABLE
A flag, used if there&#39;s a different string used to compare.
Definition: ArgumentCompletionListElement.h:46
const int ACL_MODE_DISPLAY
A flag, used if there&#39;s a different string used to be displayed.
Definition: ArgumentCompletionListElement.h:47
Die Wagnis Klasse hat die folgenden Aufgaben:
Definition: ApplicationPaths.cc:66
#define _CoreExport
Definition: CorePrereqs.h:61
std::string comparable_
The comparable (usually lowercase) string.
Definition: ArgumentCompletionListElement.h:100
void lowercase(std::string *str)
Replaces each char between A and Z with its lowercase equivalent.
Definition: StringUtils.cc:336
std::list< ArgumentCompletionListElement > ArgumentCompletionList
Definition: ArgumentCompletionListElement.h:49
ArgumentCompletionListElement(const std::string &normalcase, const std::string &lowercase)
Constructor: Normal and display string are the same, a different (usually lowercase) string is used f...
Definition: ArgumentCompletionListElement.h:72
std::string normal_
The normal string.
Definition: ArgumentCompletionListElement.h:99
bool hasDisplay() const
Returns true if there&#39;s a different string to display.
Definition: ArgumentCompletionListElement.h:90
bool hasComparable() const
Returns true if there&#39;s a different string for comparison.
Definition: ArgumentCompletionListElement.h:87
This class is used in argument completion lists and contains up to three different strings...
Definition: ArgumentCompletionListElement.h:66
const std::string & getString() const
Returns the normal string which is used as the actual argument.
Definition: ArgumentCompletionListElement.h:77