本文整理汇总了C++中PProperty::GetType方法的典型用法代码示例。如果您正苦于以下问题:C++ PProperty::GetType方法的具体用法?C++ PProperty::GetType怎么用?C++ PProperty::GetType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PProperty
的用法示例。
在下文中一共展示了PProperty::GetType方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ParseForEach
bool TemplateParser::ParseForEach()
{
// Whitespaces at the very start are ignored
ignore_whitespaces();
// parsing the property
if (GetNextToken() == TOK_PROPERTY)
{
wxString propname = ParsePropertyName();
wxString inner_template = ExtractInnerTemplate();
PProperty property = m_obj->GetProperty(propname);
wxString propvalue = property->GetValue();
// Property value must be an string using ',' as separator.
// The template will be generated nesting as many times as
// tokens were found in the property value.
if (property->GetType() == PT_INTLIST || property->GetType() == PT_UINTLIST)
{
// For doing that we will use wxStringTokenizer class from wxWidgets
wxStringTokenizer tkz( propvalue, wxT(","));
int i = 0;
while (tkz.HasMoreTokens())
{
wxString token;
token = tkz.GetNextToken();
token.Trim(true);
token.Trim(false);
// Parsing the internal template
{
wxString code;
PTemplateParser parser = CreateParser( this, inner_template );
parser->SetPredefined( token, wxString::Format( wxT("%i"), i++ ) );
code = parser->ParseTemplate();
m_out << wxT("\n") << code;
}
}
}
else if (property->GetType() == PT_STRINGLIST)
{
wxArrayString array = property->GetValueAsArrayString();
for ( unsigned int i = 0 ; i < array.Count(); i++ )
{
wxString code;
PTemplateParser parser = CreateParser(this,inner_template);
parser->SetPredefined( ValueToCode( PT_WXSTRING_I18N, array[i] ), wxString::Format( wxT("%i"), i ) );
code = parser->ParseTemplate();
m_out << wxT("\n") << code;
}
}
else
wxLogError(wxT("Property type not compatible with \"foreach\" macro"));
}
return true;
}
示例2: FindMacros
void PHPCodeGenerator::FindMacros( PObjectBase obj, std::vector<wxString>* macros )
{
// iterate through all of the properties of all objects, add the macros
// to the vector
unsigned int i;
for ( i = 0; i < obj->GetPropertyCount(); i++ )
{
PProperty prop = obj->GetProperty( i );
if ( prop->GetType() == PT_MACRO )
{
wxString value = prop->GetValue();
if( value.IsEmpty() ) continue;
// Skip wx IDs
if ( ( ! value.Contains( wxT("XRCID" ) ) ) &&
( m_predMacros.end() == m_predMacros.find( value ) ) )
{
if ( macros->end() == std::find( macros->begin(), macros->end(), value ) )
{
macros->push_back( value );
}
}
}
}
for ( i = 0; i < obj->GetChildCount(); i++ )
{
FindMacros( obj->GetChild( i ), macros );
}
}
示例3: PropertyToCode
wxString TemplateParser::PropertyToCode(PProperty property)
{
if ( property )
{
return ValueToCode(property->GetType(), property->GetValue());
}
else
{
return wxEmptyString;
}
}
示例4: GetPropertyAsArrayInt
wxArrayInt ObjectBase::GetPropertyAsArrayInt(const wxString& pname)
{
wxArrayInt array;
PProperty property = GetProperty( pname );
if (property)
{
IntList il( property->GetValue(), property->GetType() == PT_UINTLIST );
for (unsigned int i=0; i < il.GetSize() ; i++)
array.Add(il.GetValue(i));
}
return array;
}
示例5: FindMacros
void CppCodeGenerator::FindMacros(PObjectBase obj, set<string> ¯o_set)
{
// recorre cada propiedad de cada objeto identificando aquellas
// que sean macros, en cuyo caso la añade al conjunto.
unsigned int i;
for (i=0; i<obj->GetPropertyCount(); i++)
{
PProperty prop = obj->GetProperty(i);
if (prop->GetType() == PT_MACRO)
macro_set.insert(prop->GetValue());
}
for (i=0; i<obj->GetChildCount(); i++)
{
FindMacros(obj->GetChild(i),macro_set);
}
}
示例6: PropertyToCode
/**
* Convierte el valor de una propiedad a código C++.
*/
string CppTemplateParser::PropertyToCode(PProperty property)
{
PropertyType type = property->GetType();
string value = property->GetValue();
string result;
switch (type)
{
case PT_WXSTRING:
// TO-DO's
// Las cadenas de caracteres (wxString) hay que pasarlas a cadenas tipo "C"
// "Hola" -> wxT("\"Hola\"")
result = "wxT(\"" + ConvertCppString(value) + "\")";
break;
case PT_MACRO:
case PT_TEXT:
case PT_OPTION:
result = value;
break;
case PT_BITLIST:
if (value == "")
result = "0";
else
result = value;
break;
case PT_WXPOINT:
if (value == "")
result = "wxDefaultPosition";
else
result = "wxPoint(" + value + ")";
break;
case PT_WXSIZE:
if (value == "")
result = "wxDefaultSize";
else
result = "wxSize(" + value + ")";
break;
case PT_BOOL:
if (value == "0")
result = "false";
else
result = "true";
break;
case PT_WXFONT:
if (value != "")
{
wxFont font =
TypeConv::StringToFont(wxString(value.c_str(),wxConvUTF8));
wxString underlined(wxT("false"));
if (font.GetUnderlined())
underlined = wxT("true");
wxString font_str = wxString::Format(wxT("wxFont(%d,%d,%d,%d,%s,wxT(\"%s\"))"),
font.GetPointSize(),
font.GetFamily(),
font.GetStyle(),
font.GetWeight(),
underlined.c_str(),
font.GetFaceName().c_str());
result = string(font_str.mb_str());
}
else
result = "wxFont()";
break;
case PT_WXCOLOUR:
if (value != "")
{
wxColour colour =
TypeConv::StringToColour(wxString(value.c_str(),wxConvUTF8));
wxString col_str = wxString::Format(wxT("wxColour(%d,%d,%d)"),
colour.Red(),colour.Green(),colour.Blue());
result = string(col_str.mb_str());
}
else
result = "wxColour()";
break;
case PT_BITMAP:
// La generación de esta propiedad es provisional ya que la idea
// principal es que los archivos xpm se incluyan (#include) en el
// fichero cpp y no cargarlo de un fichero.
result = "wxBitmap(wxT(\"" + ConvertCppString(value)
+ "\"), wxBITMAP_TYPE_XPM)";
break;
default:
break;
}
return result;
}