VirtualBox

source: vbox/trunk/src/libs/xpcom18a4/xpcom/string/public/nsEmbedString.h@ 20554

Last change on this file since 20554 was 1, checked in by vboxsync, 55 years ago

import

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.8 KB
Line 
1/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 *
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
9 *
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
14 *
15 * The Original Code is a small implementation of the nsAString and nsACString.
16 *
17 * The Initial Developer of the Original Code is
18 * Peter Annema <[email protected]>.
19 *
20 * Portions created by the Initial Developer are Copyright (C) 2002
21 * the Initial Developer. All Rights Reserved.
22 *
23 * Contributor(s):
24 * Darin Fisher <[email protected]>
25 *
26 * Alternatively, the contents of this file may be used under the terms of
27 * either the GNU General Public License Version 2 or later (the "GPL"), or
28 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29 * in which case the provisions of the GPL or the LGPL are applicable instead
30 * of those above. If you wish to allow use of your version of this file only
31 * under the terms of either the GPL or the LGPL, and not to allow others to
32 * use your version of this file under the terms of the MPL, indicate your
33 * decision by deleting the provisions above and replace them with the notice
34 * and other provisions required by the GPL or the LGPL. If you do not delete
35 * the provisions above, a recipient may use your version of this file under
36 * the terms of any one of the MPL, the GPL or the LGPL.
37 *
38 * ***** END LICENSE BLOCK ***** */
39
40#ifndef nsEmbedString_h___
41#define nsEmbedString_h___
42
43#include "nsStringAPI.h"
44
45class nsEmbedString : public nsStringContainer
46 {
47 public:
48 typedef nsEmbedString self_type;
49 typedef nsAString abstract_string_type;
50
51 nsEmbedString()
52 {
53 NS_StringContainerInit(*this);
54 }
55
56 nsEmbedString(const self_type& aString)
57 {
58 NS_StringContainerInit(*this);
59 NS_StringCopy(*this, aString);
60 }
61
62 explicit
63 nsEmbedString(const abstract_string_type& aReadable)
64 {
65 NS_StringContainerInit(*this);
66 NS_StringCopy(*this, aReadable);
67 }
68
69 explicit
70 nsEmbedString(const char_type* aData, size_type aLength = PR_UINT32_MAX)
71 {
72 NS_StringContainerInit(*this);
73 NS_StringSetData(*this, aData, aLength);
74 }
75
76 ~nsEmbedString()
77 {
78 NS_StringContainerFinish(*this);
79 }
80
81 const char_type* get() const
82 {
83 const char_type* data;
84 NS_StringGetData(*this, &data);
85 return data;
86 }
87
88 self_type& operator=(const self_type& aString) { Assign(aString); return *this; }
89 self_type& operator=(const abstract_string_type& aReadable) { Assign(aReadable); return *this; }
90 self_type& operator=(const char_type* aPtr) { Assign(aPtr); return *this; }
91 self_type& operator=(char_type aChar) { Assign(aChar); return *this; }
92 };
93
94class nsEmbedCString : public nsCStringContainer
95 {
96 public:
97 typedef nsEmbedCString self_type;
98 typedef nsACString abstract_string_type;
99
100 nsEmbedCString()
101 {
102 NS_CStringContainerInit(*this);
103 }
104
105 nsEmbedCString(const self_type& aString)
106 {
107 NS_CStringContainerInit(*this);
108 NS_CStringCopy(*this, aString);
109 }
110
111 explicit
112 nsEmbedCString(const abstract_string_type& aReadable)
113 {
114 NS_CStringContainerInit(*this);
115 NS_CStringCopy(*this, aReadable);
116 }
117
118 explicit
119 nsEmbedCString(const char_type* aData, size_type aLength = PR_UINT32_MAX)
120 {
121 NS_CStringContainerInit(*this);
122 NS_CStringSetData(*this, aData, aLength);
123 }
124
125 ~nsEmbedCString()
126 {
127 NS_CStringContainerFinish(*this);
128 }
129
130 const char_type* get() const
131 {
132 const char_type* data;
133 NS_CStringGetData(*this, &data);
134 return data;
135 }
136
137 self_type& operator=(const self_type& aString) { Assign(aString); return *this; }
138 self_type& operator=(const abstract_string_type& aReadable) { Assign(aReadable); return *this; }
139 self_type& operator=(const char_type* aPtr) { Assign(aPtr); return *this; }
140 self_type& operator=(char_type aChar) { Assign(aChar); return *this; }
141 };
142
143#endif // !defined(nsEmbedString_h___)
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette