本文整理汇总了C++中UmlPackage类的典型用法代码示例。如果您正苦于以下问题:C++ UmlPackage类的具体用法?C++ UmlPackage怎么用?C++ UmlPackage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了UmlPackage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}
示例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);
}
}
示例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;
}
示例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");
}
示例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);
}
}
示例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));
}
}
}
示例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;
}
示例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>");
}
示例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();
}
}
示例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);
}
}
示例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);
}
示例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;
}
示例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"
//.........这里部分代码省略.........
示例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);
}
}
示例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);
}