void ImageBuf::reset (const std::string &filename, ImageCache *imagecache) { clear (); m_name = ustring (filename); if (imagecache) m_imagecache = imagecache; }
OSL_SHADEOP const char * osl_closure_to_string (ShaderGlobals *sg, ClosureColor *c) { // Special case for printing closures std::stringstream stream; print_closure(stream, c, &sg->context->shadingsys()); return ustring(stream.str ()).c_str(); }
ustring ExpAccess::get_name() const { TRUSTEE_FORM tf = ::GetTrusteeFormW((PTRUSTEEW)&Trustee); if (tf == TRUSTEE_IS_NAME) return ustring(::GetTrusteeNameW((PTRUSTEEW)&Trustee)); else if (tf != TRUSTEE_IS_SID) CheckApiError(ERROR_INVALID_PARAMETER); return Sid((PSID)Trustee.ptstrName).get_name(); }
void OSOReaderToMaster::add_param_default (const char *def, size_t offset, const Symbol& sym) { if (sym.typespec().is_unsized_array() && offset >= m_master->m_sdefaults.size()) m_master->m_sdefaults.emplace_back(def); else m_master->m_sdefaults[offset] = ustring(def); }
ustring CUTranslate(const std::string& text) { // Don't translate an empty string as it will return the PO meta data. if (text.empty()) return ustring(); return MakeUnicodeString(CTranslate(text)); }
ShellIcon ShellLink::icon() const { Base::auto_array<wchar_t> buf(Base::MAX_PATH_LEN); int ind; CheckCom(m_lnk->GetIconLocation(buf.data(), buf.size(), &ind)); return ShellIcon(ustring(buf.data()), ind); }
void write_bitmap(FILE *image_data_fp, struct transmission_line_properties xyz) { int colour_Er1=-1, colour_Er2=-1, vector_aligned; #ifndef HAVE_MEMSET int memory_location; #endif unsigned char *image_data, *unaligned_image_vector; get_Er1_and_Er2_colours(&colour_Er1, &colour_Er2); W+=2*BORDER; H+=2*BORDER; xyz.W+=2*BORDER; xyz.H+=2*BORDER; /* We create an vector big enough for the image. Since rows are aligned on 4-byte boundaries, we need to allow suffient space for (W+2)*(H-1) bytes. */ /* when aligning data on 4-byte boundaries, the padding must be filled with 0's, to meet the .bmp standard */ image_data=ustring(0,(W+3)*3*H); unaligned_image_vector=ustring(0,(W+3)*3*H); #ifdef HAVE_MEMSET (void) memset((void *) (image_data),0x0,(size_t) ((W+3)*3*H)); #else for(memory_location=0; memory_location < (W+3)*3*H; ++ memory_location) image_data[memory_location]=0; #endif /* end of #ifdef HAVE_MEMSET */ /* Fill a vector with the initial (original) data on the tline. This is not aligned in any way */ /* The following function 'fill_image_vector_with_data' is *not* in the file fill_image_vector_with_data.c, but instead different versions of it are located in files fill_rect_with_rect.c, fill_circ_with_circ.c, fill_rect_with_circ.c and fill_circ_with_rect.c */ fill_image_vector_with_data(unaligned_image_vector, colour_Er1, colour_Er2, xyz); /* put into the vector, in reverse order - i.e. from bottom to top and align each row on 4-byte boundaries */ vector_aligned=align_bitmap_image(W, H, unaligned_image_vector,image_data); write_bitmap_out(image_data, image_data_fp,vector_aligned, W, H); }
/* Create vertex color attributes. */ static void attr_create_vertex_color(Scene *scene, Mesh *mesh, BL::Mesh& b_mesh, const vector<int>& nverts, const vector<int>& face_flags) { BL::Mesh::tessface_vertex_colors_iterator l; for(b_mesh.tessface_vertex_colors.begin(l); l != b_mesh.tessface_vertex_colors.end(); ++l) { if(!mesh->need_attribute(scene, ustring(l->name().c_str()))) continue; Attribute *attr = mesh->attributes.add( ustring(l->name().c_str()), TypeDesc::TypeColor, ATTR_ELEMENT_CORNER_BYTE); BL::MeshColorLayer::data_iterator c; uchar4 *cdata = attr->data_uchar4(); size_t i = 0; for(l->data.begin(c); c != l->data.end(); ++c, ++i) { int tri_a[3], tri_b[3]; face_split_tri_indices(nverts[i], face_flags[i], tri_a, tri_b); uchar4 colors[4]; colors[0] = color_float_to_byte(color_srgb_to_scene_linear(get_float3(c->color1()))); colors[1] = color_float_to_byte(color_srgb_to_scene_linear(get_float3(c->color2()))); colors[2] = color_float_to_byte(color_srgb_to_scene_linear(get_float3(c->color3()))); if(nverts[i] == 4) { colors[3] = color_float_to_byte(color_srgb_to_scene_linear(get_float3(c->color4()))); } cdata[0] = colors[tri_a[0]]; cdata[1] = colors[tri_a[1]]; cdata[2] = colors[tri_a[2]]; if(nverts[i] == 4) { cdata[3] = colors[tri_b[0]]; cdata[4] = colors[tri_b[1]]; cdata[5] = colors[tri_b[2]]; cdata += 6; } else cdata += 3; } } }
void ImageBuf::reset (const std::string &filename, const ImageSpec &spec) { clear (); m_name = ustring (filename); m_current_subimage = 0; m_current_miplevel = 0; alloc (spec); }
ustring get_name(PCWSTR priv_name) { DWORD size = 0, lang = 0; ::LookupPrivilegeDisplayNameW(nullptr, priv_name, nullptr, &size, &lang); CheckApi(::GetLastError() == ERROR_INSUFFICIENT_BUFFER); memory::auto_array<wchar_t> name(size); CheckApi(::LookupPrivilegeDisplayNameW(nullptr, priv_name, name, &size, &lang)); return ustring(name); }
Field* QtPixmapClass::fieldNamed(PropertyName identifier, Instance*) const { UString ustring(identifier.publicName()); if (ustring == QtPixmapWidthField::name()) return &qt_pixmap_metaData.widthField; if (ustring == QtPixmapHeightField::name()) return &qt_pixmap_metaData.heightField; return 0; }
OSL_SHADEOP const char * osl_format (const char* format_str, ...) { va_list args; va_start (args, format_str); std::string s = Strutil::vformat (format_str, args); va_end (args); return ustring(s).c_str(); }
ustring get_token_user(HANDLE hToken) { DWORD size = 0; if (!::GetTokenInformation(hToken, TokenUser, nullptr, 0, &size) && size) { Base::auto_buf<PTOKEN_USER> buf(size); CheckApi(::GetTokenInformation(hToken, TokenUser, buf, buf.size(), &size)); return Sid::get_name(buf->User.Sid); } return ustring(); }
ustring md5_hash(ustring const& passphrase, ustring const& indata) { ustring str = indata + passphrase; MD5_CTX md5handler; unsigned char md5digest[MD5_DIGEST_LENGTH]; MD5(str.c_str(), str.length(), md5digest); return ustring(md5digest, MD5_DIGEST_LENGTH); }
void SymbolTable::insert (Symbol *sym) { DASSERT (sym != NULL); sym->scope (scopeid ()); m_scopetables.back()[sym->name()] = sym; m_allsyms.push_back (sym); m_allmangled[ustring(sym->mangled())] = sym; }
void OSOReaderQuery::symdefault (const char *def) { if (m_reading_param && m_query.nparams() > 0) { OSLQuery::Parameter &p (m_query.m_params[m_query.nparams()-1]); p.sdefault.push_back (ustring(def)); p.validdefault = true; m_default_values++; } }
static bool xml_read_ustring(ustring *str, pugi::xml_node node, const char *name) { pugi::xml_attribute attr = node.attribute(name); if(attr) { *str = ustring(attr.value()); return true; } return false; }
static bool mesh_need_attribute(Scene *scene, Mesh *mesh, ustring name) { if(name == ustring()) return false; foreach(uint shader, mesh->used_shaders) if(scene->shaders[shader]->attributes.find(name)) return true; return false; }
ustring Env::convert_string(jstring str) const { ustring ret; const jchar * jc = m_jenv->GetStringChars(str, NULL); if (jc) { ret = ustring(reinterpret_cast<const wchar_t*>(jc)); m_jenv->ReleaseStringChars(str, jc); } return std::move(ret); }
// Returns a substring. Offset and count are clamped to the size // of `this'. ustring substr(size_t offset, size_t count) const { if (offset > data.size()) offset = data.size(); if (count > data.size() - offset) count = data.size() - offset; std::vector<uchar> newdata(data.begin() + offset, data.begin() + offset + count); return ustring(newdata); }
static GeometryPtr createPatch(const float P[12], const float Cs[3], const Mat4& trans = Mat4()) { PrimvarStorageBuilder builder; builder.add(Primvar::P, P, 12); builder.add(PrimvarSpec(PrimvarSpec::Constant, VarSpec::Color, 1, ustring("Cs")), Cs, 3); IclassStorage storReq(1,4,4,4,4); GeometryPtr patch(new Patch(builder.build(storReq))); patch->transform(trans); return patch; }
OSL_SHADEOP int osl_split (const char *str, ustring *results, const char *sep, int maxsplit, int resultslen) { maxsplit = OIIO::clamp (maxsplit, 0, resultslen); std::vector<std::string> splits; Strutil::split (USTR(str).string(), splits, USTR(sep).string(), maxsplit); int n = std::min (maxsplit, (int)splits.size()); for (int i = 0; i < n; ++i) results[i] = ustring(splits[i]); return n; }
ustring Register::get(PCWSTR name, PCWSTR def) const { // LogDebug(L"name: '%s', def: '%s'\n", name, def); memory::auto_array<wchar_t> buf(cstr::length(def) + 1); memory::copy(buf.data(), def, cstr::length(def) + 1); DWORD l_size = buf.size_in_bytes(); if (::RegQueryValueExW(m_hndl, name, nullptr, nullptr, (PBYTE)buf.data(), &l_size) == ERROR_MORE_DATA) { buf.reserve(l_size / sizeof(wchar_t)); ::RegQueryValueExW(m_hndl, name, nullptr, nullptr, (PBYTE)buf.data(), &l_size); } // LogDebug(L"return: '%s'\n", (PCWSTR)buf.data()); return ustring(buf.data()); }
virtual bool load_kernels(const DeviceRequestedFeatures& requested_features, vector<OpenCLDeviceBase::OpenCLProgram*> &programs) { bool single_program = OpenCLInfo::use_single_program(); program_data_init = OpenCLDeviceBase::OpenCLProgram(this, single_program ? "split" : "split_data_init", single_program ? "kernel_split.cl" : "kernel_data_init.cl", get_build_options(this, requested_features)); program_data_init.add_kernel(ustring("path_trace_data_init")); programs.push_back(&program_data_init); program_state_buffer_size = OpenCLDeviceBase::OpenCLProgram(this, single_program ? "split" : "split_state_buffer_size", single_program ? "kernel_split.cl" : "kernel_state_buffer_size.cl", get_build_options(this, requested_features)); program_state_buffer_size.add_kernel(ustring("path_trace_state_buffer_size")); programs.push_back(&program_state_buffer_size); return split_kernel->load_kernels(requested_features); }
boost::optional<frenzy::ustring> frenzy::dom::Element::getAttribute(frenzy::ustring name) const { attributes_t::const_iterator it = attributes.find(name); if (it == attributes.end()) { // DOM4 says return null, DOM3 says empty string. return ustring(); } return it->second->get_value(); }
Attribute *AttributeSet::add(AttributeStandard std, ustring name) { Attribute *attr = NULL; if(name == ustring()) name = Attribute::standard_name(std); if(triangle_mesh) { if(std == ATTR_STD_VERTEX_NORMAL) attr = add(name, TypeDesc::TypeNormal, ATTR_ELEMENT_VERTEX); else if(std == ATTR_STD_FACE_NORMAL) attr = add(name, TypeDesc::TypeNormal, ATTR_ELEMENT_FACE); else if(std == ATTR_STD_UV) attr = add(name, TypeDesc::TypePoint, ATTR_ELEMENT_CORNER); else if(std == ATTR_STD_UV_TANGENT) attr = add(name, TypeDesc::TypeVector, ATTR_ELEMENT_CORNER); else if(std == ATTR_STD_UV_TANGENT_SIGN) attr = add(name, TypeDesc::TypeFloat, ATTR_ELEMENT_CORNER); else if(std == ATTR_STD_GENERATED) attr = add(name, TypeDesc::TypePoint, ATTR_ELEMENT_VERTEX); else if(std == ATTR_STD_POSITION_UNDEFORMED) attr = add(name, TypeDesc::TypePoint, ATTR_ELEMENT_VERTEX); else if(std == ATTR_STD_POSITION_UNDISPLACED) attr = add(name, TypeDesc::TypePoint, ATTR_ELEMENT_VERTEX); else if(std == ATTR_STD_MOTION_PRE) attr = add(name, TypeDesc::TypePoint, ATTR_ELEMENT_VERTEX); else if(std == ATTR_STD_MOTION_POST) attr = add(name, TypeDesc::TypePoint, ATTR_ELEMENT_VERTEX); else assert(0); } else if(curve_mesh) { if(std == ATTR_STD_UV) attr = add(name, TypeDesc::TypePoint, ATTR_ELEMENT_CURVE); else if(std == ATTR_STD_GENERATED) attr = add(name, TypeDesc::TypePoint, ATTR_ELEMENT_CURVE); else if(std == ATTR_STD_MOTION_PRE) attr = add(name, TypeDesc::TypePoint, ATTR_ELEMENT_CURVE_KEY); else if(std == ATTR_STD_MOTION_POST) attr = add(name, TypeDesc::TypePoint, ATTR_ELEMENT_CURVE_KEY); else if(std == ATTR_STD_CURVE_TANGENT) attr = add(name, TypeDesc::TypeVector, ATTR_ELEMENT_CURVE_KEY); else if(std == ATTR_STD_CURVE_INTERCEPT) attr = add(name, TypeDesc::TypeFloat, ATTR_ELEMENT_CURVE_KEY); else assert(0); } attr->std = std; return attr; }
ustring DataValue::serialize(DataType type, void *value) { switch(type) { case data_int: case data_flags: case data_combo: case data_comboEx: return int_to_str(*(int*)value); case data_stock: case data_element: return ustring("\"") + *(ustring*)value + "\""; case data_real: return double_to_str(*(double *)value); case data_data: if(((TData*)value)->type == data_null) return ustring(""); return ustring(dataNames[((TData*)value)->type]) + "(" + ((TData*)value)->toStr() + ")"; case data_str: case data_list: return serializeStrList(value); case data_color: return ((TypeColor*)value)->to_string(); case data_pixbuf: return serializePixbuf(value); case data_array: return serializeArray(value); case data_font: return serializeFont(value); default: return ustring(); } }
OSL_SHADEOP const char * osl_substr_ssii (const char *s_, int start, int length) { ustring s (USTR(s_)); int slen = int (s.length()); if (slen == 0) return NULL; // No substring of empty string int b = start; if (b < 0) b += slen; b = Imath::clamp (b, 0, slen); return ustring(s, b, Imath::clamp (length, 0, slen)).c_str(); }
namespace Group { bool is_exist(const ustring& name, const ustring& dom = ustring()); bool is_member(const ustring& name, const ustring& in, const ustring& dom = ustring()); void add(const ustring& name, const ustring& comm = ustring(), const ustring& dom = ustring()); void del(const ustring& name, const ustring& dom = ustring()); void add_member(const ustring& name, const Sid & user, const ustring& dom = ustring()); void add_member(const SidString & gid, const Sid & user, const ustring& dom = ustring()); void del_member(const ustring& name, const Sid & user, const ustring& dom = ustring()); ustring get_comm(const ustring& name, const ustring& dom = ustring()); void set_name(const ustring& name, const ustring& in, const ustring& dom = ustring()); void set_comm(const ustring& name, const ustring& in, const ustring& dom = ustring()); }
void StringList::split(const char *text, char delimiter) { const char *c = text; while(*text) { if(*text == delimiter) { add(ustring(c, text - c)); c = text + 1; } text++; } if(c != text) add(c); }