]>
git.saurik.com Git - apt-legacy.git/blob - apt-pkg/srkstring.h
1 // -*- mode: cpp; mode: fold -*-
3 // $Id: pkgcache.h,v 1.25 2001/07/01 22:28:24 jgg Exp $
4 /* ######################################################################
6 Cache - Structure definitions for the cache file
8 Please see doc/apt-pkg/cache.sgml for a more detailed description of
9 this format. Also be sure to keep that file up-to-date!!
11 Clients should always use the CacheIterators classes for access to the
12 cache. They provide a simple STL-like method for traversing the links
15 See pkgcachegen.h for information about generating cache structures.
17 ##################################################################### */
19 #ifndef PKGLIB_PKGSTRING_H
20 #define PKGLIB_PKGSTRING_H
30 srkString() : Start(NULL
), Size(0) {}
32 srkString(const char *Start
, size_t Size
) : Start(Start
), Size(Size
) {}
33 srkString(const char *Start
, const char *Stop
) : Start(Start
), Size(Stop
- Start
) {}
34 srkString(const std::string
&string
) : Start(string
.c_str()), Size(string
.size()) {}
36 bool empty() const { return Size
== 0; }
37 void clear() { Start
= NULL
; Size
= 0; }
39 void assign(const char *nStart
, const char *nStop
) { Start
= nStart
; Size
= nStop
- nStart
; }
40 void assign(const char *nStart
, size_t nSize
) { Start
= nStart
; Size
= nSize
; }
42 size_t length() const { return Size
; }
43 size_t size() const { return Size
; }
45 typedef const char *const_iterator
;
46 const char *begin() const { return Start
; }
47 const char *end() const { return Start
+ Size
; }
49 char operator [](size_t index
) const { return Start
[index
]; }
51 operator std::string() { std::string Str
; Str
.assign(Start
, Size
); return Str
; }
54 int stringcmp(const std::string
&lhs
, const char *rhsb
, const char *rhse
);
55 inline bool operator ==(const std::string
&lhs
, const srkString
&rhs
) {
56 return stringcmp(lhs
, rhs
.begin(), rhs
.end()) == 0;