本文整理汇总了C++中CL_String类的典型用法代码示例。如果您正苦于以下问题:C++ CL_String类的具体用法?C++ CL_String怎么用?C++ CL_String使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CL_String类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: validate_vcount
void CL_Collada_Triangles_Impl::validate_vcount(CL_DomElement &vcount_element)
{
CL_String points = vcount_element.get_text();
const CL_String::char_type *vcount_text = points.c_str();
for (unsigned int cnt=0; cnt < triangle_count; cnt++)
{
if (!(*vcount_text))
throw CL_Exception("VCount data count mismatch");
int value = atoi(vcount_text);
if (value != 3)
throw CL_Exception("Only triangles are supported. Export your mesh as triangles please");
while(*vcount_text)
{
if (*(vcount_text++) <= ' ') // Find whitespace
break;
}
while(*vcount_text)
{
if ((*vcount_text) > ' ') // Find end of whitespace
break;
vcount_text++;
}
}
if (*vcount_text)
throw CL_Exception("VCount data count mismatch (end)");
}
示例2: load_primitive
void CL_Collada_Triangles_Impl::load_primitive(CL_DomElement &primitive_element)
{
unsigned int count = stride * triangle_count * 3;
primitive.resize(count);
CL_String points = primitive_element.get_text();
const CL_String::char_type *primitive_text = points.c_str();
for (unsigned int cnt=0; cnt < count; cnt++)
{
if (!(*primitive_text))
throw CL_Exception("Primitive data count mismatch");
int value = atoi(primitive_text);
primitive[cnt] = value;
while(*primitive_text)
{
if (*(primitive_text++) <= ' ') // Find whitespace
break;
}
while(*primitive_text)
{
if ((*primitive_text) > ' ') // Find end of whitespace
break;
primitive_text++;
}
}
if (*primitive_text)
throw CL_Exception("Primitive data count mismatch (end)");
}
示例3: get_directory_listing
CL_VirtualDirectoryListing CL_VirtualFileSystem::get_directory_listing(const CL_String &path_rel)
{
CL_String path = CL_PathHelp::make_absolute(
"/",
path_rel,
CL_PathHelp::path_type_virtual);
// First see if its a mount point:
int index, size;
size = (int) impl->mounts.size();
for (index = 0; index < size; index++)
{
if (impl->mounts[index].first == path.substr(0, impl->mounts[index].first.length()))
{
return impl->mounts[index].second.get_directory_listing( path.substr(impl->mounts[index].first.length(), path.length()));
}
}
// Try open locally, if we got a file provider attached
if (impl->provider)
{
return CL_VirtualDirectoryListing(
impl->provider,
CL_PathHelp::make_relative(
"/",
path,
CL_PathHelp::path_type_virtual));
}
else
throw CL_Exception(cl_format("Unable to list directory: %1", path));
}
示例4: CL_String
void CL_StringFormat::set_arg(int index, long unsigned int value, int min_length)
{
CL_String t = CL_StringHelp::ull_to_text(value);
if ((int) t.length() < min_length)
t = CL_String(min_length-t.length(), '0') + t;
set_arg(index, t);
}
示例5: FromStream
void CL_TimeOfDay::FromStream (istream& s)
{
CL_String rep;
char c;
long count = 0;
char fill_char = s.fill ();
while (s.get (c) && c == fill_char);
if (!s.good() || s.eof()) {
_numSecs = 0;
return;
}
do {
if (isalnum (c) || c == ':') {
rep.Append (c);
count++;
}
else
break;
} while (s.get (c));
long n = ParseAndConvert (rep);
if (n > 0) {
if (!s.eof())
s.putback (c);
_numSecs = n;
}
else {
s.seekg (s.tellg() - count, istream::cur);
_numSecs = 0;
}
}
示例6: CL_Exception
void CL_Collada_Material_Impl::load_material(CL_DomElement &material_element, std::vector<CL_Collada_Effect> &effects)
{
id = material_element.get_attribute("id");
CL_DomElement instance_effect_element = material_element.named_item("instance_effect").to_element();
if (instance_effect_element.is_null())
throw CL_Exception("Only instance_effect materials are supported");
CL_String url = instance_effect_element.get_attribute("url");
url = url.substr(1); // Remove the initial '#' symbol
std::vector<CL_Collada_Effect>::size_type size, cnt;
size = effects.size();
for (cnt=0; cnt< size; cnt++)
{
if (effects[cnt].get_id() == url)
{
effect = effects[cnt];
break;
}
}
if (effect.is_null())
throw CL_Exception("Unable to find effect");
}
示例7: is_absolute
bool CL_PathHelp::is_absolute(const CL_String &path, PathType path_type)
{
if (path_type == path_type_file)
{
#ifdef WIN32
if (path.length() < 3)
return false;
if (path[1] == ':' && (path[2] == '\\' || path[2] == '/'))
return true;
if (path[0] == '\\' && path[1] == '\\')
return true;
return false;
#else
if (path.length() < 1)
return false;
if (path[0] == '/')
return true;
if (path[0] == '\\')
return true;
return false;
#endif
}
else
{
if (path.length() < 1)
return false;
if (path[0] == '/')
return true;
return false;
}
}
示例8: file
CL_String CL_File::read_text(const CL_String &filename)
{
CL_File file(filename);
CL_String str;
str.resize(file.get_size());
file.read(str.data(), str.length());
file.close();
return str;
}
示例9: remove_trailing_slash
CL_String CL_PathHelp::remove_trailing_slash(const CL_String &path)
{
if (path.empty())
return path;
if (path[path.length()-1] == '/' || path[path.length()-1] == '\\')
return path.substr(0, path.length()-1);
return path;
}
示例10: decode
//конвертирование из CP-1251 в UTF-8
CL_String decode(const CL_String &str)
{
//строка символов в текущей локали преобразовать в UCS-2 через MultiByteToWideChar,
//а потом из UCS-2 в кланлибовский UTF-8 через CL_StringHelp::ucs2_to_text.
CL_String16 result;
int count = MultiByteToWideChar(1251, 0, str.c_str(), str.size(), NULL, 0);
result.resize(count);
MultiByteToWideChar(1251, 0, str.c_str(), str.size(), result.data(), count);
return CL_StringHelp::ucs2_to_text(result);
}
示例11: index_file
void ReferenceIndex::save(const CL_StringRef &filename)
{
CL_File index_file(filename, CL_File::create_always, CL_File::access_write);
CL_String html =
"<!-- clanlib header begin -->"
"<HTML>"
"<HEAD>"
"<TITLE>Index - ClanLib Game SDK</TITLE>"
"<STYLE TYPE=\"text/css\"><!--"
"HTML BODY"
"{"
" font-family: verdana, helvetica, sans-serif;"
" font-size: 12px;"
"}"
"H1 { font-size: 22px; }"
"H2 { font-size: 18px; }"
"H3 { font-size: 16px; }"
"H4 { font-size: 14px; }"
"P { font-size: 12px; }"
"LI { font-size: 12px; }"
".reflink:link { text-decoration: none; font-weight: bold; color: black; }"
".reflink:visited { text-decoration: none; font-weight: bold; color: black; }"
".reflink:active { text-decoration: none; font-weight: bold; color: black; }"
".reflink:hover { text-decoration: underline; font-weight: bold; color: black; }"
"--></STYLE>"
"</HEAD>"
"<body bgcolor=white text=black link=blue vlink=#800080>"
"<center>"
"<img src=\"http://clanlib.org/gfx/clanlib.png\">"
"</center>"
"<!-- clanlib header end -->"
"<center>"
"<p>"
// "<a href=\"http://clanlib.org/docs.html\">Home</a> |"
"<a href=\"classes.html\">All Classes</a> |"
"<a href=\"modules.html\">Grouped Classes</a> |"
"<a href=\"index.html\">Index</a>"
// "<a href=\"search.html\">Search</a>"
"</p>"
"</center>"
"<h1>Index</h1>";
index_file.write(html.data(), html.length());
html =
"<!-- clanlib footer begin -->"
// "<center><br><br><font color=\"#a0a0a0\">"
// "Questions or comments, write to the <a href=\"http://clanlib.org/contact.html\">ClanLib mailing list</a>."
// "</font></center>"
"<!-- clanlib footer end -->"
"</body>"
"</html>";
index_file.write(html.data(), html.length());
}
示例12: get_fullname
CL_String CL_PathHelp::get_fullname(
const CL_String &fullpath,
const CL_String &filename,
const CL_String &extension,
PathType path_type)
{
if (!extension.empty() && extension[0] == '.')
return add_trailing_slash(fullpath, path_type) + filename + extension;
else if (!extension.empty())
return add_trailing_slash(fullpath, path_type) + filename + "." + extension;
else
return add_trailing_slash(fullpath, path_type) + filename;
}
示例13: save
void CL_ImageProviderFactory::save(
CL_PixelBuffer buffer,
const CL_String &filename,
CL_VirtualDirectory &directory,
const CL_String &type_
)
{
CL_String type = type_;
if (type.empty())
type = CL_PathHelp::get_extension(filename, CL_PathHelp::path_type_virtual);
if (types.find(type) == types.end()) throw CL_Exception("Unknown image provider type " + type);
CL_ImageProviderType *factory = types[type];
factory->save(buffer, filename, directory);
}
示例14: get_text
CL_String CL_DomElement::get_text() const
{
CL_String str;
if (has_child_nodes() == false)
return str;
CL_DomNode cur = get_first_child();
while (!cur.is_null())
{
if (cur.is_text() || cur.is_cdata_section())
str.append(cur.get_node_value());
if (cur.is_element())
str.append(cur.to_element().get_text());
cur = cur.get_next_sibling();
}
return str;
}
示例15: SetCurrentDirectory
bool CL_Directory::set_current(const CL_String &dir_name)
{
#ifdef WIN32
return SetCurrentDirectory(CL_StringHelp::utf8_to_ucs2(dir_name).c_str()) == TRUE;
#else
return chdir(dir_name.c_str()) == 0;
#endif
}