Hugin trunk 0.1
Loading...
Searching...
No Matches
alphanum.h
Go to the documentation of this file.
1/*
2The Alphanum Algorithm is an improved sorting algorithm for strings
3containing numbers. Instead of sorting numbers in ASCII order like a
4standard sort, this algorithm sorts numbers in numeric order.
5
6The Alphanum Algorithm is discussed at http://www.DaveKoelle.com
7
8This implementation is Copyright (c) 2008 Dirk Jagdmann <doj@cubic.org>.
9It is a cleanroom implementation of the algorithm and not derived by
10other's works. In contrast to the versions written by Dave Koelle this
11source code is distributed with the libpng/zlib license.
12
13This software is provided 'as-is', without any express or implied
14warranty. In no event will the authors be held liable for any damages
15arising from the use of this software.
16
17Permission is granted to anyone to use this software for any purpose,
18including commercial applications, and to alter it and redistribute it
19freely, subject to the following restrictions:
20
21 1. The origin of this software must not be misrepresented; you
22 must not claim that you wrote the original software. If you use
23 this software in a product, an acknowledgment in the product
24 documentation would be appreciated but is not required.
25
26 2. Altered source versions must be plainly marked as such, and
27 must not be misrepresented as being the original software.
28
29 3. This notice may not be removed or altered from any source
30 distribution. */
31
32/* $Header: /code/doj/alphanum.hpp,v 1.3 2008/01/28 23:06:47 doj Exp $
33
34 slightly modified version, the main function is unaltered, but the
35 interface definitions are changed to better suit hugins needs
36*/
37
38#ifndef ALPHANUM__HPP
39#define ALPHANUM__HPP
40
41#include <hugin_shared.h>
42#include <string>
43
44// TODO: make comparison with hexadecimal numbers. Extend the alphanum_comp() function by traits to choose between decimal and hexadecimal.
45
46namespace doj
47{
48
56IMPEX int alphanum_comp(const std::string& l, const std::string& r);
57IMPEX int alphanum_comp(const char* l, const char* r);
58
60
66{
67 bool operator()(const std::string& left, const std::string& right) const;
68};
69
70}
71
72#endif
#define IMPEX
int alphanum_comp(const std::string &l, const std::string &r)
Compare l and r with the same semantics as strcmp(), but with the "Alphanum Algorithm" which produces...
Definition alphanum.cpp:119
Functor class to compare two objects with the "Alphanum Algorithm".
Definition alphanum.h:66