本文整理汇总了C++中cl_format函数的典型用法代码示例。如果您正苦于以下问题:C++ cl_format函数的具体用法?C++ cl_format怎么用?C++ cl_format使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cl_format函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: CL_String
CL_String CL_CSSLayoutNode_Impl::print_node(CL_CSSBoxNode *node, int indent)
{
CL_String output_string;
output_string += CL_String(indent*2, ' ');
CL_CSSBoxElement *element = dynamic_cast<CL_CSSBoxElement*>(node);
CL_CSSBoxText *text = dynamic_cast<CL_CSSBoxText*>(node);
if (element)
{
//if (element->computed_properties.font_family.names.empty())
output_string += cl_format("%1 { display: %2; float: %3; width: %4 }\r\n", element->name, to_string(element->computed_properties.display), to_string(element->computed_properties.float_box), to_string(element->computed_properties.width));
//else
// output_string += cl_format("%1 { font-family: %2 }\r\n", element->name, element->computed_properties.font_family.names[0].name);
}
else if (text)
{
output_string += cl_format("[%1]\r\n", escape_text(text->text));
}
else
{
output_string += cl_format("unknown\r\n");
}
CL_CSSBoxNode *cur = node->get_first_child();
while (cur)
{
output_string += print_node(cur, indent+1);
cur = cur->get_next_sibling();
}
return output_string;
}
开发者ID:animehunter,项目名称:clanlib-2.3,代码行数:32,代码来源:css_layout_node.cpp
示例2: vertex_shader
ShaderColorInstanced::ShaderColorInstanced(CL_GraphicContext &gc)
{
CL_ShaderObject vertex_shader(gc, cl_shadertype_vertex, vertex);
if(!vertex_shader.compile())
{
throw CL_Exception(cl_format("Unable to compile vertex shader object: %1", vertex_shader.get_info_log()));
}
CL_ShaderObject fragment_shader(gc, cl_shadertype_fragment, fragment);
if(!fragment_shader.compile())
{
throw CL_Exception(cl_format("Unable to compile fragment shader object: %1", fragment_shader.get_info_log()));
}
program_object = CL_ProgramObject(gc);
program_object.attach(vertex_shader);
program_object.attach(fragment_shader);
program_object.bind_attribute_location(0, "InPosition");
program_object.bind_attribute_location(1, "InNormal");
if (!program_object.link())
{
throw CL_Exception(cl_format("Unable to link program object: %1", program_object.get_info_log()));
}
material_updated = false;
light_updated = false;
material_shininess = 64.0f;
material_emission = CL_Vec4f(0.0f, 0.0f, 0.0f, 1.0f);
light_vector = CL_Vec4f(0.0f, 0.0f, 1.0f, 0.0f);
light_specular = CL_Vec4f(0.7f, 0.7f, 0.7f, 1.0f);
light_diffuse = CL_Vec4f(0.7f, 0.7f, 0.7f, 1.0f);
}
开发者ID:PaulFSherwood,项目名称:cplusplus,代码行数:34,代码来源:shader_color_instanced.cpp
示例3: CL_Exception
void CL_FontProvider_Freetype::load_font(const CL_StringRef &resource_id, CL_ResourceManager *resources)
{
CL_Resource resource = resources->get_resource(resource_id);
if (resource.get_type() != "font")
throw CL_Exception(cl_format("Resource '%1' is not of type 'font'", resource.get_name()));
CL_DomElement freetype_element = resource.get_element().named_item("freetype").to_element();
if (freetype_element.is_null())
throw CL_Exception(cl_format("Font resource '%1' has no 'freetype' child element", resource.get_name()));
CL_FontDescription desc;
if (freetype_element.has_attribute("file"))
desc.set_typeface_name(freetype_element.get_attribute("file"));
else
throw CL_Exception(cl_format("Font resource '%1' has no 'file' attribute", resource.get_name()));
if (freetype_element.has_attribute("height"))
desc.set_height(freetype_element.get_attribute_int("height", 0));
else
throw CL_Exception(cl_format("Font resource '%1' has no 'height' attribute", resource.get_name()));
if (freetype_element.has_attribute("average_width"))
desc.set_average_width(freetype_element.get_attribute_int("average_width", 0));
if (freetype_element.has_attribute("anti_alias"))
desc.set_anti_alias(freetype_element.get_attribute_bool("anti_alias", true));
if (freetype_element.has_attribute("subpixel"))
desc.set_subpixel(freetype_element.get_attribute_bool("subpixel", true));
load_font(desc, resources->get_directory(resource));
}
开发者ID:animehunter,项目名称:clanlib-2.3,代码行数:33,代码来源:font_provider_freetype.cpp
示例4: vertex_shader
ShaderDepth::ShaderDepth(CL_GraphicContext &gc)
{
CL_ShaderObject vertex_shader(gc, cl_shadertype_vertex, vertex);
if(!vertex_shader.compile())
{
throw CL_Exception(cl_format("Unable to compile vertex shader object: %1", vertex_shader.get_info_log()));
}
CL_ShaderObject fragment_shader(gc, cl_shadertype_fragment, fragment);
if(!fragment_shader.compile())
{
throw CL_Exception(cl_format("Unable to compile fragment shader object: %1", fragment_shader.get_info_log()));
}
program_object = CL_ProgramObject(gc);
program_object.attach(vertex_shader);
program_object.attach(fragment_shader);
program_object.bind_attribute_location(0, "InPosition");
if (!program_object.link())
{
throw CL_Exception(cl_format("Unable to link program object: %1", program_object.get_info_log()));
}
material_updated = false;
material_ambient = CL_Vec4f(0.9f, 0.2f, 0.2f, 1.0f);
}
开发者ID:PaulFSherwood,项目名称:cplusplus,代码行数:28,代码来源:shader_depth.cpp
示例5: while
void TexturePacker::process_resource(CL_Resource &item_resource, std::vector<CL_Subtexture> &packed_sub_textures, std::map<CL_Texture, CL_String> &generated_texture_filenames, int &generated_texture_index, const CL_String &image_pathname )
{
// Found a sprite resource, lets modify its content!
CL_Resource resource = item_resource;
// Iterate through all nodes, and remove all previous image tags
CL_DomElement &element = resource.get_element();
CL_DomNode cur = element.get_first_child();
while (!cur.is_null())
{
CL_DomNode next = cur.get_next_sibling();
CL_DomNode::NodeType nodeType = (CL_DomNode::NodeType)cur.get_node_type();
// Only remove the <image> tag, as we want to keep the other sprite attributes
if (cur.get_node_name() == "image")
element.remove_child(cur);
cur = next;
}
// Add new image tag to resource DOM
std::vector<CL_Subtexture>::size_type index, size;
size = packed_sub_textures.size();
for(index = 0; index < size; ++index)
{
CL_Subtexture subtexture = packed_sub_textures[index];
// Try to find out if we already have created a texture-on-disk for this subtexture
CL_String texture_filename;
CL_Texture texture = subtexture.get_texture();
std::map<CL_Texture, CL_String>::iterator it;
it = generated_texture_filenames.find(texture);
if(it == generated_texture_filenames.end())
{
// Texture not found, generate a filename and dump texture to disk
texture_filename = cl_format("texture%1.png", ++generated_texture_index);
CL_PNGProvider::save(texture.get_pixeldata(), image_pathname + texture_filename);
generated_texture_filenames[texture] = texture_filename;
}
else
{
// Previously dumped textures, lets reuse the filename
texture_filename = (*it).second;
}
// Add <grid> DOM element
CL_DomElement new_grid_element = element.get_owner_document().create_element("grid");
new_grid_element.set_attribute("pos", cl_format("%1,%2", subtexture.get_geometry().left + last_border_size, subtexture.get_geometry().top + last_border_size));
new_grid_element.set_attribute("size", cl_format("%1,%2", subtexture.get_geometry().get_width()- last_border_size*2, subtexture.get_geometry().get_height()- last_border_size*2));
// Add <image> DOM element
CL_DomElement new_image_element = element.get_owner_document().create_element("image");
new_image_element.set_attribute("file", texture_filename);
new_image_element.append_child(new_grid_element);
// Add <image> element under <sprite> element
element.append_child(new_image_element);
}
}
开发者ID:PaulFSherwood,项目名称:cplusplus,代码行数:59,代码来源:texture_packer.cpp
示例6: url
CL_String HTMLPage::download_url(const CL_String &page_url, const CL_String &refererer_url)
{
HTMLUrl url(page_url, refererer_url);
CL_Console::write_line("Downloading URL: %1", url.to_string());
CL_String8 request;
request = cl_format("GET %1 HTTP/1.1\r\n", url.path+url.query);
if (refererer_url.empty())
request += cl_format("Host: %1\r\nConnection: close\r\nAccept: text/plain, text/html\r\nUser-Agent: CSSTokenize/0.1\r\n\r\n", url.host);
else
request += cl_format("Host: %1\r\nConnection: close\r\nReferer: %2\r\nAccept: text/plain, text/html\r\nUser-Agent: CSSTokenize/0.1\r\n\r\n", url.host, refererer_url);
//MessageBoxW(0, CL_StringHelp::utf8_to_ucs2(cl_format("GET %1 HTTP/1.1\r\n", url.path+url.query)).c_str(), L"Download URL", MB_OK);;
CL_TCPConnection connection(CL_SocketName(url.host, url.port));
connection.set_nodelay(true);
connection.send(request.data(), request.length(), true);
CL_String response;
while (connection.get_read_event().wait(15000))
{
char buffer[16*1024];
int received = connection.read(buffer, 16*1024, false);
if (received == 0)
break;
response.append(buffer, received);
}
connection.disconnect_graceful();
CL_String response_header = response.substr(0, response.find("\r\n\r\n"));
CL_String content = response.substr(response_header.length() + 4);
if (response_header.find("Transfer-Encoding: chunked") != CL_String::npos)
{
CL_String::size_type start = 0;
while (true)
{
CL_String::size_type end = content.find("\r\n", start);
if (end == CL_String::npos)
end = content.length();
CL_String str_length = content.substr(start, end-start);
int length = CL_StringHelp::text_to_int(str_length, 16);
content = content.substr(0, start) + content.substr(end+2);
start += length;
end = content.find("\r\n", start);
if (end == CL_String::npos)
end = content.length();
content = content.substr(0, start) + content.substr(end+2);
if (length == 0)
break;
}
}
return content;
}
开发者ID:animehunter,项目名称:clanlib-2.3,代码行数:57,代码来源:html_page.cpp
示例7: strlen
int CL_CSSDocument_Impl::load_keyword(const char *keyword, unsigned char *data, int pos, int length)
{
int keyword_len = strlen(keyword);
if (pos+keyword_len > length)
throw CL_Exception(cl_format("Expected %1 at position %2", keyword, pos));
CL_String8 s((char *) data+pos, keyword_len);
if (CL_StringHelp::compare(keyword, s, true) != 0)
throw CL_Exception(cl_format("Expected %1 at position %2", keyword, pos));
return pos + keyword_len;
}
开发者ID:PaulFSherwood,项目名称:cplusplus,代码行数:10,代码来源:css_document_impl.cpp
示例8: mPaused
Sound::Sound(const std::string &name)
: mPaused(false)
{
CL_SharedPtr<SoundResource> resource = cl_dynamic_pointer_cast<SoundResource>(ResourceManager::getSingleton().getResource(name));
if (!resource)
throw Exception(cl_format("Resource '%1' is not a sound resource", name));
if (!resource->isLoaded())
throw Exception(cl_format("Sound '%1' is not loaded", name));
mSession = resource->getSoundBuffer().prepare();
}
开发者ID:ermachkov,项目名称:Balance_GUI,代码行数:11,代码来源:Sound.cpp
示例9: SHDeleteKey
void CL_RegistryKey::delete_key(const CL_StringRef &subkey, bool recursive)
{
if (recursive)
{
DWORD result = SHDeleteKey(impl->key, CL_StringHelp::utf8_to_ucs2(subkey).c_str());
if (result != ERROR_SUCCESS)
throw CL_Exception(cl_format("Unable to delete registry key %1", subkey));
}
else
{
LONG result = RegDeleteKey(impl->key, CL_StringHelp::utf8_to_ucs2(subkey).c_str());
if (result != ERROR_SUCCESS)
throw CL_Exception(cl_format("Unable to delete registry key %1", subkey));
}
}
开发者ID:PaulFSherwood,项目名称:cplusplus,代码行数:15,代码来源:registry_key.cpp
示例10: PQfnumber
int CL_PgsqlReaderProvider::get_name_index(const CL_StringRef &name) const
{
int index = PQfnumber(result, name.c_str());
if (index < 0)
throw CL_Exception(cl_format("No such column name %1", name));
return index;
}
开发者ID:Zenol,项目名称:clanlib-2.4,代码行数:7,代码来源:pgsql_reader_provider.cpp
示例11: catch
CL_Resource CL_ResourceManager::get_resource(
const CL_String &resource_id,
bool resolve_alias,
int reserved)
{
std::map<CL_String, CL_Resource>::const_iterator it;
it = impl->resources.find(resource_id);
if (it != impl->resources.end())
return it->second;
std::vector<CL_ResourceManager>::size_type i;
for (i = 0; i < impl->additional_resources.size(); i++)
{
try
{
return impl->additional_resources[i].get_resource(
resource_id, resolve_alias, reserved);
}
catch (const CL_Exception&)
{
}
}
throw CL_Exception(cl_format("Resource not found: %1", resource_id));
return CL_Resource(impl->document.get_document_element(), *this);
}
开发者ID:animehunter,项目名称:clanlib-2.3,代码行数:26,代码来源:resource_manager.cpp
示例12: get_value
void Options::slider_cutoff_changed()
{
float value = get_value(slider_cutoff, max_angle_value);
CL_String text(cl_format("Cutoff : %1", value));
label_cutoff->set_text(text);
spot_light_cutoff = value;
}
开发者ID:PaulFSherwood,项目名称:cplusplus,代码行数:7,代码来源:options.cpp
示例13: select_nodes
CL_DomNode CL_DomNode::select_node(const CL_DomString &xpath_expression) const
{
std::vector<CL_DomNode> nodes = select_nodes(xpath_expression);
if (nodes.empty())
throw CL_Exception(cl_format("Xpath did not match any node: %1", xpath_expression));
return nodes[0];
}
开发者ID:animehunter,项目名称:clanlib-2.3,代码行数:7,代码来源:dom_node.cpp
示例14: RegCreateKeyEx
CL_RegistryKey CL_RegistryKey::create_key(const CL_StringRef &subkey, unsigned int access_rights, CreateFlags create_flags)
{
DWORD disposition = 0;
HKEY new_key = 0;
LONG result = RegCreateKeyEx(impl->key, CL_StringHelp::utf8_to_ucs2(subkey).c_str(), 0, 0, (create_flags & create_volatile) ? REG_OPTION_VOLATILE : REG_OPTION_NON_VOLATILE, access_rights, 0, &new_key, &disposition);
if (result != ERROR_SUCCESS)
throw CL_Exception(cl_format("Unable to create registry key %1", subkey));
if (disposition != REG_CREATED_NEW_KEY && (create_flags & create_new))
{
RegCloseKey(new_key);
throw CL_Exception(cl_format("Key already exists: %1", subkey));
}
return CL_RegistryKey(new_key);
}
开发者ID:PaulFSherwood,项目名称:cplusplus,代码行数:16,代码来源:registry_key.cpp
示例15: wait_for_workers
PixelPipeline::~PixelPipeline()
{
wait_for_workers();
#if defined(WIN32) && defined(PROFILE_PIPELINE)
profiler.end_time = __rdtsc();
#endif
event_stop.set();
for (std::vector<Thread>::size_type i = 0; i < worker_threads.size(); i++)
worker_threads[i].join();
for (size_t i = 0; i < queue_max; i++)
{
delete command_queue[i];
command_queue[i] = 0;
}
if (cur_block && cur_block->refcount == 1)
delete[] (char*) cur_block;
#if defined(WIN32) && defined(PROFILE_PIPELINE)
MessageBoxA(0, cl_format("Queue = %1\r\nSetEvent = %2\r\nWaitForWorkers = %3\r\nWaitForSpace = %4\r\nAllocFree = %5",
(int)(profiler.queue_time*100/(profiler.end_time-profiler.start_time)),
(int)(profiler.set_event_time*100/(profiler.end_time-profiler.start_time)),
(int)(profiler.wait_for_workers_time*100/(profiler.end_time-profiler.start_time)),
(int)(profiler.wait_for_space_time*100/(profiler.end_time-profiler.start_time)),
(int)(profiler.alloc_time*100/(profiler.end_time-profiler.start_time))).c_str(),
"DEBUG", MB_OK);
#endif
}
开发者ID:Cassie90,项目名称:ClanLib,代码行数:29,代码来源:pixel_pipeline.cpp
示例16: map_width
TileMap::TileMap(CL_GraphicContext& gc, CL_ResourceManager& resmgr, const CL_String& tileset)
: map_width(0), map_height(0), cur_map_x(0), cur_map_y(0) {
CL_Resource res = resmgr.get_resource(tileset);
if (res.get_type() != "tilemap")
throw CL_Exception(cl_format("Resource %1 is not a tilemap", tileset));
CL_DomElement element = res.get_element();
levelname = element.get_attribute("name");
CL_String resource_name = element.get_attribute("resource");
map_width = element.get_attribute_int("width");
map_height = element.get_attribute_int("height");
tiles = CL_Sprite(gc, resource_name, &resmgr);
float scalex, scaley;
tiles.get_scale(scalex, scaley);
tile_width = tiles.get_width() * scalex;
tile_height = tiles.get_height() * scaley;
auto layer_nodes = element.select_nodes("layer");
for (CL_DomNode& idx : layer_nodes) {
CL_DomElement layer_element = idx.to_element();
CL_String layer_tiles = layer_element.get_first_child().get_node_value();
std::vector<CL_String> tile_indices = CL_StringHelp::split_text(layer_tiles, ",");
MapLayer layer;
layer.map.reserve(tile_indices.size());
for (auto& tile : tile_indices)
layer.map.push_back(CL_StringHelp::text_to_int(tile));
layers.push_back(layer);
}
}
开发者ID:zeroshade,项目名称:ClanRPG,代码行数:34,代码来源:TileMap.cpp
示例17: css_tokenizer
CL_String HTMLPage::load_css(const CL_String &csstext, const CL_String &base_url)
{
CL_String pagecss;
CL_CSSTokenizer css_tokenizer(csstext);
CL_CSSToken css_token;
while (true)
{
css_tokenizer.read(css_token, true);
if (css_token.type != CL_CSSToken::type_atkeyword || css_token.value != "import")
break;
css_tokenizer.read(css_token, true);
if (css_token.type != CL_CSSToken::type_string)
break;
CL_String import_url = css_token.value;
css_tokenizer.read(css_token, true);
if (css_token.type != CL_CSSToken::type_semi_colon)
break;
CL_String css = download_url(import_url, base_url);
pagecss += load_css(css, HTMLUrl(import_url, base_url).to_string());
}
pagecss += cl_format("@-clan-base-uri \"%1\";\r\n", base_url);
pagecss += csstext;
return pagecss;
}
开发者ID:animehunter,项目名称:clanlib-2.3,代码行数:28,代码来源:html_page.cpp
示例18: defined
CL_String CL_Directory::get_local_appdata(const CL_StringRef &company_name, const CL_StringRef &application_name, const CL_StringRef &version, bool create_dirs_if_missing)
{
#if defined(WIN32)
TCHAR app_data[MAX_PATH];
if (FAILED(SHGetFolderPath(0, CSIDL_LOCAL_APPDATA, 0, SHGFP_TYPE_DEFAULT, app_data)))
throw CL_Exception("SHGetFolderPath failed!");
CL_String configuration_path = cl_format("%1\\%2\\%3\\%4\\", app_data, company_name, application_name, version);
if (create_dirs_if_missing)
{
CL_String::size_type prevPos = 0;
while (true)
{
CL_String::size_type pos = configuration_path.find_first_of("\\/", prevPos);
if (pos == CL_String::npos)
break;
CL_StringRef folder = configuration_path.substr(0, pos);
CreateDirectory(CL_StringHelp::utf8_to_ucs2(folder).c_str(), 0);
prevPos = pos + 1;
}
}
return configuration_path;
#elif defined(__APPLE__)
throw CL_Exception("Congratulations, you got the task to implement CL_Directory::get_local_appdata on this platform.");
#else
return get_appdata(company_name, application_name, version, create_dirs_if_missing);
#endif
}
开发者ID:PaulFSherwood,项目名称:cplusplus,代码行数:29,代码来源:directory.cpp
示例19: set_id_name
void ComponentTypes::set_id_name(CL_GUIComponent *new_component, int id)
{
if (component_count.find(id) == component_count.end())
component_count[id] = 1;
new_component->set_id_name(cl_format("%1%2", new_component->get_type_name(), component_count[id]++));
}
开发者ID:Zenol,项目名称:clanlib-2.4,代码行数:7,代码来源:component_types.cpp
示例20: getPlayer
void OnlineRaceLogic::onPlayerLeaved(const CL_String &p_name)
{
// get the player
Player &player = getPlayer(p_name);
// remove from level
getLevel().removeCar(&player.getCar());
// remove from game
removePlayer(player);
TPlayerList::iterator itor;
bool found = false;
for (itor = m_remotePlayers.begin(); itor != m_remotePlayers.end(); ++itor) {
if (reinterpret_cast<unsigned> (itor->get()) == reinterpret_cast<unsigned> (&player)) {
m_remotePlayers.erase(itor);
found = true;
break;
}
}
G_ASSERT(found);
display(cl_format("Player %1 leaved", p_name));
}
开发者ID:bercik,项目名称:gear,代码行数:26,代码来源:OnlineRaceLogic.cpp
注:本文中的cl_format函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论