本文整理汇总了C++中StringLiteral::setValue方法的典型用法代码示例。如果您正苦于以下问题:C++ StringLiteral::setValue方法的具体用法?C++ StringLiteral::setValue怎么用?C++ StringLiteral::setValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringLiteral
的用法示例。
在下文中一共展示了StringLiteral::setValue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
TEST(OOModel, JavaLibraryAndHelloWorldTest)
{
Model::Model model;
Project* prj = dynamic_cast<Project*> (model.createRoot("Project"));
model.beginModification(prj, "build simple java library and a hello world app");
prj->setName("HelloWorld");
// Build a simple Java Library
Library* java = prj->libraries()->append<Library>();
java->setName("Java");
Class* string = java->classes()->append<Class>();
string->setName("String");
string->setVisibility(Visibility::PUBLIC);
Module* io = java->modules()->append<Module>();
io->setName("io");
Class* printstream = io->classes()->append<Class>();
printstream->setName("PrintStream");
printstream->setVisibility(Visibility::PUBLIC);
Method* println = printstream->methods()->append<Method>();
println->setName("println");
println->setVisibility(Visibility::PUBLIC);
FormalArgument* arg = println->arguments()->append<FormalArgument>();
arg->setName("x");
NamedType* argType = arg->setType<NamedType>();
argType->type()->ref()->set("class:String");
Class* system = java->classes()->append<Class>();
system->setName("System");
system->setVisibility(Visibility::PUBLIC);
Field* out = system->fields()->append<Field>();
out->setName("out");
out->setVisibility(Visibility::PUBLIC);
out->setStorageSpecifier(StorageSpecifier::CLASS_VARIABLE);
NamedType* outtype = out->setType<NamedType>();
outtype->type()->ref()->set("class:PrintStream");
outtype->type()->setPrefix<ReferenceExpression>()->ref()->set("mod:io");
// Build a simple HelloWorld Application
Class* hello = prj->classes()->append<Class>();
hello->setName("HelloWorld");
hello->setVisibility(Visibility::PUBLIC);
Method* main = hello->methods()->append<Method>();
main->setName("main");
main->setVisibility(Visibility::PUBLIC);
main->setStorageSpecifier(StorageSpecifier::CLASS_VARIABLE);
//TODO make an array argument
MethodCallStatement* callPrintln = main->items()->append<MethodCallStatement>();
StringLiteral* helloStr = callPrintln->arguments()->append<StringLiteral>();
helloStr->setValue("Hello World");
callPrintln->ref()->set("met:println");
VariableAccess* va = callPrintln->setPrefix<VariableAccess>();
va->ref()->set("field:out");
ReferenceExpression* ref = va->setPrefix<ReferenceExpression>();
ref->ref()->set("lib:Java,class:System");
model.endModification();
CHECK_STR_EQUAL("Java", java->name());
CHECK_CONDITION(callPrintln->methodDefinition() != nullptr);
CHECK_CONDITION(callPrintln->methodDefinition() == println);
}