btrfs: Attempt to fix GCC2 build.
[haiku.git] / src / apps / aboutsystem / Utilities.h
blob634f9e8be0559d0fc4ea33ff731f082d94a9a8ba
1 /*
2 * Copyright 2008-2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT license.
4 */
5 #ifndef UTILITIES_H
6 #define UTILITIES_H
8 #include <stdarg.h>
10 #include <InterfaceDefs.h>
11 #include <String.h>
14 class BMessage;
17 #define COPYRIGHT_STRING "Copyright " B_UTF8_COPYRIGHT " "
20 BString trim_string(const char* string, size_t len);
21 // Removes leading and trailing white space and replaces all sequences
22 // of white space by a single space.
24 void parse_named_url(const BString& namedURL, BString& name, BString& url);
27 class StringVector {
28 public:
29 StringVector();
30 explicit StringVector(const char* string,...);
31 // NULL terminated list
32 StringVector(const BMessage& strings,
33 const char* fieldName);
34 // all elements of the given field
35 StringVector(const StringVector& other);
36 ~StringVector();
38 bool IsEmpty() const { return fCount == 0; }
39 int32 CountStrings() const { return fCount; }
40 const char* StringAt(int32 index) const;
42 void SetTo(const char* string,...);
43 void SetTo(const char* string, va_list strings);
44 void SetTo(const BMessage& strings,
45 const char* fieldName,
46 const char* prefix = NULL);
47 void Unset();
50 private:
51 BString* fStrings;
52 int32 fCount;
56 class PackageCredit {
57 public:
58 PackageCredit(const char* packageName);
59 PackageCredit(
60 const BMessage& packageDescription);
61 PackageCredit(const PackageCredit& other);
62 ~PackageCredit();
64 bool IsValid() const;
66 bool IsBetterThan(const PackageCredit& other) const;
68 PackageCredit& SetCopyrights(const char* copyright,...);
69 PackageCredit& SetCopyright(const char* copyright);
70 PackageCredit& SetLicenses(const char* license,...);
71 PackageCredit& SetLicense(const char* license);
72 PackageCredit& SetSources(const char* source,...);
73 PackageCredit& SetSource(const char* source);
74 PackageCredit& SetURL(const char* url);
76 const char* PackageName() const;
78 const StringVector& Copyrights() const;
79 int32 CountCopyrights() const;
80 const char* CopyrightAt(int32 index) const;
82 const StringVector& Licenses() const;
83 int32 CountLicenses() const;
84 const char* LicenseAt(int32 index) const;
86 const StringVector& Sources() const;
87 int32 CountSources() const;
88 const char* SourceAt(int32 index) const;
90 const char* URL() const;
92 static bool NameLessInsensitive(const PackageCredit* a,
93 const PackageCredit* b);
95 private:
96 int _MaxCopyrightYear() const;
98 private:
99 BString fPackageName;
100 StringVector fCopyrights;
101 StringVector fLicenses;
102 StringVector fSources;
103 BString fURL;
107 #endif // UTILITIES_H