*//*--------------------------------------------------------------------*/
#include "deStringUtil.hpp"
+#include "deString.h"
#include <algorithm>
#include <iterator>
return s.str();
}
+bool beginsWith (const std::string& s, const std::string& prefix)
+{
+ return deStringBeginsWith(s.c_str(), prefix.c_str());
+}
+
+bool endsWith (const std::string& s, const std::string& suffix)
+{
+ if (suffix.length() > s.length())
+ return false;
+ else
+ {
+ const std::string::size_type offset = s.length() - suffix.length();
+ return s.find(suffix, offset) == offset;
+ }
+}
+
char toUpper (char c)
{
return std::toupper(c, std::locale::classic());
DE_TEST_ASSERT(floatToString(4, 1) == "4.0");
+ DE_TEST_ASSERT(beginsWith("foobar", "foobar"));
+ DE_TEST_ASSERT(beginsWith("foobar", "foo"));
+ DE_TEST_ASSERT(beginsWith("foobar", "f"));
+ DE_TEST_ASSERT(beginsWith("foobar", ""));
+ DE_TEST_ASSERT(beginsWith("", ""));
+ DE_TEST_ASSERT(!beginsWith("foobar", "bar"));
+ DE_TEST_ASSERT(!beginsWith("foobar", "foobarbaz"));
+ DE_TEST_ASSERT(!beginsWith("", "foo"));
+
+ DE_TEST_ASSERT(endsWith("foobar", "foobar"));
+ DE_TEST_ASSERT(endsWith("foobar", "bar"));
+ DE_TEST_ASSERT(endsWith("foobar", "r"));
+ DE_TEST_ASSERT(endsWith("foobar", ""));
+ DE_TEST_ASSERT(endsWith("", ""));
+ DE_TEST_ASSERT(!endsWith("foobar", "foo"));
+ DE_TEST_ASSERT(!endsWith("foobar", "bazfoobar"));
+ DE_TEST_ASSERT(!endsWith("foobar", "foobarbaz"));
+ DE_TEST_ASSERT(!endsWith("", "foo"));
+
DE_TEST_ASSERT(toUpper('a') == 'A');
DE_TEST_ASSERT(toUpper('A') == 'A');
DE_TEST_ASSERT(toLower('a') == 'a');
std::string capitalize (const std::string& s);
std::vector<std::string> splitString (const std::string& s, char delim='\0');
std::string floatToString (float val, int precision);
+bool beginsWith (const std::string& s, const std::string& prefix);
+bool endsWith (const std::string& s, const std::string& suffix);
char toUpper (char c);
char toLower (char c);
bool isUpper (char c);
#include "gluVarType.hpp"
#include "gluShaderProgram.hpp"
#include "deSTLUtil.hpp"
+#include "deStringUtil.hpp"
#include "glwEnums.hpp"
#include <set>
for (int ndx = 0; ndx < (int)m_xfbVaryings.size(); ++ndx)
{
// user-defined
- if (m_xfbVaryings[ndx].find("gl_") != 0)
+ if (!de::beginsWith(m_xfbVaryings[ndx], "gl_"))
{
std::vector<ProgramInterfaceDefinition::VariablePathComponent> path;
if (!findProgramVariablePathByPathName(path, this, m_xfbVaryings[ndx], VariableSearchFilter::createShaderTypeStorageFilter(getProgramTransformFeedbackStage(this), glu::STORAGE_OUT)))
using ProgramInterfaceDefinition::VariablePathComponent;
using ProgramInterfaceDefinition::VariableSearchFilter;
-static bool stringEndsWith (const std::string& str, const std::string& suffix)
-{
- if (suffix.length() > str.length())
- return false;
- else
- return str.substr(str.length() - suffix.length()) == suffix;
-}
-
static glw::GLenum getProgramDefaultBlockInterfaceFromStorage (glu::Storage storage)
{
switch (storage)
if (recoveryStrategies[strategyNdx].removeTrailingArray)
{
- if (stringEndsWith(resourceName, "[0]"))
+ if (de::endsWith(resourceName, "[0]"))
simplifiedResourceName = resourceName.substr(0, resourceName.length() - 3);
else
continue;
namespace
{
-static bool stringEndsWith (const std::string& str, const std::string& suffix)
-{
- if (suffix.length() > str.length())
- return false;
- else
- return str.substr(str.length() - suffix.length()) == suffix;
-}
-
static int getTypeSize (glu::DataType type)
{
if (type == glu::TYPE_FLOAT)
{
for (int ndx = 0; ndx < (int)referenceResources.size(); ++ndx)
{
- if (stringEndsWith(referenceResources[ndx], "[0]"))
+ if (de::endsWith(referenceResources[ndx], "[0]"))
{
const std::string queryString = referenceResources[ndx].substr(0, referenceResources[ndx].length()-3);
const glw::GLuint index = gl.getProgramResourceIndex(program, programInterface, queryString.c_str());
if (arrayedInterface && isImplicitlySizedArray)
{
// omit implicit arrayness from name, i.e. remove trailing "_array"
- DE_ASSERT(stringEndsWith(buf, "_array"));
+ DE_ASSERT(de::endsWith(buf, "_array"));
buf = buf.substr(0, buf.length() - 6);
}