本文整理汇总了C++中document::Ptr类的典型用法代码示例。如果您正苦于以下问题:C++ Ptr类的具体用法?C++ Ptr怎么用?C++ Ptr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Ptr类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: RefactoringFile
QmlJSRefactoringFile::QmlJSRefactoringFile(TextEditor::TextEditorWidget *editor, Document::Ptr document)
: RefactoringFile(editor)
, m_qmljsDocument(document)
{
m_fileName = document->fileName();
}
开发者ID:AgnosticPope,项目名称:qt-creator,代码行数:6,代码来源:qmljsrefactoringchanges.cpp
示例2: sourceNeeded
void CppPreprocessor::sourceNeeded(unsigned line, const QString &fileName, IncludeType type)
{
typedef Document::DiagnosticMessage Message;
if (fileName.isEmpty())
return;
QString absoluteFileName = resolveFile(fileName, type);
absoluteFileName = QDir::cleanPath(absoluteFileName);
if (m_currentDoc) {
m_currentDoc->addIncludeFile(Document::Include(fileName, absoluteFileName, line, type));
if (absoluteFileName.isEmpty()) {
const QString text = QCoreApplication::translate(
"CppPreprocessor", "%1: No such file or directory").arg(fileName);
Message message(Message::Warning, m_currentDoc->fileName(), line, /*column =*/ 0, text);
m_currentDoc->addDiagnosticMessage(message);
return;
}
}
if (m_included.contains(absoluteFileName))
return; // we've already seen this file.
if (absoluteFileName != modelManager()->configurationFileName())
m_included.insert(absoluteFileName);
// Already in snapshot? Use it!
Document::Ptr doc = m_snapshot.document(absoluteFileName);
if (doc) {
mergeEnvironment(doc);
return;
}
// Otherwise get file contents
unsigned editorRevision = 0;
QByteArray contents;
const bool gotFileContents = getFileContents(absoluteFileName, &contents, &editorRevision);
contents = convertToLatin1(contents);
if (m_currentDoc && !gotFileContents) {
const QString text = QCoreApplication::translate(
"CppPreprocessor", "%1: Could not get file contents").arg(fileName);
Message message(Message::Warning, m_currentDoc->fileName(), line, /*column =*/ 0, text);
m_currentDoc->addDiagnosticMessage(message);
return;
}
if (m_dumpFileNameWhileParsing) {
qDebug() << "Parsing file:" << absoluteFileName
<< "contents:" << contents.size() << "bytes";
}
doc = Document::create(absoluteFileName);
doc->setRevision(m_revision);
doc->setEditorRevision(editorRevision);
const QFileInfo info(absoluteFileName);
if (info.exists())
doc->setLastModified(info.lastModified());
const Document::Ptr previousDoc = switchDocument(doc);
const QByteArray preprocessedCode = m_preprocess.run(absoluteFileName, contents);
// {
// QByteArray b(preprocessedCode);
// b.replace("\n", "<<<\n");
// qDebug("Preprocessed code for \"%s\": [[%s]]", fileName.toUtf8().constData(),
// b.constData());
// }
QCryptographicHash hash(QCryptographicHash::Sha1);
hash.addData(preprocessedCode);
foreach (const Macro ¯o, doc->definedMacros()) {
if (macro.isHidden()) {
static const QByteArray undef("#undef ");
hash.addData(undef);
hash.addData(macro.name());
} else {
static const QByteArray def("#define ");
hash.addData(macro.name());
hash.addData(" ", 1);
hash.addData(def);
hash.addData(macro.definitionText());
}
hash.addData("\n", 1);
}
doc->setFingerprint(hash.result());
Document::Ptr anotherDoc = m_globalSnapshot.document(absoluteFileName);
if (anotherDoc && anotherDoc->fingerprint() == doc->fingerprint()) {
switchDocument(previousDoc);
mergeEnvironment(anotherDoc);
m_snapshot.insert(anotherDoc);
m_todo.remove(absoluteFileName);
return;
}
doc->setUtf8Source(preprocessedCode);
doc->keepSourceAndAST();
doc->tokenize();
m_snapshot.insert(doc);
m_todo.remove(absoluteFileName);
//.........这里部分代码省略.........
开发者ID:darksylinc,项目名称:qt-creator,代码行数:101,代码来源:cpppreprocessor.cpp
示例3: sourceNeeded
void CppPreprocessor::sourceNeeded(unsigned line, const QString &fileName, IncludeType type)
{
if (fileName.isEmpty())
return;
QString absoluteFileName = resolveFile(fileName, type);
absoluteFileName = QDir::cleanPath(absoluteFileName);
if (m_currentDoc)
m_currentDoc->addIncludeFile(Document::Include(fileName, absoluteFileName, line, type));
if (m_included.contains(absoluteFileName))
return; // we've already seen this file.
if (absoluteFileName != modelManager()->configurationFileName())
m_included.insert(absoluteFileName);
unsigned editorRevision = 0;
QByteArray contents;
getFileContents(absoluteFileName, &contents, &editorRevision);
contents = convertToLatin1(contents);
if (m_currentDoc) {
if (contents.isEmpty() && !QFileInfo(absoluteFileName).isAbsolute()) {
QString msg = QCoreApplication::translate(
"CppPreprocessor", "%1: No such file or directory").arg(fileName);
Document::DiagnosticMessage d(Document::DiagnosticMessage::Warning,
m_currentDoc->fileName(),
line, /*column = */ 0,
msg);
m_currentDoc->addDiagnosticMessage(d);
return;
}
}
if (m_dumpFileNameWhileParsing) {
qDebug() << "Parsing file:" << absoluteFileName
<< "contents:" << contents.size()
;
}
Document::Ptr doc = m_snapshot.document(absoluteFileName);
if (doc) {
mergeEnvironment(doc);
return;
}
doc = Document::create(absoluteFileName);
doc->setRevision(m_revision);
doc->setEditorRevision(editorRevision);
const QFileInfo info(absoluteFileName);
if (info.exists())
doc->setLastModified(info.lastModified());
const Document::Ptr previousDoc = switchDocument(doc);
const QByteArray preprocessedCode = m_preprocess.run(absoluteFileName, contents);
// {
// QByteArray b(preprocessedCode);
// b.replace("\n", "<<<\n");
// qDebug("Preprocessed code for \"%s\": [[%s]]", fileName.toUtf8().constData(),
// b.constData());
// }
doc->setUtf8Source(preprocessedCode);
doc->keepSourceAndAST();
doc->tokenize();
m_snapshot.insert(doc);
m_todo.remove(absoluteFileName);
Process process(m_modelManager, doc, m_workingCopy);
process();
(void) switchDocument(previousDoc);
}
开发者ID:Revulet,项目名称:qtcreator,代码行数:75,代码来源:cpppreprocessor.cpp
示例4: onDocumentUpdated
void CppCurrentDocumentFilter::onDocumentUpdated(Document::Ptr doc)
{
if (m_currentFileName == doc->fileName())
m_itemsOfCurrentDoc.clear();
}
开发者ID:Andersbakken,项目名称:CPlusPlus,代码行数:5,代码来源:cppcurrentdocumentfilter.cpp
示例5: test_codegen_definition_empty_class
void CppToolsPlugin::test_codegen_definition_empty_class()
{
const QByteArray srcText = "\n"
"class Foo\n" // line 1
"{\n"
"void foo();\n" // line 3
"};\n"
"\n";
const QByteArray dstText = "\n"
"int x;\n" // line 1
"\n";
Document::Ptr src = Document::create(QDir::tempPath() + QLatin1String("/file.h"));
Utils::FileSaver srcSaver(src->fileName());
srcSaver.write(srcText);
srcSaver.finalize();
src->setUtf8Source(srcText);
src->parse();
src->check();
QCOMPARE(src->diagnosticMessages().size(), 0);
QCOMPARE(src->globalSymbolCount(), 1U);
Document::Ptr dst = Document::create(QDir::tempPath() + QLatin1String("/file.cpp"));
Utils::FileSaver dstSaver(dst->fileName());
dstSaver.write(dstText);
dstSaver.finalize();
dst->setUtf8Source(dstText);
dst->parse();
dst->check();
QCOMPARE(dst->diagnosticMessages().size(), 0);
QCOMPARE(dst->globalSymbolCount(), 1U);
Snapshot snapshot;
snapshot.insert(src);
snapshot.insert(dst);
Class *foo = src->globalSymbolAt(0)->asClass();
QVERIFY(foo);
QCOMPARE(foo->line(), 1U);
QCOMPARE(foo->column(), 7U);
QCOMPARE(foo->memberCount(), 1U);
Declaration *decl = foo->memberAt(0)->asDeclaration();
QVERIFY(decl);
QCOMPARE(decl->line(), 3U);
QCOMPARE(decl->column(), 6U);
CppRefactoringChanges changes(snapshot);
InsertionPointLocator find(changes);
QList<InsertionLocation> locList = find.methodDefinition(decl);
QVERIFY(locList.size() == 1);
InsertionLocation loc = locList.first();
QCOMPARE(loc.fileName(), dst->fileName());
QCOMPARE(loc.prefix(), QLatin1String("\n\n"));
QCOMPARE(loc.suffix(), QString());
QCOMPARE(loc.line(), 3U);
QCOMPARE(loc.column(), 1U);
}
开发者ID:ProDataLab,项目名称:qt-creator,代码行数:58,代码来源:cppcodegen_test.cpp
示例6: context
void tst_Lookup::simple_class_1()
{
const QByteArray source = "\n"
"@interface Zoo {} +(id)alloc; -(id)init; @end\n"
"@implementation Zoo +(id)alloc{} -(id)init{} -(void)dealloc{} @end\n";
Document::Ptr doc = Document::create("simple_class_1");
doc->setSource(source);
doc->parse();
doc->check();
QVERIFY(doc->diagnosticMessages().isEmpty());
QCOMPARE(doc->globalSymbolCount(), 2U);
Snapshot snapshot;
snapshot.insert(doc);
ObjCClass *iface = doc->globalSymbolAt(0)->asObjCClass();
QVERIFY(iface);
QVERIFY(iface->isInterface());
QCOMPARE(iface->memberCount(), 2U);
ObjCClass *impl = doc->globalSymbolAt(1)->asObjCClass();
QVERIFY(impl);
QVERIFY(!impl->isInterface());
QCOMPARE(impl->memberCount(), 3U);
Declaration *allocMethodIface = iface->memberAt(0)->asDeclaration();
QVERIFY(allocMethodIface);
QVERIFY(allocMethodIface->name() && allocMethodIface->name()->identifier());
QCOMPARE(QLatin1String(allocMethodIface->name()->identifier()->chars()), QLatin1String("alloc"));
ObjCMethod *allocMethodImpl = impl->memberAt(0)->asObjCMethod();
QVERIFY(allocMethodImpl);
QVERIFY(allocMethodImpl->name() && allocMethodImpl->name()->identifier());
QCOMPARE(QLatin1String(allocMethodImpl->name()->identifier()->chars()), QLatin1String("alloc"));
ObjCMethod *deallocMethod = impl->memberAt(2)->asObjCMethod();
QVERIFY(deallocMethod);
QVERIFY(deallocMethod->name() && deallocMethod->name()->identifier());
QCOMPARE(QLatin1String(deallocMethod->name()->identifier()->chars()), QLatin1String("dealloc"));
const LookupContext context(doc, snapshot);
// check class resolving:
ClassOrNamespace *klass = context.lookupType(impl->name(), impl->enclosingScope());
QVERIFY(klass != 0);
QCOMPARE(klass->symbols().size(), 2);
QVERIFY(klass->symbols().contains(iface));
QVERIFY(klass->symbols().contains(impl));
// check method resolving:
QList<LookupItem> results = context.lookup(allocMethodImpl->name(), impl);
QCOMPARE(results.size(), 2);
QCOMPARE(results.at(0).declaration(), allocMethodIface);
QCOMPARE(results.at(1).declaration(), allocMethodImpl);
results = context.lookup(deallocMethod->name(), impl);
QCOMPARE(results.size(), 1);
QCOMPARE(results.at(0).declaration(), deallocMethod);
}
开发者ID:anchowee,项目名称:QtCreator,代码行数:61,代码来源:tst_lookup.cpp
示例7: navigateToSlot
bool QtCreatorIntegration::navigateToSlot(const QString &objectName,
const QString &signalSignature,
const QStringList ¶meterNames,
QString *errorMessage)
{
const EditorData ed = m_few->activeEditor();
QTC_ASSERT(ed, return false)
const QString currentUiFile = ed.formWindowEditor->file()->fileName();
#if 0
return Designer::Internal::navigateToSlot(currentUiFile, objectName, signalSignature, parameterNames, errorMessage);
#endif
// TODO: we should pass to findDocumentsIncluding an absolute path to generated .h file from ui.
// Currently we are guessing the name of ui_<>.h file and pass the file name only to the findDocumentsIncluding().
// The idea is that the .pro file knows if the .ui files is inside, and the .pro file knows it will
// be generating the ui_<>.h file for it, and the .pro file knows what the generated file's name and its absolute path will be.
// So we should somehow get that info from project manager (?)
const QFileInfo fi(currentUiFile);
const QString uicedName = QLatin1String("ui_") + fi.completeBaseName() + QLatin1String(".h");
// Retrieve code model snapshot restricted to project of ui file.
const ProjectExplorer::Project *uiProject = ProjectExplorer::ProjectExplorerPlugin::instance()->session()->projectForFile(currentUiFile);
if (!uiProject) {
*errorMessage = tr("Internal error: No project could be found for %1.").arg(currentUiFile);
return false;
}
CPlusPlus::Snapshot docTable = CppModelManagerInterface::instance()->snapshot();
CPlusPlus::Snapshot newDocTable;
for (CPlusPlus::Snapshot::iterator it = docTable.begin(); it != docTable.end(); ++it) {
const ProjectExplorer::Project *project = ProjectExplorer::ProjectExplorerPlugin::instance()->session()->projectForFile(it.key());
if (project == uiProject)
newDocTable.insert(it.value());
}
docTable = newDocTable;
// take all docs, find the ones that include the ui_xx.h.
QList<Document::Ptr> docList = findDocumentsIncluding(docTable, uicedName, true); // change to false when we know the absolute path to generated ui_<>.h file
if (Designer::Constants::Internal::debug)
qDebug() << Q_FUNC_INFO << objectName << signalSignature << "Looking for " << uicedName << " returned " << docList.size();
if (docList.isEmpty()) {
*errorMessage = tr("No documents matching '%1' could be found.\nRebuilding the project might help.").arg(uicedName);
return false;
}
QDesignerFormWindowInterface *fwi = ed.widgetHost->formWindow();
const QString uiClass = uiClassName(fwi->mainContainer()->objectName());
if (Designer::Constants::Internal::debug)
qDebug() << "Checking docs for " << uiClass;
// Find the class definition (ui class defined as member or base class)
// in the file itself or in the directly included files (order 1).
QString namespaceName;
const Class *cl = 0;
Document::Ptr doc;
foreach (const Document::Ptr &d, docList) {
const ClassDocumentPtrPair cd = findClassRecursively(docTable, d, uiClass, 1u , &namespaceName);
if (cd.first) {
cl = cd.first;
doc = cd.second;
break;
}
}
if (!cl) {
*errorMessage = msgClassNotFound(uiClass, docList);
return false;
}
Overview o;
const QString className = namespaceName + o.prettyName(cl->name());
if (Designer::Constants::Internal::debug)
qDebug() << "Found class " << className << doc->fileName();
const QString functionName = QLatin1String("on_") + objectName + QLatin1Char('_') + signalSignature;
const QString functionNameWithParameterNames = addParameterNames(functionName, parameterNames);
if (Designer::Constants::Internal::debug)
qDebug() << Q_FUNC_INFO << "Found " << uiClass << doc->fileName() << " checking " << functionName << functionNameWithParameterNames;
int line = 0;
Document::Ptr sourceDoc;
if (Function *fun = findDeclaration(cl, functionName)) {
sourceDoc = findDefinition(fun, &line);
if (!sourceDoc) {
// add function definition to cpp file
sourceDoc = addDefinition(docTable, doc->fileName(), className, functionNameWithParameterNames, &line);
}
} else {
// add function declaration to cl
CppModelManagerInterface::WorkingCopy workingCopy =
CppModelManagerInterface::instance()->workingCopy();
const QString fileName = doc->fileName();
getParsedDocument(fileName, workingCopy, docTable);
addDeclaration(docTable, fileName, cl, functionNameWithParameterNames);
//.........这里部分代码省略.........
开发者ID:NoobSaibot,项目名称:qtcreator-minimap,代码行数:101,代码来源:qtcreatorintegration.cpp
示例8: update
bool SQLiteDocumentDAO::update(Document::Ptr pub)
{
if(!pub) {
return false;
}
repository()->journalDAO()->saveOrUpdate(pub->journal());
QueryParameters params;
params.insert("title", pub->title());
params.insert("abstract", pub->abstract());
params.insert("year", pub->year());
params.insert("month", pub->month());
params.insert("conference", pub->conference());
params.insert("publisher", pub->publisher());
params.insert("volume", pub->volume());
params.insert("number", pub->number());
params.insert("url", pub->url());
params.insert("doi", pub->doi());
params.insert("isbn", pub->isbn());
params.insert("localURL", pub->localUrl());
params.insert("type", static_cast<uint>(pub->type()));
params.insert("isPublished", pub->isPublished());
params.insert("isPeerReviewed", pub->isPeerReviewed());
//params.insert("keywords", pub->keywords());
params.insert("series", pub->series());
params.insert("subTitle", pub->subTitle());
params.insert("pages", pub->pages().toString());
params.insert("authors", StringUtils::serialize(pub->authors()));
params.insert("editors", StringUtils::serialize(pub->editors()));
params.insert("citeKey", pub->citeKey());
if(pub->journal()) {
params.insert("journalId", pub->journal()->id());
} else {
params.insert("journalId", QVariant());
}
bool ok = QueryExecutor().update("document", makeQueryParameters("id", pub->id()), params);
if(ok) {
emit dataChanged();
}
return ok;
}
开发者ID:mvaldenegro,项目名称:KResearch,代码行数:47,代码来源:SQLiteDocumentDAO.cpp
示例9: findById
Document::Ptr SQLiteDocumentDAO::findById(qulonglong id) const
{
if(repository()->publications()->contains(id)) {
return repository()->publications()->find(id);
}
QueryExecutor executor(database());
QSqlQuery query = executor.select("document", QStringList(), makeQueryParameters("id", id));
if(query.next()) {
QSqlRecord record = query.record();
qulonglong id = record.value("id").toULongLong();
Document::Ptr pub = Document::Ptr(new Document());
pub->setId(id);
pub->setTitle(record.value("title").toString());
pub->setAbstract(record.value("abstract").toString());
pub->setYear(record.value("year").toInt());
pub->setMonth(record.value("month").toInt());
pub->setConference(record.value("conference").toString());
pub->setPublisher(record.value("publisher").toString());
pub->setVolume(record.value("volume").toInt());
pub->setNumber(record.value("number").toInt());
pub->setUrl(record.value("url").toString());
pub->setDoi(record.value("doi").toString());
pub->setIsbn(record.value("isbn").toString());
pub->setLocalUrl(record.value("localURL").toString());
pub->setType(static_cast<DocumentType>(record.value("type").toUInt()));
pub->setPublished(record.value("isPublished").toBool());
pub->setPeerReviewed(record.value("isPeerReviewed").toBool());
pub->setKeywords(QStringList());
pub->setSeries(record.value("series").toString());
pub->setSubTitle(record.value("subTitle").toString());
pub->setPages(PageRange::fromString(record.value("pages").toString()));
pub->setCiteKey(record.value("citeKey").toString());
repository()->publications()->insert(id, pub);
QString authors = record.value("authors").toString();
pub->setAuthors(StringUtils::deserialize(authors));
QString editors = record.value("editors").toString();
pub->setEditors(StringUtils::deserialize(editors));
qulonglong jid = record.value("journalId").toULongLong();
if(jid != 0) {
pub->setJournal(repository()->journalDAO()->findById(jid));
}
emit dataChanged();
return pub;
}
return Document::Ptr();
}
开发者ID:mvaldenegro,项目名称:KResearch,代码行数:58,代码来源:SQLiteDocumentDAO.cpp
示例10: save
bool SQLiteDocumentDAO::save(Document::Ptr pub)
{
if(!pub) {
return false;
}
QueryExecutor executor(database());
QueryParameters params;
if(pub->journal()) {
Journal::Ptr realJournal = repository()->journalDAO()->findByName(pub->journal()->name(), true);
if(realJournal != pub->journal()) {
Journal::Ptr old = pub->journal();
pub->setJournal(realJournal);
delete old;
}
}
params.insert("title", pub->title());
params.insert("abstract", pub->abstract());
params.insert("year", pub->year());
params.insert("month", pub->month());
params.insert("conference", pub->conference());
params.insert("publisher", pub->publisher());
params.insert("volume", pub->volume());
params.insert("number", pub->number());
params.insert("url", pub->url());
params.insert("doi", pub->doi());
params.insert("isbn", pub->isbn());
params.insert("localURL", pub->localUrl());
params.insert("type", static_cast<uint>(pub->type()));
params.insert("isPublished", pub->isPublished());
params.insert("isPeerReviewed", pub->isPeerReviewed());
//params.insert("keywords", pub->keywords());
params.insert("series", pub->series());
params.insert("subTitle", pub->subTitle());
params.insert("pages", pub->pages().toString());
params.insert("authors", StringUtils::serialize(pub->authors()));
params.insert("editors", StringUtils::serialize(pub->editors()));
params.insert("citeKey", pub->citeKey());
if(pub->journal()) {
params.insert("journalId", pub->journal()->id());
} else {
params.insert("journalId", QVariant());
}
bool ok = executor.insert("document", params);
if(ok) {
qulonglong id = executor.lastInsertID();
pub->setId(id);
repository()->publications()->insert(id, pub);
emit dataChanged();
}
return ok;
}
开发者ID:mvaldenegro,项目名称:KResearch,代码行数:62,代码来源:SQLiteDocumentDAO.cpp
示例11: main
int main(int argc, char *argv[])
{
int sockfd, newsockfd, port_no, bindfd, listenfd, bytes_sent, bytes_recvd;
char sbuffer[512], cli_ip[16], sname[64], cname[64];
char *ptr_buff, *ptr_port;
const char *ptr_cli_ip;
struct sockaddr_in serv_addr, cli_addr;
socklen_t serv_size, cli_size;
int inp_true = 0, count = 0, inp, ni, x, y, toss;
char serv_choice, cli_choice, nc;
char choice_buffer[2], co_ordinates_buffer[2], toss_buffer;
system("clear");
ptr_buff = &sbuffer[0];
ptr_port = (char *)&PORT;
//creating sever side socket
sockfd = socket(AF_INET, SOCK_STREAM, 0);
if (sockfd == -1)
{
perror("Server side listening Socket could not be created!");
return 1;
}
memset(&serv_addr, 0, sizeof(serv_addr));
port_no = atoi(ptr_port);
serv_addr.sin_family = AF_INET;
serv_addr.sin_port = htons(port_no);
serv_addr.sin_addr.s_addr = INADDR_ANY;
//binding socket
bindfd = bind(sockfd, (struct sockaddr *)&serv_addr, sizeof(serv_addr));
if (bindfd == -1)
{
perror("Failed to bind!");
return 1;
}
Repo repo(MONGODB_HOST, MONGODB_PORT);
cout<<"--Player History--"<<endl;
repo.Read();
cout<<endl<<"Enter your Name : ";
cin>>sname;
Player *playerExist = Exist(sname);
if (playerExist->name != "")
{
cout<<endl<<"Welcome back "<<sname;
cout<<endl<<"Your history : ";
cout<<endl<<"win = "<<playerExist->win;
cout<<endl<<"lose = "<<playerExist->lose;
cout<<endl<<"draw = "<<playerExist->draw;
}
else
{
Document::Ptr person = new Document();
person->add("name", string(sname));
person->add("win", 0);
person->add("lose", 0);
person->add("draw", 0);
repo.Create(person);
}
char ans;
cout<<endl<<"Reset Game History ? (y/N)";
cin>>ans;
if (ans == 'y')
{
repo.Delete("all");
cout<<"--Player History--"<<endl;
repo.Read();
}
/*-----*/
cout<<"Server created!"<<endl<<"Waiting for a Player..."<<endl;
//listening for incoming connections
listenfd = listen(sockfd, 5);
if (listenfd == -1)
{
perror("Failed to listen!");
return 1;
}
serv_size = sizeof(serv_addr);
cli_size = sizeof(cli_addr);
newsockfd = accept(sockfd, (struct sockaddr *)&cli_addr, &cli_size);
if (newsockfd == -1)
{
perror("Failed to accept from client!");
return 1;
}
ptr_cli_ip = inet_ntop(AF_INET, &cli_addr.sin_addr, cli_ip, cli_size);
//.........这里部分代码省略.........
开发者ID:friskipr,项目名称:Cpp_TicTacToe,代码行数:101,代码来源:TTTServer.cpp
示例12: ctx
void tst_Lookup::base_class_defined_1()
{
Overview overview;
const QByteArray source = "\n"
"class base {};\n"
"class derived: public base {};\n";
Document::Ptr doc = Document::create("base_class_defined_1");
doc->setSource(source);
doc->parse();
doc->check();
QVERIFY(doc->diagnosticMessages().isEmpty());
QCOMPARE(doc->globalSymbolCount(), 2U);
Snapshot snapshot;
snapshot.insert(doc->fileName(), doc);
Document::Ptr emptyDoc = Document::create("<empty>");
Class *baseClass = doc->globalSymbolAt(0)->asClass();
QVERIFY(baseClass);
Class *derivedClass = doc->globalSymbolAt(1)->asClass();
QVERIFY(derivedClass);
LookupContext ctx(derivedClass, emptyDoc, doc, snapshot);
const QList<Symbol *> candidates =
ctx.resolveClass(derivedClass->baseClassAt(0)->name());
QCOMPARE(candidates.size(), 1);
QCOMPARE(candidates.at(0), baseClass);
TranslationUnit *unit = doc->translationUnit();
QVERIFY(unit != 0);
TranslationUnitAST *ast = unit->ast()->asTranslationUnit();
QVERIFY(ast != 0);
ClassSymbols classSymbols(doc->control());
classSymbols(ast);
QCOMPARE(classSymbols.size(), 2);
const QMap<Class *, ClassSpecifierAST *> classToAST =
invert(classSymbols.asMap());
QVERIFY(classToAST.value(baseClass) != 0);
QVERIFY(classToAST.value(derivedClass) != 0);
}
开发者ID:halsten,项目名称:beaverdbg,代码行数:52,代码来源:tst_lookup.cpp
示例13: insert
void Snapshot::insert(Document::Ptr doc)
{
if (doc)
_documents.insert(doc->fileName(), doc);
}
开发者ID:AtlantisCD9,项目名称:Qt,代码行数:5,代码来源:CppDocument.cpp
示例14: iface_impl_scoping
void tst_Lookup::iface_impl_scoping()
{
const QByteArray source = "\n"
"@interface Scooping{}-(int)method1:(int)arg;-(void)method2;@end\n"
"@implementation Scooping-(int)method1:(int)arg{return arg;}@end\n";
Document::Ptr doc = Document::create("class_with_protocol_with_protocol");
doc->setSource(source);
doc->parse();
doc->check();
QVERIFY(doc->diagnosticMessages().isEmpty());
QCOMPARE(doc->globalSymbolCount(), 2U);
Snapshot snapshot;
snapshot.insert(doc);
ObjCClass *iface = doc->globalSymbolAt(0)->asObjCClass();
QVERIFY(iface);
QVERIFY(iface->isInterface());
ObjCClass *impl = doc->globalSymbolAt(1)->asObjCClass();
QVERIFY(impl);
QVERIFY(!impl->isInterface());
QCOMPARE(iface->memberCount(), 2U);
QCOMPARE(impl->memberCount(), 1U);
ObjCMethod *method1Impl = impl->memberAt(0)->asObjCMethod();
QVERIFY(method1Impl);
QCOMPARE(method1Impl->identifier()->chars(), "method1");
// get the body of method1
QCOMPARE(method1Impl->memberCount(), 2U);
Argument *method1Arg = method1Impl->memberAt(0)->asArgument();
QVERIFY(method1Arg);
QCOMPARE(method1Arg->identifier()->chars(), "arg");
QVERIFY(method1Arg->type()->isIntegerType());
Block *method1Body = method1Impl->memberAt(1)->asBlock();
QVERIFY(method1Body);
const LookupContext context(doc, snapshot);
{ // verify if we can resolve "arg" in the body
QCOMPARE(method1Impl->argumentCount(), 1U);
Argument *arg = method1Impl->argumentAt(0)->asArgument();
QVERIFY(arg);
QVERIFY(arg->name());
QVERIFY(arg->name()->identifier());
QCOMPARE(arg->name()->identifier()->chars(), "arg");
QVERIFY(arg->type()->isIntegerType());
const QList<LookupItem> candidates = context.lookup(arg->name(), method1Body->enclosingScope());
QCOMPARE(candidates.size(), 1);
QVERIFY(candidates.at(0).declaration()->type()->asIntegerType());
}
Declaration *method2 = iface->memberAt(1)->asDeclaration();
QVERIFY(method2);
QCOMPARE(method2->identifier()->chars(), "method2");
{ // verify if we can resolve "method2" in the body
const QList<LookupItem> candidates = context.lookup(method2->name(), method1Body->enclosingScope());
QCOMPARE(candidates.size(), 1);
QCOMPARE(candidates.at(0).declaration(), method2);
}
}
开发者ID:anchowee,项目名称:QtCreator,代码行数:67,代码来源:tst_lookup.cpp
示例15: updateHelper
void BuiltinEditorDocumentParser::updateHelper(const WorkingCopy &theWorkingCopy)
{
if (filePath().isEmpty())
return;
const Configuration baseConfig = configuration();
const bool releaseSourceAndAST_ = releaseSourceAndAST();
State baseState = state();
ExtraState state = extraState();
WorkingCopy workingCopy = theWorkingCopy;
bool invalidateSnapshot = false, invalidateConfig = false, editorDefinesChanged_ = false;
CppModelManager *modelManager = CppModelManager::instance();
QByteArray configFile = modelManager->codeModelConfiguration();
ProjectPartHeaderPaths headerPaths;
QStringList precompiledHeaders;
QString projectConfigFile;
LanguageFeatures features = LanguageFeatures::defaultFeatures();
baseState.projectPart = determineProjectPart(filePath(), baseConfig, baseState);
if (state.forceSnapshotInvalidation) {
invalidateSnapshot = true;
state.forceSnapshotInvalidation = false;
}
if (const ProjectPart::Ptr part = baseState.projectPart) {
configFile += part->toolchainDefines;
configFile += overwrittenToolchainDefines(*part.data());
configFile += part->projectDefines;
headerPaths = part->headerPaths;
projectConfigFile = part->projectConfigFile;
if (baseConfig.usePrecompiledHeaders)
precompiledHeaders = part->precompiledHeaders;
features = part->languageFeatures;
}
if (configFile != state.configFile) {
state.configFile = configFile;
invalidateSnapshot = true;
invalidateConfig = true;
}
if (baseConfig.editorDefines != baseState.editorDefines) {
baseState.editorDefines = baseConfig.editorDefines;
invalidateSnapshot = true;
editorDefinesChanged_ = true;
}
if (headerPaths != state.headerPaths) {
state.headerPaths = headerPaths;
invalidateSnapshot = true;
}
if (projectConfigFile != state.projectConfigFile) {
state.projectConfigFile = projectConfigFile;
invalidateSnapshot = true;
}
if (precompiledHeaders != state.precompiledHeaders) {
state.precompiledHeaders = precompiledHeaders;
invalidateSnapshot = true;
}
unsigned rev = 0;
if (Document::Ptr doc = state.snapshot.document(filePath()))
rev = doc->revision();
else
invalidateSnapshot = true;
Snapshot globalSnapshot = modelManager->snapshot();
if (invalidateSnapshot) {
state.snapshot = Snapshot();
} else {
// Remove changed files from the snapshot
QSet<Utils::FileName> toRemove;
foreach (const Document::Ptr &doc, state.snapshot) {
const Utils::FileName fileName = Utils::FileName::fromString(doc->fileName());
if (workingCopy.contains(fileName)) {
if (workingCopy.get(fileName).second != doc->editorRevision())
addFileAndDependencies(&state.snapshot, &toRemove, fileName);
continue;
}
Document::Ptr otherDoc = globalSnapshot.document(fileName);
if (!otherDoc.isNull() && otherDoc->revision() != doc->revision())
addFileAndDependencies(&state.snapshot, &toRemove, fileName);
}
if (!toRemove.isEmpty()) {
invalidateSnapshot = true;
foreach (const Utils::FileName &fileName, toRemove)
state.snapshot.remove(fileName);
}
}
开发者ID:C-sjia,项目名称:qt-creator,代码行数:97,代码来源:builtineditordocumentparser.cpp
示例16: onDocumentUpdated
void CppCurrentDocumentFilter::onDocumentUpdated(Document::Ptr doc)
{
QMutexLocker locker(&m_mutex);
if (m_currentFileName == doc->fileName())
m_itemsOfCurrentDoc.clear();
}
开发者ID:C-sjia,项目名称:qt-creator,代码行数:6,代码来源:cppcurrentdocumentfilter.cpp
示例17: navigateToSlot
bool QtCreatorIntegration::navigateToSlot(const QString &objectName,
const QString &signalSignature,
const QStringList ¶meterNames,
QString *errorMessage)
{
typedef QMap<int, Document::Ptr> DocumentMap;
const Utils::FileName currentUiFile = FormEditorW::activeEditor()->document()->filePath();
#if 0
return Designer::Internal::navigateToSlot(currentUiFile.toString(), objectName,
signalSignature, parameterNames, errorMessage);
#endif
// TODO: we should pass to findDocumentsIncluding an absolute path to generated .h file from ui.
// Currently we are guessing the name of ui_<>.h file and pass the file name only to the findDocumentsIncluding().
// The idea is that the .pro file knows if the .ui files is inside, and the .pro file knows it will
// be generating the ui_<>.h file for it, and the .pro file knows what the generated file's name and its absolute path will be.
// So we should somehow get that info from project manager (?)
const QFileInfo fi = currentUiFile.toFileInfo();
const QString uiFolder = fi.absolutePath();
const QString uicedName = "ui_" + fi.completeBaseName() + ".h";
// Retrieve code model snapshot restricted to project of ui file or the working copy.
Snapshot docTable = CppTools::CppModelManager::instance()->snapshot();
Snapshot newDocTable;
const Project *uiProject = SessionManager::projectForFile(currentUiFile);
if (uiProject) {
for (Snapshot::const_iterator i = docTable.begin(), ei = docTable.end(); i != ei; ++i) {
const Project *project = SessionManager::projectForFile(i.key());
if (project == uiProject)
newDocTable.insert(i.value());
}
} else {
const CppTools::WorkingCopy workingCopy =
CppTools::CppModelManager::instance()->workingCopy();
const Utils::FileName configFileName =
Utils::FileName::fromString(CppTools::CppModelManager::configurationFileName());
QHashIterator<Utils::FileName, QPair<QByteArray, unsigned> > it = workingCopy.iterator();
while (it.hasNext()) {
it.next();
const Utils::FileName &fileName = it.key();
if (fileName != configFileName)
newDocTable.insert(docTable.document(fileName));
}
}
docTable = newDocTable;
// take all docs, find the ones that include the ui_xx.h.
// Sort into a map, putting the ones whose path closely matches the ui-folder path
// first in case there are project subdirectories that contain identical file names.
const QList<Document::Ptr> docList = findDocumentsIncluding(docTable, uicedName, true); // change to false when we know the absolute path to generated ui_<>.h file
DocumentMap docMap;
for (const Document::Ptr &d : docList) {
const QFileInfo docFi(d->fileName());
docMap.insert(qAbs(docFi.absolutePath().compare(uiFolder, Qt::CaseInsensitive)), d);
}
if (Designer::Constants::Internal::debug)
qDebug() << Q_FUNC_INFO << objectName << signalSignature << "Looking for " << uicedName << " returned " << docList.size();
if (docMap.isEmpty()) {
*errorMessage = tr("No documents matching \"%1\" could be found.\nRebuilding the project might help.").arg(uicedName);
return false;
}
QDesignerFormWindowInterface *fwi = FormEditorW::activeWidgetHost()->formWindow();
const QString uiClass = uiClassName(fwi->mainContainer()->objectName());
if (Designer::Constants::Internal::debug)
qDebug() << "Checking docs for " << uiClass;
// Find the class definition (ui class defined as member or base class)
// in the file itself or in the directly included files (order 1).
QString namespaceName;
const Class *cl = 0;
Document::Ptr doc;
for (const Document::Ptr &d : qAsConst(docMap)) {
LookupContext context(d, docTable);
const ClassDocumentPtrPair cd = findClassRecursively(context, uiClass, 1u , &namespaceName);
if (cd.first) {
cl = cd.first;
doc = cd.second;
break;
}
}
if (!cl) {
*errorMessage = msgClassNotFound(uiClass, docList);
return false;
}
Overview o;
const QString className = namespaceName + o.prettyName(cl->name());
if (Designer::Constants::Internal::debug)
qDebug() << "Found class " << className << doc->fileName();
const QString functionName = "on_" + objectName + '_' + signalSignature;
const QString functionNameWithParameterNames = addParameterNames(functionName, parameterNames);
if (Designer::Constants::Internal::debug)
qDebug() << Q_FUNC_INFO << "Found " << uiClass << doc->fileName() << " checking " << functionName << functionNameWithParameterNames;
//.........这里部分代码省略.........
开发者ID:kai66673,项目名称:qt-creator,代码行数:101,代码来源:qtcreatorintegration.cpp
|
请发表评论