]>
git.saurik.com Git - apt.git/blob - apt-pkg/contrib/strutl.h
1 // -*- mode: cpp; mode: fold -*-
3 // $Id: strutl.h,v 1.10 1998/11/04 07:11:14 jgg Exp $
4 /* ######################################################################
6 String Util - These are some usefull string functions
8 _strstrip is a function to remove whitespace from the front and end
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>
14 ##################################################################### */
20 #pragma interface "strutl.h"
28 char *_strstrip(char *String
);
29 char *_strtabexpand(char *String
,size_t Len
);
30 bool ParseQuoteWord(const char *&String
,string
&Res
);
31 bool ParseCWord(const char *String
,string
&Res
);
32 string
QuoteString(string Str
,const char *Bad
);
33 string
SizeToStr(double Bytes
);
34 string
TimeToStr(unsigned long Sec
);
35 string
SubstVar(string Str
,string Subst
,string Contents
);
36 string
Base64Encode(string Str
);
37 string
URItoFileName(string URI
);
38 string
TimeRFC1123(time_t Date
);
39 bool StrToTime(string Val
,time_t &Result
);
40 string
LookupTag(string Message
,const char *Tag
,const char *Default
= 0);
41 int StringToBool(string Text
,int Default
= -1);
42 bool ReadMessages(int Fd
, vector
<string
> &List
);
44 int stringcmp(const char *A
,const char *AEnd
,const char *B
,const char *BEnd
);
45 inline int stringcmp(const char *A
,const char *AEnd
,const char *B
) {return stringcmp(A
,AEnd
,B
,B
+strlen(B
));};
46 inline int stringcmp(string A
,const char *B
) {return stringcmp(A
.begin(),A
.end(),B
,B
+strlen(B
));};
47 int stringcasecmp(const char *A
,const char *AEnd
,const char *B
,const char *BEnd
);
48 inline int stringcasecmp(const char *A
,const char *AEnd
,const char *B
) {return stringcasecmp(A
,AEnd
,B
,B
+strlen(B
));};
49 inline int stringcasecmp(string A
,const char *B
) {return stringcasecmp(A
.begin(),A
.end(),B
,B
+strlen(B
));};
53 void CopyFrom(string From
);
65 inline operator =(string From
) {CopyFrom(From
);};
66 inline bool empty() {return Access
.empty();};
68 URI(string Path
) {CopyFrom(Path
);};