本文整理汇总了C++中UmlPackage类的典型用法代码示例。如果您正苦于以下问题:C++ UmlPackage类的具体用法?C++ UmlPackage怎么用?C++ UmlPackage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了UmlPackage类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: javaSource
void UmlArtifact::roundtrip_java()
{
if (! managed) {
managed = TRUE;
if (stereotype() != "source")
return;
const WrapperStr srcdef = javaSource();
if (srcdef.isEmpty())
return;
const WrapperStr & name = UmlArtifact::name();
UmlPackage * pack = package();
WrapperStr src_path = pack->java_path(name);
{
WrapperStr s = " <i> " + src_path + "</i>";
UmlCom::message(name);
if (verbose())
UmlCom::trace(WrapperStr("<hr><font face=helvetica>roundtrip body from")
+ s + "</font><br>");
else
set_trace_header(WrapperStr("<font face=helvetica>roundtrip body from")
+ s + "</font><br>");
}
UmlOperation::roundtrip(src_path, javaLanguage);
}
}
开发者ID:ErickCastellanos,项目名称:douml,代码行数:33,代码来源:UmlArtifact.cpp
示例2: getProject
void UmlPackage::fileControl(bool ci) {
UmlPackage * prj = getProject();
Q3CString prjfile = prj->supportFile();
BooL rec;
BooL reload;
Q3CString cmd;
if (! prj->propertyValue((ci) ? "check-in-cmd" : "check-out-cmd", cmd))
cmd = "specify the command containing %file and %dir or %dironly";
Dialog dialog(ci, cmd, rec, reload); // the dialog execution set 'cmd' and 'rec'
if (dialog.exec() == QDialog::Accepted) {
// save the command for a future usage
prj->set_PropertyValue((ci) ? "check-in-cmd" : "check-out-cmd", cmd);
if (reload)
saveProject();
// get files list
Q3Dict<void> files;
getFiles(files, (rec) ? ~0u : 1);
if (this == prj)
getAuxFiles(files);
// apply the command on each file
Q3DictIterator<void> it(files);
QFileInfo prjpath(prjfile);
QString dir = prjpath.dirPath(TRUE);
QString dironly = dir;
int index;
if ((dironly.length() > 3) &&
(((const char *) dironly)[1] == ':') &&
(((const char *) dironly)[2] == '/'))
dironly = dironly.mid(2);
while ((index = cmd.find("%dironly")) != -1)
cmd.replace(index, 8, dironly);
while ((index = cmd.find("%dir")) != -1)
cmd.replace(index, 4, dir);
while (it.current()) {
QString s = cmd;
while ((index = s.find("%file")) != -1)
s.replace(index, 5, it.currentKey());
system((const char *) s);
++it;
}
UmlCom::trace("Done.");
if (reload)
loadProject(prjfile);
}
}
开发者ID:SciBoy,项目名称:douml,代码行数:60,代码来源:UmlPackage.cpp
示例3: parent
UmlClass * UmlClass::addMetaclass(WrapperStr mclname, const char * mclpath)
{
UmlPackage * pack = (UmlPackage *) parent()->parent(); // is a package
const Q3PtrVector<UmlItem> ch = pack->children();
unsigned n = ch.size();
UmlClass * r = 0;
for (unsigned i = 0; i != n; i += 1) {
UmlItem * x = ch[i];
if ((x->kind() == aClassView) &&
!strncmp(x->name(), "meta classes", 12) &&
((r = UmlClass::create(x, mclname)) != 0))
break;
}
if (r == 0) {
WrapperStr s = "meta classes";
UmlItem * v = 0;
while ((v = UmlClassView::create(pack, s)) == 0)
s += "_";
r = UmlClass::create(v, mclname);
}
r->set_Stereotype("metaclass");
if (mclpath != 0)
r->set_PropertyValue("metaclassPath", mclpath);
return r;
}
开发者ID:daniel7solis,项目名称:douml,代码行数:33,代码来源:UmlClass.cpp
示例4: parent
void UmlArtifact::genpro() {
UmlPackage * pack = (UmlPackage *) parent()->parent();
Q3CString path;
if (! propertyValue("genpro path", path)) {
path = pack->cppSrcDir();
if (path.isEmpty())
path = root_dir();
else if (QDir::isRelativePath(path)) {
QDir d(root_dir());
d.cd(path);
path = d.absPath();
}
}
if (stereotype() == "executable") {
gen_app(path);
}
else
UmlCom::trace(stereotype() + " : not managed");
}
开发者ID:SciBoy,项目名称:douml,代码行数:25,代码来源:UmlArtifact.cpp
示例5: associatedArtifact
void UmlClass::import(QTextOStream & f, const QCString & indent) {
QCString s;
if (!isJavaExternal()) {
UmlArtifact * cp = associatedArtifact();
UmlPackage * pack = (UmlPackage *)
((cp != 0) ? (UmlItem *) cp : (UmlItem *) this)->package();
if ((s = pack->javaPackage()).isEmpty())
return;
QCString s2 = name();
UmlItem * p = this;
while ((p = p->parent())->kind() == aClass)
s2 = p->name() + dot + s2;
s += dot + s2;
}
else if ((s = package()->javaPackage()).isEmpty())
return;
else
s += dot + name();
if (! UmlArtifact::generated_one()->is_imported(s)) {
f << indent << "import " << s << ";\n";
UmlArtifact::generated_one()->imported(s);
}
}
开发者ID:,项目名称:,代码行数:29,代码来源:
示例6: parent
void UmlClass::need_artifact(const QStringList & imports,
bool remove_java_lang,
const QStringList & ,
const WrapperStr & path, UmlArtifact *& cp)
{
if (parent()->kind() == aClassView) {
if (cp != 0)
cp->addAssociatedClass(this);
else {
UmlPackage * pack = (UmlPackage *) parent()->parent();
if ((cp = associatedArtifact()) == 0) {
// create associated artifact
QFileInfo fi(path);
WrapperStr artname = WrapperStr(fi.baseName().toAscii().constData());
if ((cp = UmlBaseArtifact::create(pack->get_deploymentview(), artname)) == 0) {
UmlCom::trace(WrapperStr("<font face=helvetica><b>cannot create<i> artifact ")
+ artname + "</i></b></font><br>");
return;
}
cp->addAssociatedClass(this);
}
cp->set_Stereotype("source");
WrapperStr s = JavaSettings::sourceContent();
int index = s.find("${definition}");
if (index != -1) {
for (QStringList::const_iterator it = imports.begin(); it != imports.end(); it++) {
WrapperStr import = WrapperStr((*it).toAscii().constData());
if (!remove_java_lang || (import != "java.lang.")) {
import += (((const char *) import)[import.length() - 1] == '.')
? "*;\n" : ";\n";
s.insert(index, (const char *)("import " + import));
index = s.find("${definition}", index);
}
}
for (QStringList::const_iterator it = imports.begin(); it != imports.end(); it++) {
s.insert(index, (const char *)("import static" + WrapperStr((*it).toAscii().constData()) + '\n'));
index = s.find("${definition}", index);
}
}
cp->set_JavaSource(WrapperStr(s));
}
}
}
开发者ID:,项目名称:,代码行数:55,代码来源:
示例7: getProject
UmlPackage * UmlPackage::importProfile(FileIn & in, WrapperStr href)
{
if (!href.isEmpty() && (href.left(5) != "http:") && (href.left(8) != "pathmap:")) {
int index = href.find('#');
if (index != -1) {
WrapperStr id = href.mid(index + 1);
QMap<WrapperStr, UmlItem *>::Iterator it = All.find(id);
if (it == All.end()) {
UmlPackage * pf = getProject()->findProfile(id);
if (pf == 0) {
QFileInfo fi(in.path());
QDir d(fi.dir(TRUE));
QString fn = d.absFilePath(href.left(index));
if (QFile::exists(fn)) {
WrapperStr cmd = qApp->argv()[0] + WrapperStr(" ") + WrapperStr((const char *)fn); //[rageek] ambiguous, cast
int pid = UmlCom::targetItem()->apply(cmd);
while (isToolRunning(pid)) {
#ifdef WIN32
Sleep(1000);
#else
sleep(1);
#endif
}
UmlCom::targetItem()->unload(FALSE, FALSE); // to reread children
if ((pf = ((UmlPackage *) UmlCom::targetItem())->findProfile(id)) != 0)
// not in Bouml case
pf->loadFromProfile();
}
else
in.warning("can't open " + href.left(index));
}
else
// not in Bouml case
pf->loadFromProfile();
return pf;
}
else if ((*it)->kind() == aPackage)
return (UmlPackage *) *it;
}
}
return 0;
}
开发者ID:bleakxanadu,项目名称:douml,代码行数:51,代码来源:UmlPackage.cpp
示例8: javaSource
void UmlArtifact::generate_text()
{
const WrapperStr srcdef = javaSource();
if (srcdef.isEmpty()) {
if (verbose())
UmlCom::trace(WrapperStr("<hr><font face=helvetica>artifact <i>")
+ name() + "</i> has an empty Java definition</font><br>");
return;
}
UmlPackage * pack = package();
const WrapperStr & name = UmlArtifact::name();
WrapperStr src_path = pack->text_path(name);
WrapperStr s = " in <i> " + src_path + "</i>";
UmlCom::message(name);
if (verbose())
UmlCom::trace(WrapperStr("<hr><font face=helvetica>Generate code for <i> ")
+ name + "</i>" + s + "</font><br>");
else
set_trace_header(WrapperStr("<font face=helvetica>Generate code for <i> ")
+ name + "</i>" + s + "</font><br>");
if (must_be_saved(src_path, (const char *) srcdef)) {
write_trace_header();
FILE * fp_src;
if ((fp_src = fopen((const char *) src_path, "wb")) == 0) {
write_trace_header();
UmlCom::trace(WrapperStr("<font color=\"red\"><b><i> ")
+ name + " : </i> cannot open <i> "
+ src_path + "</i>, edit the <i> generation settings</i> (tab directory) or the <i>"
+ pack->name() + "</i> Java directory specification</b></font><br>");
incr_error();
}
else {
fputs((const char *) srcdef, fp_src);
fclose(fp_src);
}
}
else if (get_trace_header().isEmpty())
UmlCom::trace(WrapperStr("<font face=helvetica><i> ")
+ src_path + "</i> not modified</font><br>");
}
开发者ID:ErickCastellanos,项目名称:douml,代码行数:49,代码来源:UmlArtifact.cpp
示例9: javaDecl
void UmlClass::write(QTextOStream & f) {
if (isJavaExternal()) {
QCString s = javaDecl().stripWhiteSpace();
int index;
if ((index = s.find("${name}")) != -1)
s.replace(index, 7, name());
else if ((index = s.find("${Name}")) != -1)
s.replace(index, 7, capitalize(name()));
else if ((index = s.find("${NAME}")) != -1)
s.replace(index, 7, name().upper());
else if ((index = s.find("${nAME}")) != -1)
s.replace(index, 7, name().lower());
f << s;
}
else {
UmlClass * toplevel = this;
UmlItem * p;
QCString s2;
while ((p = toplevel->parent())->kind() == aClass) {
toplevel = (UmlClass *) p;
s2 = dot + p->name() + s2;
}
UmlArtifact * cp = toplevel->associatedArtifact();
UmlPackage * pack = (UmlPackage *)
((cp != 0) ? (UmlItem *) cp : (UmlItem *) toplevel)->package();
if (pack != UmlArtifact::generation_package()) {
QCString s = pack->javaPackage();
if (! s.isEmpty() && (s != "java.lang") && (s.left(10) != "java.lang.")) {
s += s2;
if (JavaSettings::isForcePackagePrefixGeneration() ||
!UmlArtifact::generated_one()->is_imported(s, name()))
f << s << '.';
}
}
else if (! s2.isEmpty())
f << s2.mid(1) << '.';
f << name();
}
}
开发者ID:,项目名称:,代码行数:47,代码来源:
示例10: cppHeader
void UmlArtifact::roundtrip_cpp()
{
if (! managed) {
managed = TRUE;
if (stereotype() != "source")
return;
const WrapperStr hdef = cppHeader();
const WrapperStr srcdef = cppSource();
if (hdef.isEmpty() && srcdef.isEmpty())
return;
const WrapperStr & name = UmlArtifact::name();
UmlPackage * pack = package();
WrapperStr h_path = pack->header_path(name);
WrapperStr src_path = pack->source_path(name);
{
WrapperStr s;
if (!hdef.isEmpty())
s = "<i> " + h_path + "</i>";
if (!srcdef.isEmpty()) {
if (!hdef.isEmpty())
s += " and <i> " + src_path + "</i>";
else
s = "<i> " + src_path + "</i>";
}
UmlCom::message(name);
if (verbose())
UmlCom::trace(WrapperStr("<hr><font face=helvetica>roundtrip body from")
+ s + "</font><br>");
else
set_trace_header(WrapperStr("<font face=helvetica>roundtrip body from")
+ s + "</font><br>");
}
UmlOperation::roundtrip(h_path, cppLanguage);
UmlOperation::roundtrip(src_path, cppLanguage);
}
}
开发者ID:ErickCastellanos,项目名称:douml,代码行数:46,代码来源:UmlArtifact.cpp
示例11: while
void Package::send_dir(bool rec)
{
// reverse phase
UmlPackage * prj = root->uml;
while (prj->parent() != 0)
prj = (UmlPackage *) prj->parent();
prj->set_childrenVisible(FALSE);
QDir d(path);
progress = new Progress(file_number(d, TRUE),
(scan) ? "Scanning in progress, please wait ..."
: "Reverse in progress, please wait ...");
reverse_directory(d, rec);
if (progress != 0)
delete progress;
((uml) ? uml : root->uml)->set_childrenVisible(TRUE);
}
开发者ID:jeremysalwen,项目名称:douml,代码行数:23,代码来源:Package.cpp
示例12: name
UmlClassView * UmlPackage::get_classview(const Q3CString & nmsp) {
UmlPackage * pack;
if (nmsp != cppNamespace()) {
if (namespace_fixedp) {
if ((pack = findCppNamespace(nmsp)) == 0) {
Q3CString s = nmsp;
if (s.isEmpty())
s = name();
else {
int index = 0;
while ((index = s.find("::", index)) != -1)
s.replace(index++, 2, " ");
}
if (((pack = UmlBasePackage::create(this, s)) == 0) &&
((pack = UmlBasePackage::create(this, s += "_")) == 0) &&
((pack = UmlBasePackage::create(this, s += "_")) == 0) &&
((pack = UmlBasePackage::create(this, s += "_")) == 0) &&
((pack = UmlBasePackage::create(this, s += "_")) == 0)) {
#ifdef REVERSE
UmlCom::trace(Q3CString("<font face=helvetica><b>cannot create package <i>")
+ s + "</i> under package <i>"
+ name() + "</b></font><br>");
UmlCom::message("");
throw 0;
#else
QMessageBox::critical(0, "Fatal Error",
Q3CString("<font face=helvetica><b>cannot create package <i>")
+ s + "</i> under package <i>"
+ Name() + "</b></font><br>");
QApplication::exit(1);
#endif
}
pack->set_CppNamespace(nmsp);
pack->set_CppSrcDir(cppSrcDir());
pack->set_CppHDir(cppHDir());
pack->namespace_fixedp = TRUE;
}
}
else {
pack = this;
pack->set_CppNamespace(nmsp);
pack->namespace_fixedp = TRUE;
}
}
else
pack = this;
if (pack->class_view == 0) {
Q3PtrVector<UmlItem> ch = pack->children();
for (unsigned index = 0; index != ch.size(); index += 1)
// return the first class view find
if (ch[index]->kind() == aClassView)
return pack->class_view = (UmlClassView *) ch[index];
if ((pack->class_view = UmlBaseClassView::create(pack, name())) == 0) {
#ifdef REVERSE
UmlCom::trace(Q3CString("<font face=helvetica><b>cannot create class view <i>")
+ name() + "</i> under package <i>"
+ pack->name() + "</b></font><br>");
UmlCom::message("");
throw 0;
#else
QMessageBox::critical(0, "Fatal Error",
Q3CString("<font face=helvetica><b>cannot create class view <i>")
+ name() + "</i> under package <i>"
+ pack->name() + "</b></font><br>");
QApplication::exit(1);
#endif
}
}
return pack->class_view;
}
开发者ID:SciBoy,项目名称:douml,代码行数:79,代码来源:UmlPackage.cpp
示例13: main
int main(int argc, char ** argv)
{
if (argc != 2)
return 0;
if (UmlCom::connect(Q3CString(argv[1]).toUInt())) {
bool aborted = TRUE;
try {
UmlCom::trace("<b>C++ roundtrip</b> release 1.3<br>");
UmlCom::traceAutoRaise(FALSE);
char * argv = 0;
int argc = 0;
QApplication * app = new QApplication(argc, &argv);
UmlItem * item = UmlCom::targetItem();
int n;
switch (item->kind()) {
default:
UmlCom::trace("<font face=helvetica><b>must be applied on a <i>package, class view, deployment view, artifact</i> or <i>class</i></b></font><br>");
aborted = FALSE;
throw 0;
case aPackage:
n = ((UmlPackage *) item)->count_roundtriped();
break;
case aClassView:
case aDeploymentView:
case anArtifact:
n = 1;
break;
case aClass:
if (item->parent()->kind() != aClassView) {
UmlCom::trace("<font face=helvetica><b>can't be applied on a <i>class</i> nested or out of a <i>class view</i></b></font><br>");
aborted = FALSE;
throw 0;
}
n = 1;
break;
}
UmlPackage * project = UmlPackage::getProject();
UmlCom::trace("<font face=helvetica>Upload project ...</font>");
Package::init(project, app);
UmlCom::trace("<font face=helvetica>...done</font><br>");
UmlCom::message("");
Package::set_step(0, n);
UmlCom::trace("<font face=helvetica>Preparation...</font>");
if (!item->set_roundtrip_expected() &&
(QMessageBox::warning(0, "Roundtrip",
"Some elements to roundtrip are read-only and will not be updated\n\n"
"Roundtrip anyway ?",
"Yes", "No", QString::null, 1, 1)
!= 0)) {
aborted = FALSE;
throw 0;
}
Package::set_step(0, -1);
UmlCom::trace("<font face=helvetica>...done</font><br>");
if ((item->kind() == aPackage) && !UmlArtifact::is_roundtrip_usefull()) {
UmlCom::trace("<font face=helvetica>you don't ask for to roundtrip artifact(s)<br><br>"
"probably you want to do a <i>reverse</i> rather than a <i>roundtrip</i></font><br>");
aborted = FALSE;
throw 0;
}
Q3CString f;
if (project->propertyValue("#file", f))
Lex::defines(f);
n = 0;
item->scan_it(n);
CppSettings::set_UseDefaults(TRUE);
project->set_childrenVisible(FALSE);
item->send_it(n);
UmlOperation::force_defs();
Statistic::produce();
// umark all
{
Q3PtrVector<UmlItem> marked = UmlItem::markedItems();
UmlItem ** v = marked.data();
UmlItem ** const vsup = v + marked.size();
for (;v != vsup; v += 1)
(*v)->set_isMarked(FALSE);
}
Q3PtrList<UmlItem> useless;
item->mark_useless(useless);
if (!useless.isEmpty() &&
(QMessageBox::warning(0, "C++ roundtrip",
"The marked elements are useless because they don't\n"
//.........这里部分代码省略.........
开发者ID:SciBoy,项目名称:douml,代码行数:101,代码来源:main.cpp
示例14: getProject
void UmlPackage::fileControl(bool ci)
{
UmlPackage * prj = getProject();
QByteArray prjfile = prj->supportFile();
BooL rec;
BooL reload;
QByteArray cmd;
if (! prj->propertyValue((ci) ? "check-in-cmd" : "check-out-cmd", cmd))
cmd = "specify the command containing %file and %dir or %dironly";
Dialog dialog(ci, cmd, rec, reload); // the dialog execution set 'cmd' and 'rec'
if (dialog.exec() == QDialog::Accepted) {
// save the command for a future usage
prj->set_PropertyValue((ci) ? "check-in-cmd" : "check-out-cmd", cmd);
if (reload)
saveProject();
// get files list
QHash<QString,void*> files;
getFiles(files, (rec) ? ~0u : 1);
if (this == prj)
getAuxFiles(files);
// apply the command on each file
QHashIterator<QString,void*> it(files);
QFileInfo prjpath(prjfile);
QString dir = prjpath.path();
QString dironly = dir;
int index;
if ((dironly.length() > 3) &&
(dironly[1] == ':') &&
(dironly[2] == '/'))
dironly = dironly.mid(2);
while ((index = cmd.indexOf("%dironly")) != -1)
cmd.replace(index, 8, dironly.toLatin1());
while ((index = cmd.indexOf("%dir")) != -1)
cmd.replace(index, 4, dir.toLatin1());
while (it.hasNext()) {
it.next();
QString s = cmd;
while ((index = s.indexOf("%file")) != -1)
s.replace(index, 5, it.key().toLatin1());
system((const char *) s.toLatin1().constData());
//++it;
}
UmlCom::trace("Done.");
if (reload)
loadProject(prjfile);
}
}
开发者ID:DoUML,项目名称:douml,代码行数:63,代码来源:UmlPackage.cpp
示例15: while
void UmlPackage::importIt(FileIn & in, Token & token, UmlItem * where)
{
while (where->kind() != aPackage)
where = where->parent();
WrapperStr s = token.valueOf("name");
if (s.isEmpty()) {
static unsigned n = 0;
s.sprintf("anonymous %u", ++n);
}
UmlPackage * pack = create((UmlPackage *) where, s);
if (pack == 0)
in.error("cannot create package '" + s + "' in '" + where->name() + "'");
bool profile =
(token.what() == "uml:profile") || (token.xmiType() == "uml:Profile");
if (profile) {
pack->set_Stereotype("profile");
pack->set_PropertyValue("xmiId", token.xmiId());
NumberOf -= 1;
NumberOfProfile += 1;
if (!(s = token.valueOf("metamodelreference")).isEmpty())
pack->set_PropertyValue("metamodelReference", s);
if (!(s = token.valueOf("metaclassreference")).isEmpty())
pack->set_PropertyValue("metaclassReference", s);
}
s = token.xmiId();
if (!s.isEmpty()) {
pack->addItem(s, in);
if (! token.closed()) {
WrapperStr k = token.what();
const char * kstr = k;
if (profile) {
while (in.read(), !token.close(kstr)) {
if ((token.what() == "packagedelement") &&
(token.xmiType() == "uml:Extension")) {
if (! token.closed())
in.finish(token.what());
}
else if (token.what() == "packageimport")
pack->packageImport(in, token);
else
pack->UmlItem::import(in, token);
}
updateProfiles();
}
else
while (in.read(), !token.close(kstr))
pack->UmlItem::import(in, token);
}
}
else if (! token.valueOf("href", s))
in.error("xmi:id is missing"); // doesn't return
else {
in.warning("bypass external package " + s);
if (! token.closed())
in.finish(token.what());
}
pack->unload(TRUE, FALSE);
}
开发者ID:bleakxanadu,项目名称:douml,代码行数:74,代码来源:UmlPackage.cpp
示例16: if
void CppRefType::compute(Q3PtrList<CppRefType> & dependencies,
const WrapperStr & hdef, const WrapperStr & srcdef,
WrapperStr & h_incl, WrapperStr & decl, WrapperStr & src_incl,
UmlArtifact * who)
{
UmlPackage * pack = who->package();
WrapperStr hdir;
WrapperStr srcdir;
if (CppSettings::isRelativePath()) {
WrapperStr empty;
hdir = pack->header_path(empty);
srcdir = pack->source_path(empty);
}
else if (CppSettings::isRootRelativePath())
hdir = srcdir = UmlPackage::rootDir();
// aze.cpp includes aze.h
src_incl += "#include \"";
if (CppSettings::includeWithPath())
src_incl += pack->header_path(who->name(), srcdir);
else {
src_incl += who->name();
src_incl += '.';
src_incl += CppSettings::headerExtension();
}
src_incl += "\"\n";
h_incl = ""; // to not be WrapperStr::null
decl = ""; // to not be WrapperStr::null
CppRefType * ref;
for (ref = dependencies.first(); ref != 0; ref = dependencies.next())
{
UmlClass * cl = (ref->type.type)
? ref->type.type
: UmlBaseClass::get(ref->type.explicit_type, 0);
bool included = ref->included;
WrapperStr hform; // form in header
WrapperStr srcform; // form in source
if (cl == 0) {
WrapperStr in = CppSettings::include(ref->type.explicit_type);
if (!in.isEmpty())
hform = srcform = in + '\n';
else
// doesn't know what it is
continue;
}
else if (cl->isCppExternal())
{
QString className = cl->name();
hform = cl->cppDecl();
int index;
if ((index = hform.find('\n')) == -1)
// wrong form
continue;
hform = hform.mid(index + 1) + '\n';
for (;;) {
if ((index = hform.find("${name}")) != -1)
hform.replace(index, 7, cl->name());
else if ((index = hform.find("${Name}")) != -1)
hform.replace(index, 7, capitalize(cl->name()));
else if ((index = hform.find("${NAME}")) != -1)
hform.replace(index, 7, cl->name().upper());
else if ((index = hform.find("${nAME}")) != -1)
hform.replace(index, 7, cl->name().lower());
else
break;
}
srcform = hform;
}
else {
QString className = cl->name();
WrapperStr st = cl->cpp_stereotype();
if ((st == "enum") || (st == "typedef"))
included = TRUE;
UmlArtifact * art = cl->associatedArtifact();
if (art != 0) {
if (art == who)
// don't include itself
continue;
if (CppSettings::includeWithPath()) {
UmlPackage * p = art->package();
hform = "#include \"" + p->header_path(art->name(), hdir) + "\"\n";
//.........这里部分代码省略.........
开发者ID:lollisoft,项目名称:douml,代码行数:101,代码来源:CppRefType.cpp
示例17: generate_text
void UmlArtifact::generate() {
if (! managed) {
managed = TRUE;
if (stereotype() == "text") {
generate_text();
return;
}
else if (stereotype() != "source")
return;
package_of_generated_artifact = package();
const Q3CString def = idlSource();
if (def.isEmpty())
return;
const Q3CString & name = this->name();
UmlPackage * pack = package();
Q3CString path = pack->path(name);
Q3CString mod_start;
Q3CString mod_end;
Q3CString mod = pack->idlModule();
if (! mod.isEmpty()) {
int index = 0;
int index2;
Q3CString closed = "\n}; // module ";
while ((index2 = mod.find(':', index)) != -1) {
Q3CString mo = mod.mid(index, index2 - index);
mod_start += Q3CString("module ") + mo + " {\n\n";
closed += mo;
mod_end = closed + "\n" + mod_end;
closed += "::";
mod.replace(index2, 2, "_");
index = index2 + 1;
}
mod_start += Q3CString("module ") + mod.mid(index) + " {\n\n";
closed += mod.mid(index);
mod_end = closed + "\n" + mod_end;
}
UmlCom::message(name);
if (verbose())
UmlCom::trace(Q3CString("<hr><font face=helvetica>Generate code for <i> ")
+ name + "</i> in <i>" + path + "</i></font><br>");
else
set_trace_header(Q3CString("<font face=helvetica>Generate code for <i> ")
+ name + "</i> in <i>" + path + "</i></font><br>");
#if 0
// compute dependencies
Q3PtrList<CppRefType> dependencies;
#endif
const Q3PtrVector<UmlClass> & cls = associatedClasses();
unsigned n = cls.count();
unsigned index;
#if 0
for (index = 0; index != n; index += 1)
cls[index]->compute_dependencies(dependencies);
#endif
// generate source file
QByteArray file;
QTextOStream f(&file);
const char * p = def;
const char * pp = 0;
for (;;) {
if (*p == 0) {
if (pp == 0)
break;
// comment management done
p = pp;
pp = 0;
if (*p == 0)
break;
}
if (*p == '@')
manage_alias(p, f);
else if (*p != '$')
f << *p++;
else if (!strncmp(p, "${comment}", 10))
manage_comment(p, pp);
else if (!strncmp(p, "${description}", 14))
manage_description(p, pp);
else if (!strncmp(p, "${name}", 7)) {
p += 7;
f << name;
}
else if (!strncmp(p, "${Name}", 7)) {
//.........这里部分代码省略.........
开发者ID:SciBoy,项目名称:douml,代码行数:101,代码来源:UmlArtifact.cpp
示例18: generate_text
void UmlArtifact::generate()
{
if (! managed) {
managed = TRUE;
if (stereotype() == "text") {
generate_text();
return;
}
else if (stereotype() != "source")
return;
package_of_generated_artifact = package();
const WrapperStr hdef = cppHeader();
QLOG_INFO() << "Read header as: " + hdef.operator QString();
const WrapperStr srcdef = cppSource();
if (hdef.isEmpty() && srcdef.isEmpty()) {
if (verbose())
UmlCom::trace(WrapperStr("<hr><font face=helvetica>artifact <i>")
+ name() + "</i> has an empty C++ definition</font><br>");
return;
}
const WrapperStr & name = UmlArtifact::name();
UmlPackage * pack = package();
WrapperStr h_path = pack->header_path(name);
WrapperStr src_path = pack->source_path(name);
WrapperStr nasp_start;
WrapperStr nasp_end;
const char * cnasp = pack->cppNamespace();
WrapperStr nasp = ((cnasp[0] == ':') && (cnasp[1] == ':'))
? cnasp + 2 : cnasp;
if (!nasp.isEmpty()) {
int index = 0;
int index2;
WrapperStr closed = "\n} // namespace ";
while ((index2 = nasp.find(':', index)) != -1) {
WrapperStr na = nasp.mid(index, index2 - index);
nasp_start += WrapperStr("namespace ") + na + " {\n\n";
closed += na;
nasp_end = closed + "\n" + nasp_end;
closed += "::";
nasp.replace(index2, 2, "_");
index = index2 + 1;
}
nasp_start += WrapperStr("namespace ") + nasp.mid(index) + " {\n\n";
closed += nasp.mid(index);
nasp_end = closed + "\n" + nasp_end;
}
else {
WrapperStr s;
if (!hdef.isEmpty())
s = " in <i> " + h_path + "</i>";
if (!srcdef.isEmpty()) {
if (!hdef.isEmpty())
s += " and <i> " + src_path + "</i>";
else
s = " in <i> " + src_path + "</i>";
}
UmlCom::message(name);
if (verbose())
UmlCom::trace(WrapperStr("<hr><font face=helvetica>Generate code for <i> ")
+ name + "</i>" + s + "</font><br>");
else
set_trace_header(WrapperStr("<font face=helvetica>Generate code for <i> ")
+ name + "</i>" + s + "</font><br>");
}
// get bodies if preserve
const Q3PtrVector<UmlClass> & cls = associatedClasses();
if (preserve())
UmlOperation::read_bodies(h_path, src_path);
// compute dependencies
bool all_in_h = (hdef.find("${all_includes}") != -1);
Q3PtrList<CppRefType> dependencies;
unsigned n = cls.count();
unsigned index;
for (index = 0; index != n; index += 1)
cls[index]->compute_dependencies(dependencies, all_in_h);
// generate header file
WrapperStr h_incl;
WrapperStr src_incl;
WrapperStr decl;
//.........这里部分代码省略.........
开发者ID:harmegnies,项目名称:douml,代码行数:101,代码来源:UmlArtifact.cpp
注:本文中的UmlPackage类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论