~ubuntu-branches/ubuntu/breezy/lurker/breezy

« back to all changes in this revision

Viewing changes to libesort/Source.h

  • Committer: Bazaar Package Importer
  • Author(s): Jonas Meurer
  • Date: 2004-09-26 16:27:51 UTC
  • Revision ID: james.westby@ubuntu.com-20040926162751-z1ohcjltv7ojtg6z
Tags: upstream-1.2
ImportĀ upstreamĀ versionĀ 1.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*  $Id: Source.h,v 1.2 2003/04/21 18:25:32 terpstra Exp $
 
2
 *  
 
3
 *  Source.h - Common segment interface
 
4
 *  
 
5
 *  Copyright (C) 2002 - Wesley W. Terpstra
 
6
 *  
 
7
 *  License: GPL
 
8
 *  
 
9
 *  Authors: 'Wesley W. Terpstra' <wesley@terpstra.ca>
 
10
 *  
 
11
 *    This program is free software; you can redistribute it and/or modify
 
12
 *    it under the terms of the GNU General Public License as published by
 
13
 *    the Free Software Foundation; version 2.1.
 
14
 *    
 
15
 *    This program is distributed in the hope that it will be useful,
 
16
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
17
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
18
 *    GNU General Public License for more details.
 
19
 *    
 
20
 *    You should have received a copy of the GNU General Public License
 
21
 *    along with this program; if not, write to the Free Software
 
22
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
23
 */
 
24
 
 
25
#ifndef SOURCE_H
 
26
#define SOURCE_H
 
27
 
 
28
namespace ESort
 
29
{
 
30
 
 
31
/** One of the database fragments.
 
32
 */
 
33
class Source
 
34
{
 
35
 public:
 
36
        virtual ~Source();
 
37
        
 
38
        /** The tail of the returned key.
 
39
         *  The length is for the whole key.
 
40
         *  The tail includes only what is not compressed.
 
41
         *  -- these are not initialized till first call of advance
 
42
         *
 
43
         * The tail MUST be unsigned. Why? Because std::string compares
 
44
         * as though it were unsigned. ie: '\0x7f' < '\0x80' even though
 
45
         * if it were really lexicographical compare it wouldn't.
 
46
         */
 
47
        const unsigned char*    tail;
 
48
        unsigned long           length;
 
49
        unsigned int            dup;    // amount in common with last
 
50
        
 
51
        /** Advance to the next key in the source.
 
52
         *  -1 on error, errno = 0 -> eof.
 
53
         */
 
54
        virtual int advance() = 0;
 
55
};
 
56
 
 
57
}
 
58
 
 
59
#endif