本文整理汇总了C++中AString::Buffer方法的典型用法代码示例。如果您正苦于以下问题:C++ AString::Buffer方法的具体用法?C++ AString::Buffer怎么用?C++ AString::Buffer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AString
的用法示例。
在下文中一共展示了AString::Buffer方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: wtoa
FileStream::FileStream(const WString& fileName, AccessRight _accessRight)
:accessRight(_accessRight)
{
const wchar_t* mode=L"rb";
switch(accessRight)
{
case ReadOnly:
mode=L"rb";
break;
case WriteOnly:
mode=L"wb";
break;
case ReadWrite:
mode=L"w+b";
break;
}
#if defined VCZH_MSVC
if(_wfopen_s(&file, fileName.Buffer(), mode)!=0)
{
file=0;
}
#elif defined VCZH_GCC
AString fileNameA = wtoa(fileName);
AString modeA = wtoa(mode);
file = fopen(fileNameA.Buffer(), modeA.Buffer());
#endif
}
示例2: atof_test
double atof_test(const AString& string, bool& success)
{
char* endptr = 0;
double result = strtod(string.Buffer(), &endptr);
success = endptr == string.Buffer() + string.Length();
return result;
}
示例3:
vuint64_t atou64_test(const AString& string, bool& success)
{
char* endptr = 0;
vuint64_t result = _strtoui64(string.Buffer(), &endptr, 10);
success = endptr == string.Buffer() + string.Length() && u64toa(result) == string;
return result;
}
示例4: atoi_test
vint atoi_test(const AString& string, bool& success)
{
char* endptr = 0;
vint result = strtol(string.Buffer(), &endptr, 10);
success = endptr == string.Buffer() + string.Length() && itoa(result) == string;
return result;
}
示例5: Create
bool Semaphore::Create(vint initialCount, vint maxCount, const WString& name)
{
if (internalData) return false;
if (initialCount > maxCount) return false;
internalData = new SemaphoreData;
#if defined(__APPLE__)
AString auuid;
if(name.Length() == 0)
{
CFUUIDRef cfuuid = CFUUIDCreate(kCFAllocatorDefault);
CFStringRef cfstr = CFUUIDCreateString(kCFAllocatorDefault, cfuuid);
auuid = CFStringGetCStringPtr(cfstr, kCFStringEncodingASCII);
CFRelease(cfstr);
CFRelease(cfuuid);
}
auuid = auuid.Insert(0, "/");
// OSX SEM_NAME_LENGTH = 31
if(auuid.Length() >= 30)
auuid = auuid.Sub(0, 30);
if ((internalData->semNamed = sem_open(auuid.Buffer(), O_CREAT, O_RDWR, initialCount)) == SEM_FAILED)
{
delete internalData;
internalData = 0;
return false;
}
#else
if (name == L"")
{
if(sem_init(&internalData->semUnnamed, 0, (int)initialCount) == -1)
{
delete internalData;
internalData = 0;
return false;
}
}
else
{
AString astr = wtoa(name);
if ((internalData->semNamed = sem_open(astr.Buffer(), O_CREAT, 0777, initialCount)) == SEM_FAILED)
{
delete internalData;
internalData = 0;
return false;
}
}
#endif
Release(initialCount);
return true;
}
示例6: atow
WString atow(const AString& string)
{
vint len = _atow(string.Buffer(), 0, 0);
wchar_t* buffer = new wchar_t[len];
memset(buffer, 0, len*sizeof(*buffer));
_atow(string.Buffer(), buffer, (int)len);
WString s = buffer;
delete[] buffer;
return s;
}
示例7: IsFolder
bool FilePath::IsFolder()const
{
#if defined VCZH_MSVC
WIN32_FILE_ATTRIBUTE_DATA info;
BOOL result = GetFileAttributesEx(fullPath.Buffer(), GetFileExInfoStandard, &info);
if (!result) return false;
return (info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
#elif defined VCZH_GCC
struct stat info;
AString path = wtoa(fullPath);
int result = stat(path.Buffer(), &info);
if(result != 0) return false;
else return S_ISDIR(info.st_mode);
#endif
}
示例8: OnElementStateChanged
void GuiSolidLabelElementRenderer::OnElementStateChanged()
{
FontProperties font = element->GetFont();
Color color = element->GetColor();
int layoutWidth, layoutHeight;
AString family = wtoa(font.fontFamily);
pango_font_description_set_family(pangoFontDesc, family.Buffer());
pango_font_description_set_absolute_size(pangoFontDesc, font.size * PANGO_SCALE);
if(font.italic) pango_font_description_set_style(pangoFontDesc, PANGO_STYLE_ITALIC);
else pango_font_description_set_style(pangoFontDesc, PANGO_STYLE_NORMAL);
if(attrList)
{
pango_attr_list_unref(attrList);
}
attrList = pango_attr_list_new();
pango_attr_list_insert(attrList, pango_attr_underline_new(
font.underline ? PANGO_UNDERLINE_SINGLE : PANGO_UNDERLINE_NONE)
);
pango_attr_list_insert(attrList, pango_attr_strikethrough_new (
font.strikeline ? TRUE : FALSE
)
);
pango_attr_list_insert(attrList, pango_attr_weight_new (
font.bold ? PANGO_WEIGHT_BOLD : PANGO_WEIGHT_MEDIUM
)
);
if(layout)
{
g_object_unref(layout);
layout = NULL;
}
if(cairoContext)
{
layout = pango_cairo_create_layout(cairoContext);
WString wtext = (font.fontFamily == L"Webdings") ? helpers::WebdingsMap(element->GetText()) : element->GetText();
AString text = wtoa(wtext);
pango_layout_set_font_description(layout, pangoFontDesc);
pango_layout_set_attributes(layout, attrList);
pango_layout_set_text(layout, text.Buffer(), text.Length());
pango_layout_set_alignment(layout,
element->GetHorizontalAlignment() == Alignment::Left ? PANGO_ALIGN_LEFT :
element->GetHorizontalAlignment() == Alignment::Center ? PANGO_ALIGN_CENTER :
element->GetHorizontalAlignment() == Alignment::Right ? PANGO_ALIGN_RIGHT :
PANGO_ALIGN_LEFT
);
pango_cairo_update_layout(cairoContext, layout);
pango_layout_get_pixel_size( layout, &layoutWidth, &layoutHeight);
minSize.x = layoutWidth;
minSize.y = layoutHeight;
}
}
示例9: aupper
AString aupper(const AString& string)
{
AString result = string.Buffer();
_strupr_s((char*)result.Buffer(), result.Length() + 1);
return result;
}
示例10: if
/** ****************************************************************************************
* Gets a node. If not existent and parameter \p create is \c true, the node is created.
* @param key The key to the stored value.
* @param create Flag if a non-existent entry should be created.
* @param separators A list of characters recognized as separators.
* @return Returns the ourselves or a child node representing the key string.
******************************************************************************************/
PathMap* get ( Substring& key, bool create, const TString& separators )
{
// find the index of the match length and consume these characters from the key
int idx= 0;
int pLen= Path.Length();
if ( pLen > 0 )
{
int cmpLen= pLen < key.Length() ? pLen : key.Length();
const char* kBuf= key.Buffer();
const char* pBuf= Path.Buffer();
while( idx < cmpLen && *(kBuf + idx) == *(pBuf +idx ) )
idx++;
key.Consume<false>( idx );
}
// all of 'our' path characters matched
if( idx == pLen)
{
// identical to the searched string?
if( key.IsEmpty() )
return this;
// return matching child
for ( auto child : Childs )
{
if( key.CharAtStart<false>() == child->Path.CharAtStart() )
{
PathMap* search= child->get( key, create, separators );
if ( search != nullptr )
return search;
}
}
// no child found
if(create)
{
PathMap* newChild= nullptr;
newChild= new PathMap( this );
newChild->Path._( key );
Childs.emplace_back( newChild );
return newChild;
}
}
// nothing matched
else if ( idx == 0 )
return nullptr;
// just a part of us matched
else if ( create )
{
// create new child receiving our old path (rest), our value and childs
PathMap* child1= new PathMap( this );
child1->Path._( Path, idx );
for( auto child : Childs )
child->Parent= child1;
child1->Childs= Childs;
child1->Value= Value;
Childs.clear();
Childs.emplace_back( child1 );
// cut my path and clear my value
Path.SetLength<false>( idx );
Value= 0;
// create second child if remaining path is not empty
if( key.IsNotEmpty() )
{
PathMap* child2= new PathMap( this );
child2->Path._( key );
Childs.emplace_back( child2 );
return child2;
}
return this;
}
// return if this is the root or a real node
if( Parent == nullptr
|| separators.IndexOf( Path.CharAt<false>( idx - 1 ) ) >= 0
)
return this;
return Parent;
}