1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
|
/*
* File: MacString.h
* Summary: Wrapper around an immutable CFString.
* Written by: Jesse Jones (jesjones@mindspring.com)
*
* Change History (most recent first):
*
* <1> 6/04/02 JDJ Created
*/
#ifndef MAC_STRING_H
#define MAC_STRING_H
#if macintosh
#include <CoreFoundation/CFBase.h>
// ============================================================================
// class MacString
//! Wrapper around an immutable CFString.
// ============================================================================
class MacString {
//-----------------------------------
// Initialization/Destruction
//
public:
~MacString();
MacString();
MacString(const char* str);
MacString(const unsigned char* str);
/**< Uses default system encoding. */
MacString(CFStringRef str);
/**< Bumps the ref count. */
MacString(CFMutableStringRef str);
/**< Makes a copy. */
explicit MacString(int value);
MacString(const MacString& str);
MacString& operator=(const MacString& rhs);
//-----------------------------------
// API
//
public:
// ----- Size -----
size_t length() const;
size_t size() const {return this->length();}
bool empty() const {return this->length() == 0;}
// ----- Access -----
void CopyTo(unsigned char* buffer, CFIndex bytes);
operator CFStringRef() const {return mString;}
//-----------------------------------
// Member Data
//
private:
CFStringRef mString;
};
#endif // macintosh
#endif // MAC_STRING_H
|