blob: bd6204ba1f941b5cb79cf47d6cd015d4cd69d7fb [file] [log] [blame]
Andreas Hubere46b7be2009-07-14 16:56:47 -07001/*
2 * Copyright (C) 2009 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Andreas Huber63d524f2009-10-19 10:15:44 -070017#include "include/stagefright_string.h"
Andreas Hubere46b7be2009-07-14 16:56:47 -070018
19namespace android {
20
21// static
22string::size_type string::npos = (string::size_type)-1;
23
24string::string() {
25}
26
27string::string(const char *s, size_t length)
28 : mString(s, length) {
29}
30
31string::string(const string &from, size_type start, size_type length)
32 : mString(from.c_str() + start, length) {
33}
34
35string::string(const char *s)
36 : mString(s) {
37}
38
39const char *string::c_str() const {
40 return mString.string();
41}
42
43string::size_type string::size() const {
44 return mString.length();
45}
46
47void string::clear() {
48 mString = String8();
49}
50
51string::size_type string::find(char c) const {
52 char s[2];
53 s[0] = c;
54 s[1] = '\0';
55
56 ssize_t index = mString.find(s);
57
58 return index < 0 ? npos : (size_type)index;
59}
60
61bool string::operator<(const string &other) const {
62 return mString < other.mString;
63}
64
65bool string::operator==(const string &other) const {
66 return mString == other.mString;
67}
68
69string &string::operator+=(char c) {
70 mString.append(&c, 1);
71
72 return *this;
73}
74
75void string::erase(size_t from, size_t length) {
76 String8 s(mString.string(), from);
77 s.append(mString.string() + from + length);
78
79 mString = s;
80}
81
82} // namespace android
83