]> git.saurik.com Git - apt.git/blame_incremental - apt-pkg/contrib/strutl.h
Clean support
[apt.git] / apt-pkg / contrib / strutl.h
... / ...
CommitLineData
1// -*- mode: cpp; mode: fold -*-
2// Description /*{{{*/
3// $Id: strutl.h,v 1.12 1999/02/01 08:11:57 jgg Exp $
4/* ######################################################################
5
6 String Util - These are some usefull string functions
7
8 _strstrip is a function to remove whitespace from the front and end
9 of a string.
10
11 This source is placed in the Public Domain, do with it what you will
12 It was originally written by Jason Gunthorpe <jgg@gpu.srv.ualberta.ca>
13
14 ##################################################################### */
15 /*}}}*/
16#ifndef STRUTL_H
17#define STRUTL_H
18
19#ifdef __GNUG__
20#pragma interface "apt-pkg/strutl.h"
21#endif
22
23#include <stdlib.h>
24#include <string>
25#include <vector>
26#include <time.h>
27
28char *_strstrip(char *String);
29char *_strtabexpand(char *String,size_t Len);
30bool ParseQuoteWord(const char *&String,string &Res);
31bool ParseCWord(const char *String,string &Res);
32string QuoteString(string Str,const char *Bad);
33string DeQuoteString(string Str);
34string SizeToStr(double Bytes);
35string TimeToStr(unsigned long Sec);
36string SubstVar(string Str,string Subst,string Contents);
37string Base64Encode(string Str);
38string URItoFileName(string URI);
39string TimeRFC1123(time_t Date);
40bool StrToTime(string Val,time_t &Result);
41string LookupTag(string Message,const char *Tag,const char *Default = 0);
42int StringToBool(string Text,int Default = -1);
43bool ReadMessages(int Fd, vector<string> &List);
44
45int stringcmp(const char *A,const char *AEnd,const char *B,const char *BEnd);
46inline int stringcmp(const char *A,const char *AEnd,const char *B) {return stringcmp(A,AEnd,B,B+strlen(B));};
47inline int stringcmp(string A,const char *B) {return stringcmp(A.begin(),A.end(),B,B+strlen(B));};
48int stringcasecmp(const char *A,const char *AEnd,const char *B,const char *BEnd);
49inline int stringcasecmp(const char *A,const char *AEnd,const char *B) {return stringcasecmp(A,AEnd,B,B+strlen(B));};
50inline int stringcasecmp(string A,const char *B) {return stringcasecmp(A.begin(),A.end(),B,B+strlen(B));};
51
52class URI
53{
54 void CopyFrom(string From);
55
56 public:
57
58 string Access;
59 string User;
60 string Password;
61 string Host;
62 string Path;
63 unsigned int Port;
64
65 operator string();
66 inline operator =(string From) {CopyFrom(From);};
67 inline bool empty() {return Access.empty();};
68
69 URI(string Path) {CopyFrom(Path);};
70 URI() : Port(0) {};
71};
72
73#endif