remove string8, replace with std::string from stlport
also remove unnecessary ALOGEs from header
Change-Id: I52953f5edc47fece953fbc3f91c732fcbbfe2d04
(cherry picked from commit f9b6346e62848565a4b45fd1123d41df7634bfd5)
diff --git a/cpp/Element.cpp b/cpp/Element.cpp
index d4b2c66..35f081d 100644
--- a/cpp/Element.cpp
+++ b/cpp/Element.cpp
@@ -39,7 +39,7 @@
if (index >= mVisibleElementMap.size()) {
mRS->throwError("Illegal sub-element index");
}
- return mElementNames[mVisibleElementMap[index]].string();
+ return mElementNames[mVisibleElementMap[index]].c_str();
}
size_t Element::getSubElementArraySize(uint32_t index) {
@@ -135,14 +135,14 @@
size_t fieldCount = mElementNames.size();
// Find out how many elements are not padding
for (size_t ct = 0; ct < fieldCount; ct ++) {
- if (mElementNames[ct].string()[0] != '#') {
+ if (mElementNames[ct].c_str()[0] != '#') {
noPaddingFieldCount ++;
}
}
// Make a map that points us at non-padding elements
for (size_t ct = 0; ct < fieldCount; ct ++) {
- if (mElementNames[ct].string()[0] != '#') {
+ if (mElementNames[ct].c_str()[0] != '#') {
mVisibleElementMap.push_back((uint32_t)ct);
}
}
@@ -150,7 +150,7 @@
Element::Element(void *id, android::RSC::sp<RS> rs,
std::vector<android::RSC::sp<Element> > &elements,
- std::vector<android::String8> &elementNames,
+ std::vector<std::string> &elementNames,
std::vector<uint32_t> &arraySizes) : BaseObj(id, rs) {
mSizeBytes = 0;
mVectorSize = 1;
@@ -337,11 +337,11 @@
mSkipPadding = false;
}
-void Element::Builder::add(android::RSC::sp</*const*/ Element>e, android::String8 &name, uint32_t arraySize) {
+void Element::Builder::add(android::RSC::sp</*const*/ Element>e, std::string &name, uint32_t arraySize) {
// Skip padding fields after a vector 3 type.
if (mSkipPadding) {
const char *s1 = "#padding_";
- const char *s2 = name.string();
+ const char *s2 = name.c_str();
size_t len = strlen(s1);
if (strlen(s2) >= len) {
if (!memcmp(s1, s2, len)) {
@@ -369,7 +369,7 @@
size_t* sizeArray = (size_t*)calloc(fieldCount, sizeof(size_t));
for (size_t ct = 0; ct < fieldCount; ct++) {
- nameArray[ct] = mElementNames[ct].string();
+ nameArray[ct] = mElementNames[ct].c_str();
elementArray[ct] = mElements[ct].get();
sizeArray[ct] = mElementNames[ct].length();
}
diff --git a/cpp/rsCppStructs.h b/cpp/rsCppStructs.h
index b85499c..01d0d20 100644
--- a/cpp/rsCppStructs.h
+++ b/cpp/rsCppStructs.h
@@ -23,6 +23,7 @@
#include "rsDispatch.h"
#include <vector>
+#include <string>
// Every row in an RS allocation is guaranteed to be aligned by this amount
// Every row in a user-backed allocation must be aligned by this amount
@@ -187,7 +188,7 @@
protected:
void *mID;
sp<RS> mRS;
- String8 mName;
+ std::string mName;
BaseObj(void *id, sp<RS> rs);
void checkValid();
@@ -383,7 +384,7 @@
Element(void *id, sp<RS> rs,
std::vector<sp<Element> > &elements,
- std::vector<android::String8> &elementNames,
+ std::vector<std::string> &elementNames,
std::vector<uint32_t> &arraySizes);
Element(void *id, sp<RS> rs, RsDataType dt, RsDataKind dk, bool norm, uint32_t size);
Element(sp<RS> rs);
@@ -394,14 +395,14 @@
private:
sp<RS> mRS;
std::vector<sp<Element> > mElements;
- std::vector<android::String8> mElementNames;
+ std::vector<std::string> mElementNames;
std::vector<uint32_t> mArraySizes;
bool mSkipPadding;
public:
Builder(sp<RS> rs);
~Builder();
- void add(sp<Element> e, android::String8 &name, uint32_t arraySize = 1);
+ void add(sp<Element> e, std::string &name, uint32_t arraySize = 1);
sp<const Element> create();
};
@@ -409,7 +410,7 @@
void updateVisibleSubElements();
std::vector<sp<Element> > mElements;
- std::vector<android::String8> mElementNames;
+ std::vector<std::string> mElementNames;
std::vector<uint32_t> mArraySizes;
std::vector<uint32_t> mVisibleElementMap;
std::vector<uint32_t> mOffsetInBytes;
@@ -439,7 +440,7 @@
void align(size_t v) {
if ((v & (v - 1)) != 0) {
- ALOGE("Non-power-of-two alignment: %zu", v);
+ // ALOGE("Non-power-of-two alignment: %zu", v);
return;
}
@@ -454,7 +455,7 @@
void reset(size_t i) {
if (i >= mLen) {
- ALOGE("Out of bounds: i (%zu) >= len (%zu)", i, mLen);
+ // ALOGE("Out of bounds: i (%zu) >= len (%zu)", i, mLen);
return;
}
mPos = i;
@@ -463,7 +464,7 @@
void skip(size_t i) {
size_t res = mPos + i;
if (res > mLen) {
- ALOGE("Exceeded buffer length: i (%zu) > len (%zu)", i, mLen);
+ // ALOGE("Exceeded buffer length: i (%zu) > len (%zu)", i, mLen);
return;
}
mPos = res;