forked from qt-creator/qt-creator
Introduce codemodelbackend process and library
This is a partial result of wip/clang-oop. More will follow. This allows us to invoke the completion out of the Qt Creator process and thus safes us as against libclang crashes. At this point only the completion use case is supported. Some notes on the individual components: src/libs/codemodelbackendipc * library encapsulating the inter process communication handling * used by the backend application and in a follow-up change by the creator integration src/libs/3rdparty/sqlite * version 3.8.10.2 * dependency of codemodelbackendipc, will be used to storage indexing data, among others src/tools/codemodelbackend * the backend application tests/unit: * unit tests Change-Id: I91a48e27467581a22fb760a18d8eb926008fea60 Reviewed-by: Alessandro Portale <alessandro.portale@theqtcompany.com> Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com> Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
This commit is contained in:
committed by
Nikolai Kosjar
parent
51fec1a3ca
commit
e2f8a9883b
1
.gitignore
vendored
1
.gitignore
vendored
@@ -117,6 +117,7 @@ tmp/
|
|||||||
*.dll
|
*.dll
|
||||||
*.exe
|
*.exe
|
||||||
/bin/buildoutputparser
|
/bin/buildoutputparser
|
||||||
|
/bin/codemodelbackend
|
||||||
/bin/cpaster
|
/bin/cpaster
|
||||||
/bin/cplusplus-ast2png
|
/bin/cplusplus-ast2png
|
||||||
/bin/cplusplus-frontend
|
/bin/cplusplus-frontend
|
||||||
|
52
qbs/imports/QtcClangInstallation/functions.js
Normal file
52
qbs/imports/QtcClangInstallation/functions.js
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
function llvmConfig(qbs)
|
||||||
|
{
|
||||||
|
var llvmInstallDirFromEnv = qbs.getEnv("LLVM_INSTALL_DIR")
|
||||||
|
var llvmConfigVariants = [
|
||||||
|
"llvm-config", "llvm-config-3.2", "llvm-config-3.3", "llvm-config-3.4",
|
||||||
|
"llvm-config-3.5", "llvm-config-3.6", "llvm-config-4.0", "llvm-config-4.1"
|
||||||
|
];
|
||||||
|
|
||||||
|
// Prefer llvm-config* from LLVM_INSTALL_DIR
|
||||||
|
if (llvmInstallDirFromEnv) {
|
||||||
|
for (var i = 0; i < llvmConfigVariants.length; ++i) {
|
||||||
|
var variant = llvmInstallDirFromEnv + "/bin/" + llvmConfigVariants[i];
|
||||||
|
if (File.exists(variant))
|
||||||
|
return variant;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find llvm-config* in PATH
|
||||||
|
var pathListString = qbs.getEnv("PATH");
|
||||||
|
var separator = qbs.hostOS.contains("windows") ? ";" : ":";
|
||||||
|
var pathList = pathListString.split(separator);
|
||||||
|
for (var i = 0; i < llvmConfigVariants.length; ++i) {
|
||||||
|
for (var j = 0; j < pathList.length; ++j) {
|
||||||
|
var variant = pathList[j] + "/" + llvmConfigVariants[i];
|
||||||
|
if (File.exists(variant))
|
||||||
|
return variant;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
function includeDir(llvmConfig, processOutputReader)
|
||||||
|
{
|
||||||
|
return processOutputReader.readOutput(llvmConfig, ["--includedir"])
|
||||||
|
}
|
||||||
|
|
||||||
|
function libDir(llvmConfig, processOutputReader)
|
||||||
|
{
|
||||||
|
return processOutputReader.readOutput(llvmConfig, ["--libdir"])
|
||||||
|
}
|
||||||
|
|
||||||
|
function version(llvmConfig, processOutputReader)
|
||||||
|
{
|
||||||
|
return processOutputReader.readOutput(llvmConfig, ["--version"])
|
||||||
|
.replace(/(\d+\.\d+\.\d+).*/, "$1")
|
||||||
|
}
|
||||||
|
|
||||||
|
function libraries(targetOS)
|
||||||
|
{
|
||||||
|
return ["clang"] + (targetOS.contains("windows") ? ["advapi32", "shell32"] : [])
|
||||||
|
}
|
231
src/libs/3rdparty/sqlite/okapi_bm25.h
vendored
Normal file
231
src/libs/3rdparty/sqlite/okapi_bm25.h
vendored
Normal file
@@ -0,0 +1,231 @@
|
|||||||
|
#include <math.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#include "sqlite3.h"
|
||||||
|
|
||||||
|
|
||||||
|
static void okapi_bm25(sqlite3_context *pCtx, int nVal, sqlite3_value **apVal) {
|
||||||
|
assert(sizeof(int) == 4);
|
||||||
|
|
||||||
|
unsigned int *matchinfo = (unsigned int *)sqlite3_value_blob(apVal[0]);
|
||||||
|
int searchTextCol = sqlite3_value_int(apVal[1]);
|
||||||
|
|
||||||
|
double K1 = ((nVal >= 3) ? sqlite3_value_double(apVal[2]) : 1.2);
|
||||||
|
double B = ((nVal >= 4) ? sqlite3_value_double(apVal[3]) : 0.75);
|
||||||
|
|
||||||
|
int P_OFFSET = 0;
|
||||||
|
int C_OFFSET = 1;
|
||||||
|
int X_OFFSET = 2;
|
||||||
|
|
||||||
|
int termCount = matchinfo[P_OFFSET];
|
||||||
|
int colCount = matchinfo[C_OFFSET];
|
||||||
|
|
||||||
|
int N_OFFSET = X_OFFSET + 3*termCount*colCount;
|
||||||
|
int A_OFFSET = N_OFFSET + 1;
|
||||||
|
int L_OFFSET = (A_OFFSET + colCount);
|
||||||
|
|
||||||
|
|
||||||
|
double totalDocs = matchinfo[N_OFFSET];
|
||||||
|
double avgLength = matchinfo[A_OFFSET + searchTextCol];
|
||||||
|
double docLength = matchinfo[L_OFFSET + searchTextCol];
|
||||||
|
|
||||||
|
double sum = 0.0;
|
||||||
|
|
||||||
|
for (int i = 0; i < termCount; i++) {
|
||||||
|
int currentX = X_OFFSET + (3 * searchTextCol * (i + 1));
|
||||||
|
double termFrequency = matchinfo[currentX];
|
||||||
|
double docsWithTerm = matchinfo[currentX + 2];
|
||||||
|
|
||||||
|
double idf = log(
|
||||||
|
(totalDocs - docsWithTerm + 0.5) /
|
||||||
|
(docsWithTerm + 0.5)
|
||||||
|
);
|
||||||
|
|
||||||
|
double rightSide = (
|
||||||
|
(termFrequency * (K1 + 1)) /
|
||||||
|
(termFrequency + (K1 * (1 - B + (B * (docLength / avgLength)))))
|
||||||
|
);
|
||||||
|
|
||||||
|
sum += (idf * rightSide);
|
||||||
|
}
|
||||||
|
|
||||||
|
sqlite3_result_double(pCtx, sum);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Created by Joshua Wilson on 27/05/14.
|
||||||
|
// Copyright (c) 2014 Joshua Wilson. All rights reserved.
|
||||||
|
// https://github.com/neozenith/sqlite-okapi-bm25
|
||||||
|
//
|
||||||
|
// This is an extension to the work of "Radford 'rads' Smith"
|
||||||
|
// found at: https://github.com/rads/sqlite-okapi-bm25
|
||||||
|
// which is covered by the MIT License
|
||||||
|
// http://opensource.org/licenses/MIT
|
||||||
|
// the following code shall also be covered by the same MIT License
|
||||||
|
|
||||||
|
static void okapi_bm25f(sqlite3_context *pCtx, int nVal, sqlite3_value **apVal) {
|
||||||
|
assert(sizeof(int) == 4);
|
||||||
|
|
||||||
|
unsigned int *matchinfo = (unsigned int *)sqlite3_value_blob(apVal[0]);
|
||||||
|
|
||||||
|
|
||||||
|
//Setting the default values and ignoring argument based inputs so the extra
|
||||||
|
//arguments can be the column weights instead.
|
||||||
|
double K1 = 1.2;// ((nVal >= 3) ? sqlite3_value_double(apVal[2]) : 1.2);
|
||||||
|
double B = 0.75;// ((nVal >= 4) ? sqlite3_value_double(apVal[3]) : 0.75);
|
||||||
|
|
||||||
|
//For a good explanation fo the maths and how to choose these variables
|
||||||
|
//http://stackoverflow.com/a/23161886/622276
|
||||||
|
|
||||||
|
//NOTE: the rearranged order of parameters to match the order presented on
|
||||||
|
//SQLite3 FTS3 documentation 'pcxnals' (http://www.sqlite.org/fts3.html#matchinfo)
|
||||||
|
|
||||||
|
int P_OFFSET = 0;
|
||||||
|
int C_OFFSET = 1;
|
||||||
|
int X_OFFSET = 2;
|
||||||
|
|
||||||
|
int termCount = matchinfo[P_OFFSET];
|
||||||
|
int colCount = matchinfo[C_OFFSET];
|
||||||
|
|
||||||
|
int N_OFFSET = X_OFFSET + 3*termCount*colCount;
|
||||||
|
int A_OFFSET = N_OFFSET + 1;
|
||||||
|
int L_OFFSET = (A_OFFSET + colCount);
|
||||||
|
// int S_OFFSET = (L_OFFSET + colCount); //useful as a pseudo proximity weighting per field/column
|
||||||
|
|
||||||
|
double totalDocs = matchinfo[N_OFFSET];
|
||||||
|
|
||||||
|
double avgLength = 0.0;
|
||||||
|
double docLength = 0.0;
|
||||||
|
|
||||||
|
for (int col = 0; col < colCount; col++)
|
||||||
|
{
|
||||||
|
avgLength += matchinfo[A_OFFSET + col];
|
||||||
|
docLength += matchinfo[L_OFFSET + col];
|
||||||
|
}
|
||||||
|
|
||||||
|
double epsilon = 1.0 / (totalDocs*avgLength);
|
||||||
|
double sum = 0.0;
|
||||||
|
|
||||||
|
for (int t = 0; t < termCount; t++) {
|
||||||
|
for (int col = 0 ; col < colCount; col++)
|
||||||
|
{
|
||||||
|
int currentX = X_OFFSET + (3 * col * (t + 1));
|
||||||
|
|
||||||
|
|
||||||
|
double termFrequency = matchinfo[currentX];
|
||||||
|
double docsWithTerm = matchinfo[currentX + 2];
|
||||||
|
|
||||||
|
double idf = log(
|
||||||
|
(totalDocs - docsWithTerm + 0.5) /
|
||||||
|
(docsWithTerm + 0.5)
|
||||||
|
);
|
||||||
|
// "...terms appearing in more than half of the corpus will provide negative contributions to the final document score."
|
||||||
|
//http://en.wikipedia.org/wiki/Okapi_BM25
|
||||||
|
|
||||||
|
idf = (idf < 0) ? epsilon : idf; //common terms could have no effect (\epsilon=0.0) or a very small effect (\epsilon=1/NoOfTokens which asymptotes to 0.0)
|
||||||
|
|
||||||
|
double rightSide = (
|
||||||
|
(termFrequency * (K1 + 1)) /
|
||||||
|
(termFrequency + (K1 * (1 - B + (B * (docLength / avgLength)))))
|
||||||
|
);
|
||||||
|
|
||||||
|
rightSide += 1.0;
|
||||||
|
//To comply with BM25+ that solves a lower bounding issue where large documents that match are unfairly scored as
|
||||||
|
//having similar relevancy as short documents that do not contain as many terms
|
||||||
|
//Yuanhua Lv and ChengXiang Zhai. 'Lower-bounding term frequency normalization.' In Proceedings of CIKM'2011, pages 7-16.
|
||||||
|
//http://sifaka.cs.uiuc.edu/~ylv2/pub/cikm11-lowerbound.pdf
|
||||||
|
|
||||||
|
double weight = ((nVal > col+1) ? sqlite3_value_double(apVal[col+1]) : 1.0);
|
||||||
|
|
||||||
|
// double subsequence = matchinfo[S_OFFSET + col];
|
||||||
|
|
||||||
|
sum += (idf * rightSide) * weight; // * subsequence; //useful as a pseudo proximty weighting
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sqlite3_result_double(pCtx, sum);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void okapi_bm25f_kb(sqlite3_context *pCtx, int nVal, sqlite3_value **apVal) {
|
||||||
|
assert(sizeof(int) == 4);
|
||||||
|
|
||||||
|
unsigned int *matchinfo = (unsigned int *)sqlite3_value_blob(apVal[0]);
|
||||||
|
|
||||||
|
|
||||||
|
//Setting the default values and ignoring argument based inputs so the extra
|
||||||
|
//arguments can be the column weights instead.
|
||||||
|
if (nVal < 2) sqlite3_result_error(pCtx, "wrong number of arguments to function okapi_bm25_kb(), expected k1 parameter", -1);
|
||||||
|
if (nVal < 3) sqlite3_result_error(pCtx, "wrong number of arguments to function okapi_bm25_kb(), expected b parameter", -1);
|
||||||
|
double K1 = sqlite3_value_double(apVal[1]);
|
||||||
|
double B = sqlite3_value_double(apVal[2]);
|
||||||
|
|
||||||
|
//For a good explanation fo the maths and how to choose these variables
|
||||||
|
//http://stackoverflow.com/a/23161886/622276
|
||||||
|
|
||||||
|
//NOTE: the rearranged order of parameters to match the order presented on
|
||||||
|
//SQLite3 FTS3 documentation 'pcxnals' (http://www.sqlite.org/fts3.html#matchinfo)
|
||||||
|
|
||||||
|
int P_OFFSET = 0;
|
||||||
|
int C_OFFSET = 1;
|
||||||
|
int X_OFFSET = 2;
|
||||||
|
|
||||||
|
int termCount = matchinfo[P_OFFSET];
|
||||||
|
int colCount = matchinfo[C_OFFSET];
|
||||||
|
|
||||||
|
int N_OFFSET = X_OFFSET + 3*termCount*colCount;
|
||||||
|
int A_OFFSET = N_OFFSET + 1;
|
||||||
|
int L_OFFSET = (A_OFFSET + colCount);
|
||||||
|
// int S_OFFSET = (L_OFFSET + colCount); //useful as a pseudo proximity weighting per field/column
|
||||||
|
|
||||||
|
double totalDocs = matchinfo[N_OFFSET];
|
||||||
|
|
||||||
|
double avgLength = 0.0;
|
||||||
|
double docLength = 0.0;
|
||||||
|
|
||||||
|
for (int col = 0; col < colCount; col++)
|
||||||
|
{
|
||||||
|
avgLength += matchinfo[A_OFFSET + col];
|
||||||
|
docLength += matchinfo[L_OFFSET + col];
|
||||||
|
}
|
||||||
|
|
||||||
|
double epsilon = 1.0 / (totalDocs*avgLength);
|
||||||
|
double sum = 0.0;
|
||||||
|
|
||||||
|
for (int t = 0; t < termCount; t++) {
|
||||||
|
for (int col = 0 ; col < colCount; col++)
|
||||||
|
{
|
||||||
|
int currentX = X_OFFSET + (3 * col * (t + 1));
|
||||||
|
|
||||||
|
|
||||||
|
double termFrequency = matchinfo[currentX];
|
||||||
|
double docsWithTerm = matchinfo[currentX + 2];
|
||||||
|
|
||||||
|
double idf = log(
|
||||||
|
(totalDocs - docsWithTerm + 0.5) /
|
||||||
|
(docsWithTerm + 0.5)
|
||||||
|
);
|
||||||
|
// "...terms appearing in more than half of the corpus will provide negative contributions to the final document score."
|
||||||
|
//http://en.wikipedia.org/wiki/Okapi_BM25
|
||||||
|
|
||||||
|
idf = (idf < 0) ? epsilon : idf; //common terms could have no effect (\epsilon=0.0) or a very small effect (\epsilon=1/NoOfTokens which asymptotes to 0.0)
|
||||||
|
|
||||||
|
double rightSide = (
|
||||||
|
(termFrequency * (K1 + 1)) /
|
||||||
|
(termFrequency + (K1 * (1 - B + (B * (docLength / avgLength)))))
|
||||||
|
);
|
||||||
|
|
||||||
|
rightSide += 1.0;
|
||||||
|
//To comply with BM25+ that solves a lower bounding issue where large documents that match are unfairly scored as
|
||||||
|
//having similar relevancy as short documents that do not contain as many terms
|
||||||
|
//Yuanhua Lv and ChengXiang Zhai. 'Lower-bounding term frequency normalization.' In Proceedings of CIKM'2011, pages 7-16.
|
||||||
|
//http://sifaka.cs.uiuc.edu/~ylv2/pub/cikm11-lowerbound.pdf
|
||||||
|
|
||||||
|
double weight = ((nVal > col+3) ? sqlite3_value_double(apVal[col+3]) : 1.0);
|
||||||
|
|
||||||
|
// double subsequence = matchinfo[S_OFFSET + col];
|
||||||
|
|
||||||
|
sum += (idf * rightSide) * weight; // * subsequence; //useful as a pseudo proximty weighting
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sqlite3_result_double(pCtx, sum);
|
||||||
|
}
|
12
src/libs/3rdparty/sqlite/sqlite.pri
vendored
Normal file
12
src/libs/3rdparty/sqlite/sqlite.pri
vendored
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
INCLUDEPATH *= $$PWD
|
||||||
|
VPATH *= $$PWD
|
||||||
|
|
||||||
|
HEADERS += okapi_bm25.h \
|
||||||
|
sqlite3.h \
|
||||||
|
sqlite3ext.h
|
||||||
|
|
||||||
|
|
||||||
|
SOURCES += sqlite3.c
|
||||||
|
|
||||||
|
win32:DEFINES += SQLITE_API=__declspec(dllexport)
|
||||||
|
unix:DEFINES += SQLITE_API=\"__attribute__((visibility(\\\"default\\\")))\"
|
155866
src/libs/3rdparty/sqlite/sqlite3.c
vendored
Normal file
155866
src/libs/3rdparty/sqlite/sqlite3.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
7831
src/libs/3rdparty/sqlite/sqlite3.h
vendored
Normal file
7831
src/libs/3rdparty/sqlite/sqlite3.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
517
src/libs/3rdparty/sqlite/sqlite3ext.h
vendored
Normal file
517
src/libs/3rdparty/sqlite/sqlite3ext.h
vendored
Normal file
@@ -0,0 +1,517 @@
|
|||||||
|
/*
|
||||||
|
** 2006 June 7
|
||||||
|
**
|
||||||
|
** The author disclaims copyright to this source code. In place of
|
||||||
|
** a legal notice, here is a blessing:
|
||||||
|
**
|
||||||
|
** May you do good and not evil.
|
||||||
|
** May you find forgiveness for yourself and forgive others.
|
||||||
|
** May you share freely, never taking more than you give.
|
||||||
|
**
|
||||||
|
*************************************************************************
|
||||||
|
** This header file defines the SQLite interface for use by
|
||||||
|
** shared libraries that want to be imported as extensions into
|
||||||
|
** an SQLite instance. Shared libraries that intend to be loaded
|
||||||
|
** as extensions by SQLite should #include this file instead of
|
||||||
|
** sqlite3.h.
|
||||||
|
*/
|
||||||
|
#ifndef _SQLITE3EXT_H_
|
||||||
|
#define _SQLITE3EXT_H_
|
||||||
|
#include "sqlite3.h"
|
||||||
|
|
||||||
|
typedef struct sqlite3_api_routines sqlite3_api_routines;
|
||||||
|
|
||||||
|
/*
|
||||||
|
** The following structure holds pointers to all of the SQLite API
|
||||||
|
** routines.
|
||||||
|
**
|
||||||
|
** WARNING: In order to maintain backwards compatibility, add new
|
||||||
|
** interfaces to the end of this structure only. If you insert new
|
||||||
|
** interfaces in the middle of this structure, then older different
|
||||||
|
** versions of SQLite will not be able to load each other's shared
|
||||||
|
** libraries!
|
||||||
|
*/
|
||||||
|
struct sqlite3_api_routines {
|
||||||
|
void * (*aggregate_context)(sqlite3_context*,int nBytes);
|
||||||
|
int (*aggregate_count)(sqlite3_context*);
|
||||||
|
int (*bind_blob)(sqlite3_stmt*,int,const void*,int n,void(*)(void*));
|
||||||
|
int (*bind_double)(sqlite3_stmt*,int,double);
|
||||||
|
int (*bind_int)(sqlite3_stmt*,int,int);
|
||||||
|
int (*bind_int64)(sqlite3_stmt*,int,sqlite_int64);
|
||||||
|
int (*bind_null)(sqlite3_stmt*,int);
|
||||||
|
int (*bind_parameter_count)(sqlite3_stmt*);
|
||||||
|
int (*bind_parameter_index)(sqlite3_stmt*,const char*zName);
|
||||||
|
const char * (*bind_parameter_name)(sqlite3_stmt*,int);
|
||||||
|
int (*bind_text)(sqlite3_stmt*,int,const char*,int n,void(*)(void*));
|
||||||
|
int (*bind_text16)(sqlite3_stmt*,int,const void*,int,void(*)(void*));
|
||||||
|
int (*bind_value)(sqlite3_stmt*,int,const sqlite3_value*);
|
||||||
|
int (*busy_handler)(sqlite3*,int(*)(void*,int),void*);
|
||||||
|
int (*busy_timeout)(sqlite3*,int ms);
|
||||||
|
int (*changes)(sqlite3*);
|
||||||
|
int (*close)(sqlite3*);
|
||||||
|
int (*collation_needed)(sqlite3*,void*,void(*)(void*,sqlite3*,
|
||||||
|
int eTextRep,const char*));
|
||||||
|
int (*collation_needed16)(sqlite3*,void*,void(*)(void*,sqlite3*,
|
||||||
|
int eTextRep,const void*));
|
||||||
|
const void * (*column_blob)(sqlite3_stmt*,int iCol);
|
||||||
|
int (*column_bytes)(sqlite3_stmt*,int iCol);
|
||||||
|
int (*column_bytes16)(sqlite3_stmt*,int iCol);
|
||||||
|
int (*column_count)(sqlite3_stmt*pStmt);
|
||||||
|
const char * (*column_database_name)(sqlite3_stmt*,int);
|
||||||
|
const void * (*column_database_name16)(sqlite3_stmt*,int);
|
||||||
|
const char * (*column_decltype)(sqlite3_stmt*,int i);
|
||||||
|
const void * (*column_decltype16)(sqlite3_stmt*,int);
|
||||||
|
double (*column_double)(sqlite3_stmt*,int iCol);
|
||||||
|
int (*column_int)(sqlite3_stmt*,int iCol);
|
||||||
|
sqlite_int64 (*column_int64)(sqlite3_stmt*,int iCol);
|
||||||
|
const char * (*column_name)(sqlite3_stmt*,int);
|
||||||
|
const void * (*column_name16)(sqlite3_stmt*,int);
|
||||||
|
const char * (*column_origin_name)(sqlite3_stmt*,int);
|
||||||
|
const void * (*column_origin_name16)(sqlite3_stmt*,int);
|
||||||
|
const char * (*column_table_name)(sqlite3_stmt*,int);
|
||||||
|
const void * (*column_table_name16)(sqlite3_stmt*,int);
|
||||||
|
const unsigned char * (*column_text)(sqlite3_stmt*,int iCol);
|
||||||
|
const void * (*column_text16)(sqlite3_stmt*,int iCol);
|
||||||
|
int (*column_type)(sqlite3_stmt*,int iCol);
|
||||||
|
sqlite3_value* (*column_value)(sqlite3_stmt*,int iCol);
|
||||||
|
void * (*commit_hook)(sqlite3*,int(*)(void*),void*);
|
||||||
|
int (*complete)(const char*sql);
|
||||||
|
int (*complete16)(const void*sql);
|
||||||
|
int (*create_collation)(sqlite3*,const char*,int,void*,
|
||||||
|
int(*)(void*,int,const void*,int,const void*));
|
||||||
|
int (*create_collation16)(sqlite3*,const void*,int,void*,
|
||||||
|
int(*)(void*,int,const void*,int,const void*));
|
||||||
|
int (*create_function)(sqlite3*,const char*,int,int,void*,
|
||||||
|
void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
|
||||||
|
void (*xStep)(sqlite3_context*,int,sqlite3_value**),
|
||||||
|
void (*xFinal)(sqlite3_context*));
|
||||||
|
int (*create_function16)(sqlite3*,const void*,int,int,void*,
|
||||||
|
void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
|
||||||
|
void (*xStep)(sqlite3_context*,int,sqlite3_value**),
|
||||||
|
void (*xFinal)(sqlite3_context*));
|
||||||
|
int (*create_module)(sqlite3*,const char*,const sqlite3_module*,void*);
|
||||||
|
int (*data_count)(sqlite3_stmt*pStmt);
|
||||||
|
sqlite3 * (*db_handle)(sqlite3_stmt*);
|
||||||
|
int (*declare_vtab)(sqlite3*,const char*);
|
||||||
|
int (*enable_shared_cache)(int);
|
||||||
|
int (*errcode)(sqlite3*db);
|
||||||
|
const char * (*errmsg)(sqlite3*);
|
||||||
|
const void * (*errmsg16)(sqlite3*);
|
||||||
|
int (*exec)(sqlite3*,const char*,sqlite3_callback,void*,char**);
|
||||||
|
int (*expired)(sqlite3_stmt*);
|
||||||
|
int (*finalize)(sqlite3_stmt*pStmt);
|
||||||
|
void (*free)(void*);
|
||||||
|
void (*free_table)(char**result);
|
||||||
|
int (*get_autocommit)(sqlite3*);
|
||||||
|
void * (*get_auxdata)(sqlite3_context*,int);
|
||||||
|
int (*get_table)(sqlite3*,const char*,char***,int*,int*,char**);
|
||||||
|
int (*global_recover)(void);
|
||||||
|
void (*interruptx)(sqlite3*);
|
||||||
|
sqlite_int64 (*last_insert_rowid)(sqlite3*);
|
||||||
|
const char * (*libversion)(void);
|
||||||
|
int (*libversion_number)(void);
|
||||||
|
void *(*malloc)(int);
|
||||||
|
char * (*mprintf)(const char*,...);
|
||||||
|
int (*open)(const char*,sqlite3**);
|
||||||
|
int (*open16)(const void*,sqlite3**);
|
||||||
|
int (*prepare)(sqlite3*,const char*,int,sqlite3_stmt**,const char**);
|
||||||
|
int (*prepare16)(sqlite3*,const void*,int,sqlite3_stmt**,const void**);
|
||||||
|
void * (*profile)(sqlite3*,void(*)(void*,const char*,sqlite_uint64),void*);
|
||||||
|
void (*progress_handler)(sqlite3*,int,int(*)(void*),void*);
|
||||||
|
void *(*realloc)(void*,int);
|
||||||
|
int (*reset)(sqlite3_stmt*pStmt);
|
||||||
|
void (*result_blob)(sqlite3_context*,const void*,int,void(*)(void*));
|
||||||
|
void (*result_double)(sqlite3_context*,double);
|
||||||
|
void (*result_error)(sqlite3_context*,const char*,int);
|
||||||
|
void (*result_error16)(sqlite3_context*,const void*,int);
|
||||||
|
void (*result_int)(sqlite3_context*,int);
|
||||||
|
void (*result_int64)(sqlite3_context*,sqlite_int64);
|
||||||
|
void (*result_null)(sqlite3_context*);
|
||||||
|
void (*result_text)(sqlite3_context*,const char*,int,void(*)(void*));
|
||||||
|
void (*result_text16)(sqlite3_context*,const void*,int,void(*)(void*));
|
||||||
|
void (*result_text16be)(sqlite3_context*,const void*,int,void(*)(void*));
|
||||||
|
void (*result_text16le)(sqlite3_context*,const void*,int,void(*)(void*));
|
||||||
|
void (*result_value)(sqlite3_context*,sqlite3_value*);
|
||||||
|
void * (*rollback_hook)(sqlite3*,void(*)(void*),void*);
|
||||||
|
int (*set_authorizer)(sqlite3*,int(*)(void*,int,const char*,const char*,
|
||||||
|
const char*,const char*),void*);
|
||||||
|
void (*set_auxdata)(sqlite3_context*,int,void*,void (*)(void*));
|
||||||
|
char * (*snprintf)(int,char*,const char*,...);
|
||||||
|
int (*step)(sqlite3_stmt*);
|
||||||
|
int (*table_column_metadata)(sqlite3*,const char*,const char*,const char*,
|
||||||
|
char const**,char const**,int*,int*,int*);
|
||||||
|
void (*thread_cleanup)(void);
|
||||||
|
int (*total_changes)(sqlite3*);
|
||||||
|
void * (*trace)(sqlite3*,void(*xTrace)(void*,const char*),void*);
|
||||||
|
int (*transfer_bindings)(sqlite3_stmt*,sqlite3_stmt*);
|
||||||
|
void * (*update_hook)(sqlite3*,void(*)(void*,int ,char const*,char const*,
|
||||||
|
sqlite_int64),void*);
|
||||||
|
void * (*user_data)(sqlite3_context*);
|
||||||
|
const void * (*value_blob)(sqlite3_value*);
|
||||||
|
int (*value_bytes)(sqlite3_value*);
|
||||||
|
int (*value_bytes16)(sqlite3_value*);
|
||||||
|
double (*value_double)(sqlite3_value*);
|
||||||
|
int (*value_int)(sqlite3_value*);
|
||||||
|
sqlite_int64 (*value_int64)(sqlite3_value*);
|
||||||
|
int (*value_numeric_type)(sqlite3_value*);
|
||||||
|
const unsigned char * (*value_text)(sqlite3_value*);
|
||||||
|
const void * (*value_text16)(sqlite3_value*);
|
||||||
|
const void * (*value_text16be)(sqlite3_value*);
|
||||||
|
const void * (*value_text16le)(sqlite3_value*);
|
||||||
|
int (*value_type)(sqlite3_value*);
|
||||||
|
char *(*vmprintf)(const char*,va_list);
|
||||||
|
/* Added ??? */
|
||||||
|
int (*overload_function)(sqlite3*, const char *zFuncName, int nArg);
|
||||||
|
/* Added by 3.3.13 */
|
||||||
|
int (*prepare_v2)(sqlite3*,const char*,int,sqlite3_stmt**,const char**);
|
||||||
|
int (*prepare16_v2)(sqlite3*,const void*,int,sqlite3_stmt**,const void**);
|
||||||
|
int (*clear_bindings)(sqlite3_stmt*);
|
||||||
|
/* Added by 3.4.1 */
|
||||||
|
int (*create_module_v2)(sqlite3*,const char*,const sqlite3_module*,void*,
|
||||||
|
void (*xDestroy)(void *));
|
||||||
|
/* Added by 3.5.0 */
|
||||||
|
int (*bind_zeroblob)(sqlite3_stmt*,int,int);
|
||||||
|
int (*blob_bytes)(sqlite3_blob*);
|
||||||
|
int (*blob_close)(sqlite3_blob*);
|
||||||
|
int (*blob_open)(sqlite3*,const char*,const char*,const char*,sqlite3_int64,
|
||||||
|
int,sqlite3_blob**);
|
||||||
|
int (*blob_read)(sqlite3_blob*,void*,int,int);
|
||||||
|
int (*blob_write)(sqlite3_blob*,const void*,int,int);
|
||||||
|
int (*create_collation_v2)(sqlite3*,const char*,int,void*,
|
||||||
|
int(*)(void*,int,const void*,int,const void*),
|
||||||
|
void(*)(void*));
|
||||||
|
int (*file_control)(sqlite3*,const char*,int,void*);
|
||||||
|
sqlite3_int64 (*memory_highwater)(int);
|
||||||
|
sqlite3_int64 (*memory_used)(void);
|
||||||
|
sqlite3_mutex *(*mutex_alloc)(int);
|
||||||
|
void (*mutex_enter)(sqlite3_mutex*);
|
||||||
|
void (*mutex_free)(sqlite3_mutex*);
|
||||||
|
void (*mutex_leave)(sqlite3_mutex*);
|
||||||
|
int (*mutex_try)(sqlite3_mutex*);
|
||||||
|
int (*open_v2)(const char*,sqlite3**,int,const char*);
|
||||||
|
int (*release_memory)(int);
|
||||||
|
void (*result_error_nomem)(sqlite3_context*);
|
||||||
|
void (*result_error_toobig)(sqlite3_context*);
|
||||||
|
int (*sleep)(int);
|
||||||
|
void (*soft_heap_limit)(int);
|
||||||
|
sqlite3_vfs *(*vfs_find)(const char*);
|
||||||
|
int (*vfs_register)(sqlite3_vfs*,int);
|
||||||
|
int (*vfs_unregister)(sqlite3_vfs*);
|
||||||
|
int (*xthreadsafe)(void);
|
||||||
|
void (*result_zeroblob)(sqlite3_context*,int);
|
||||||
|
void (*result_error_code)(sqlite3_context*,int);
|
||||||
|
int (*test_control)(int, ...);
|
||||||
|
void (*randomness)(int,void*);
|
||||||
|
sqlite3 *(*context_db_handle)(sqlite3_context*);
|
||||||
|
int (*extended_result_codes)(sqlite3*,int);
|
||||||
|
int (*limit)(sqlite3*,int,int);
|
||||||
|
sqlite3_stmt *(*next_stmt)(sqlite3*,sqlite3_stmt*);
|
||||||
|
const char *(*sql)(sqlite3_stmt*);
|
||||||
|
int (*status)(int,int*,int*,int);
|
||||||
|
int (*backup_finish)(sqlite3_backup*);
|
||||||
|
sqlite3_backup *(*backup_init)(sqlite3*,const char*,sqlite3*,const char*);
|
||||||
|
int (*backup_pagecount)(sqlite3_backup*);
|
||||||
|
int (*backup_remaining)(sqlite3_backup*);
|
||||||
|
int (*backup_step)(sqlite3_backup*,int);
|
||||||
|
const char *(*compileoption_get)(int);
|
||||||
|
int (*compileoption_used)(const char*);
|
||||||
|
int (*create_function_v2)(sqlite3*,const char*,int,int,void*,
|
||||||
|
void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
|
||||||
|
void (*xStep)(sqlite3_context*,int,sqlite3_value**),
|
||||||
|
void (*xFinal)(sqlite3_context*),
|
||||||
|
void(*xDestroy)(void*));
|
||||||
|
int (*db_config)(sqlite3*,int,...);
|
||||||
|
sqlite3_mutex *(*db_mutex)(sqlite3*);
|
||||||
|
int (*db_status)(sqlite3*,int,int*,int*,int);
|
||||||
|
int (*extended_errcode)(sqlite3*);
|
||||||
|
void (*log)(int,const char*,...);
|
||||||
|
sqlite3_int64 (*soft_heap_limit64)(sqlite3_int64);
|
||||||
|
const char *(*sourceid)(void);
|
||||||
|
int (*stmt_status)(sqlite3_stmt*,int,int);
|
||||||
|
int (*strnicmp)(const char*,const char*,int);
|
||||||
|
int (*unlock_notify)(sqlite3*,void(*)(void**,int),void*);
|
||||||
|
int (*wal_autocheckpoint)(sqlite3*,int);
|
||||||
|
int (*wal_checkpoint)(sqlite3*,const char*);
|
||||||
|
void *(*wal_hook)(sqlite3*,int(*)(void*,sqlite3*,const char*,int),void*);
|
||||||
|
int (*blob_reopen)(sqlite3_blob*,sqlite3_int64);
|
||||||
|
int (*vtab_config)(sqlite3*,int op,...);
|
||||||
|
int (*vtab_on_conflict)(sqlite3*);
|
||||||
|
/* Version 3.7.16 and later */
|
||||||
|
int (*close_v2)(sqlite3*);
|
||||||
|
const char *(*db_filename)(sqlite3*,const char*);
|
||||||
|
int (*db_readonly)(sqlite3*,const char*);
|
||||||
|
int (*db_release_memory)(sqlite3*);
|
||||||
|
const char *(*errstr)(int);
|
||||||
|
int (*stmt_busy)(sqlite3_stmt*);
|
||||||
|
int (*stmt_readonly)(sqlite3_stmt*);
|
||||||
|
int (*stricmp)(const char*,const char*);
|
||||||
|
int (*uri_boolean)(const char*,const char*,int);
|
||||||
|
sqlite3_int64 (*uri_int64)(const char*,const char*,sqlite3_int64);
|
||||||
|
const char *(*uri_parameter)(const char*,const char*);
|
||||||
|
char *(*vsnprintf)(int,char*,const char*,va_list);
|
||||||
|
int (*wal_checkpoint_v2)(sqlite3*,const char*,int,int*,int*);
|
||||||
|
/* Version 3.8.7 and later */
|
||||||
|
int (*auto_extension)(void(*)(void));
|
||||||
|
int (*bind_blob64)(sqlite3_stmt*,int,const void*,sqlite3_uint64,
|
||||||
|
void(*)(void*));
|
||||||
|
int (*bind_text64)(sqlite3_stmt*,int,const char*,sqlite3_uint64,
|
||||||
|
void(*)(void*),unsigned char);
|
||||||
|
int (*cancel_auto_extension)(void(*)(void));
|
||||||
|
int (*load_extension)(sqlite3*,const char*,const char*,char**);
|
||||||
|
void *(*malloc64)(sqlite3_uint64);
|
||||||
|
sqlite3_uint64 (*msize)(void*);
|
||||||
|
void *(*realloc64)(void*,sqlite3_uint64);
|
||||||
|
void (*reset_auto_extension)(void);
|
||||||
|
void (*result_blob64)(sqlite3_context*,const void*,sqlite3_uint64,
|
||||||
|
void(*)(void*));
|
||||||
|
void (*result_text64)(sqlite3_context*,const char*,sqlite3_uint64,
|
||||||
|
void(*)(void*), unsigned char);
|
||||||
|
int (*strglob)(const char*,const char*);
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
** The following macros redefine the API routines so that they are
|
||||||
|
** redirected through the global sqlite3_api structure.
|
||||||
|
**
|
||||||
|
** This header file is also used by the loadext.c source file
|
||||||
|
** (part of the main SQLite library - not an extension) so that
|
||||||
|
** it can get access to the sqlite3_api_routines structure
|
||||||
|
** definition. But the main library does not want to redefine
|
||||||
|
** the API. So the redefinition macros are only valid if the
|
||||||
|
** SQLITE_CORE macros is undefined.
|
||||||
|
*/
|
||||||
|
#ifndef SQLITE_CORE
|
||||||
|
#define sqlite3_aggregate_context sqlite3_api->aggregate_context
|
||||||
|
#ifndef SQLITE_OMIT_DEPRECATED
|
||||||
|
#define sqlite3_aggregate_count sqlite3_api->aggregate_count
|
||||||
|
#endif
|
||||||
|
#define sqlite3_bind_blob sqlite3_api->bind_blob
|
||||||
|
#define sqlite3_bind_double sqlite3_api->bind_double
|
||||||
|
#define sqlite3_bind_int sqlite3_api->bind_int
|
||||||
|
#define sqlite3_bind_int64 sqlite3_api->bind_int64
|
||||||
|
#define sqlite3_bind_null sqlite3_api->bind_null
|
||||||
|
#define sqlite3_bind_parameter_count sqlite3_api->bind_parameter_count
|
||||||
|
#define sqlite3_bind_parameter_index sqlite3_api->bind_parameter_index
|
||||||
|
#define sqlite3_bind_parameter_name sqlite3_api->bind_parameter_name
|
||||||
|
#define sqlite3_bind_text sqlite3_api->bind_text
|
||||||
|
#define sqlite3_bind_text16 sqlite3_api->bind_text16
|
||||||
|
#define sqlite3_bind_value sqlite3_api->bind_value
|
||||||
|
#define sqlite3_busy_handler sqlite3_api->busy_handler
|
||||||
|
#define sqlite3_busy_timeout sqlite3_api->busy_timeout
|
||||||
|
#define sqlite3_changes sqlite3_api->changes
|
||||||
|
#define sqlite3_close sqlite3_api->close
|
||||||
|
#define sqlite3_collation_needed sqlite3_api->collation_needed
|
||||||
|
#define sqlite3_collation_needed16 sqlite3_api->collation_needed16
|
||||||
|
#define sqlite3_column_blob sqlite3_api->column_blob
|
||||||
|
#define sqlite3_column_bytes sqlite3_api->column_bytes
|
||||||
|
#define sqlite3_column_bytes16 sqlite3_api->column_bytes16
|
||||||
|
#define sqlite3_column_count sqlite3_api->column_count
|
||||||
|
#define sqlite3_column_database_name sqlite3_api->column_database_name
|
||||||
|
#define sqlite3_column_database_name16 sqlite3_api->column_database_name16
|
||||||
|
#define sqlite3_column_decltype sqlite3_api->column_decltype
|
||||||
|
#define sqlite3_column_decltype16 sqlite3_api->column_decltype16
|
||||||
|
#define sqlite3_column_double sqlite3_api->column_double
|
||||||
|
#define sqlite3_column_int sqlite3_api->column_int
|
||||||
|
#define sqlite3_column_int64 sqlite3_api->column_int64
|
||||||
|
#define sqlite3_column_name sqlite3_api->column_name
|
||||||
|
#define sqlite3_column_name16 sqlite3_api->column_name16
|
||||||
|
#define sqlite3_column_origin_name sqlite3_api->column_origin_name
|
||||||
|
#define sqlite3_column_origin_name16 sqlite3_api->column_origin_name16
|
||||||
|
#define sqlite3_column_table_name sqlite3_api->column_table_name
|
||||||
|
#define sqlite3_column_table_name16 sqlite3_api->column_table_name16
|
||||||
|
#define sqlite3_column_text sqlite3_api->column_text
|
||||||
|
#define sqlite3_column_text16 sqlite3_api->column_text16
|
||||||
|
#define sqlite3_column_type sqlite3_api->column_type
|
||||||
|
#define sqlite3_column_value sqlite3_api->column_value
|
||||||
|
#define sqlite3_commit_hook sqlite3_api->commit_hook
|
||||||
|
#define sqlite3_complete sqlite3_api->complete
|
||||||
|
#define sqlite3_complete16 sqlite3_api->complete16
|
||||||
|
#define sqlite3_create_collation sqlite3_api->create_collation
|
||||||
|
#define sqlite3_create_collation16 sqlite3_api->create_collation16
|
||||||
|
#define sqlite3_create_function sqlite3_api->create_function
|
||||||
|
#define sqlite3_create_function16 sqlite3_api->create_function16
|
||||||
|
#define sqlite3_create_module sqlite3_api->create_module
|
||||||
|
#define sqlite3_create_module_v2 sqlite3_api->create_module_v2
|
||||||
|
#define sqlite3_data_count sqlite3_api->data_count
|
||||||
|
#define sqlite3_db_handle sqlite3_api->db_handle
|
||||||
|
#define sqlite3_declare_vtab sqlite3_api->declare_vtab
|
||||||
|
#define sqlite3_enable_shared_cache sqlite3_api->enable_shared_cache
|
||||||
|
#define sqlite3_errcode sqlite3_api->errcode
|
||||||
|
#define sqlite3_errmsg sqlite3_api->errmsg
|
||||||
|
#define sqlite3_errmsg16 sqlite3_api->errmsg16
|
||||||
|
#define sqlite3_exec sqlite3_api->exec
|
||||||
|
#ifndef SQLITE_OMIT_DEPRECATED
|
||||||
|
#define sqlite3_expired sqlite3_api->expired
|
||||||
|
#endif
|
||||||
|
#define sqlite3_finalize sqlite3_api->finalize
|
||||||
|
#define sqlite3_free sqlite3_api->free
|
||||||
|
#define sqlite3_free_table sqlite3_api->free_table
|
||||||
|
#define sqlite3_get_autocommit sqlite3_api->get_autocommit
|
||||||
|
#define sqlite3_get_auxdata sqlite3_api->get_auxdata
|
||||||
|
#define sqlite3_get_table sqlite3_api->get_table
|
||||||
|
#ifndef SQLITE_OMIT_DEPRECATED
|
||||||
|
#define sqlite3_global_recover sqlite3_api->global_recover
|
||||||
|
#endif
|
||||||
|
#define sqlite3_interrupt sqlite3_api->interruptx
|
||||||
|
#define sqlite3_last_insert_rowid sqlite3_api->last_insert_rowid
|
||||||
|
#define sqlite3_libversion sqlite3_api->libversion
|
||||||
|
#define sqlite3_libversion_number sqlite3_api->libversion_number
|
||||||
|
#define sqlite3_malloc sqlite3_api->malloc
|
||||||
|
#define sqlite3_mprintf sqlite3_api->mprintf
|
||||||
|
#define sqlite3_open sqlite3_api->open
|
||||||
|
#define sqlite3_open16 sqlite3_api->open16
|
||||||
|
#define sqlite3_prepare sqlite3_api->prepare
|
||||||
|
#define sqlite3_prepare16 sqlite3_api->prepare16
|
||||||
|
#define sqlite3_prepare_v2 sqlite3_api->prepare_v2
|
||||||
|
#define sqlite3_prepare16_v2 sqlite3_api->prepare16_v2
|
||||||
|
#define sqlite3_profile sqlite3_api->profile
|
||||||
|
#define sqlite3_progress_handler sqlite3_api->progress_handler
|
||||||
|
#define sqlite3_realloc sqlite3_api->realloc
|
||||||
|
#define sqlite3_reset sqlite3_api->reset
|
||||||
|
#define sqlite3_result_blob sqlite3_api->result_blob
|
||||||
|
#define sqlite3_result_double sqlite3_api->result_double
|
||||||
|
#define sqlite3_result_error sqlite3_api->result_error
|
||||||
|
#define sqlite3_result_error16 sqlite3_api->result_error16
|
||||||
|
#define sqlite3_result_int sqlite3_api->result_int
|
||||||
|
#define sqlite3_result_int64 sqlite3_api->result_int64
|
||||||
|
#define sqlite3_result_null sqlite3_api->result_null
|
||||||
|
#define sqlite3_result_text sqlite3_api->result_text
|
||||||
|
#define sqlite3_result_text16 sqlite3_api->result_text16
|
||||||
|
#define sqlite3_result_text16be sqlite3_api->result_text16be
|
||||||
|
#define sqlite3_result_text16le sqlite3_api->result_text16le
|
||||||
|
#define sqlite3_result_value sqlite3_api->result_value
|
||||||
|
#define sqlite3_rollback_hook sqlite3_api->rollback_hook
|
||||||
|
#define sqlite3_set_authorizer sqlite3_api->set_authorizer
|
||||||
|
#define sqlite3_set_auxdata sqlite3_api->set_auxdata
|
||||||
|
#define sqlite3_snprintf sqlite3_api->snprintf
|
||||||
|
#define sqlite3_step sqlite3_api->step
|
||||||
|
#define sqlite3_table_column_metadata sqlite3_api->table_column_metadata
|
||||||
|
#define sqlite3_thread_cleanup sqlite3_api->thread_cleanup
|
||||||
|
#define sqlite3_total_changes sqlite3_api->total_changes
|
||||||
|
#define sqlite3_trace sqlite3_api->trace
|
||||||
|
#ifndef SQLITE_OMIT_DEPRECATED
|
||||||
|
#define sqlite3_transfer_bindings sqlite3_api->transfer_bindings
|
||||||
|
#endif
|
||||||
|
#define sqlite3_update_hook sqlite3_api->update_hook
|
||||||
|
#define sqlite3_user_data sqlite3_api->user_data
|
||||||
|
#define sqlite3_value_blob sqlite3_api->value_blob
|
||||||
|
#define sqlite3_value_bytes sqlite3_api->value_bytes
|
||||||
|
#define sqlite3_value_bytes16 sqlite3_api->value_bytes16
|
||||||
|
#define sqlite3_value_double sqlite3_api->value_double
|
||||||
|
#define sqlite3_value_int sqlite3_api->value_int
|
||||||
|
#define sqlite3_value_int64 sqlite3_api->value_int64
|
||||||
|
#define sqlite3_value_numeric_type sqlite3_api->value_numeric_type
|
||||||
|
#define sqlite3_value_text sqlite3_api->value_text
|
||||||
|
#define sqlite3_value_text16 sqlite3_api->value_text16
|
||||||
|
#define sqlite3_value_text16be sqlite3_api->value_text16be
|
||||||
|
#define sqlite3_value_text16le sqlite3_api->value_text16le
|
||||||
|
#define sqlite3_value_type sqlite3_api->value_type
|
||||||
|
#define sqlite3_vmprintf sqlite3_api->vmprintf
|
||||||
|
#define sqlite3_overload_function sqlite3_api->overload_function
|
||||||
|
#define sqlite3_prepare_v2 sqlite3_api->prepare_v2
|
||||||
|
#define sqlite3_prepare16_v2 sqlite3_api->prepare16_v2
|
||||||
|
#define sqlite3_clear_bindings sqlite3_api->clear_bindings
|
||||||
|
#define sqlite3_bind_zeroblob sqlite3_api->bind_zeroblob
|
||||||
|
#define sqlite3_blob_bytes sqlite3_api->blob_bytes
|
||||||
|
#define sqlite3_blob_close sqlite3_api->blob_close
|
||||||
|
#define sqlite3_blob_open sqlite3_api->blob_open
|
||||||
|
#define sqlite3_blob_read sqlite3_api->blob_read
|
||||||
|
#define sqlite3_blob_write sqlite3_api->blob_write
|
||||||
|
#define sqlite3_create_collation_v2 sqlite3_api->create_collation_v2
|
||||||
|
#define sqlite3_file_control sqlite3_api->file_control
|
||||||
|
#define sqlite3_memory_highwater sqlite3_api->memory_highwater
|
||||||
|
#define sqlite3_memory_used sqlite3_api->memory_used
|
||||||
|
#define sqlite3_mutex_alloc sqlite3_api->mutex_alloc
|
||||||
|
#define sqlite3_mutex_enter sqlite3_api->mutex_enter
|
||||||
|
#define sqlite3_mutex_free sqlite3_api->mutex_free
|
||||||
|
#define sqlite3_mutex_leave sqlite3_api->mutex_leave
|
||||||
|
#define sqlite3_mutex_try sqlite3_api->mutex_try
|
||||||
|
#define sqlite3_open_v2 sqlite3_api->open_v2
|
||||||
|
#define sqlite3_release_memory sqlite3_api->release_memory
|
||||||
|
#define sqlite3_result_error_nomem sqlite3_api->result_error_nomem
|
||||||
|
#define sqlite3_result_error_toobig sqlite3_api->result_error_toobig
|
||||||
|
#define sqlite3_sleep sqlite3_api->sleep
|
||||||
|
#define sqlite3_soft_heap_limit sqlite3_api->soft_heap_limit
|
||||||
|
#define sqlite3_vfs_find sqlite3_api->vfs_find
|
||||||
|
#define sqlite3_vfs_register sqlite3_api->vfs_register
|
||||||
|
#define sqlite3_vfs_unregister sqlite3_api->vfs_unregister
|
||||||
|
#define sqlite3_threadsafe sqlite3_api->xthreadsafe
|
||||||
|
#define sqlite3_result_zeroblob sqlite3_api->result_zeroblob
|
||||||
|
#define sqlite3_result_error_code sqlite3_api->result_error_code
|
||||||
|
#define sqlite3_test_control sqlite3_api->test_control
|
||||||
|
#define sqlite3_randomness sqlite3_api->randomness
|
||||||
|
#define sqlite3_context_db_handle sqlite3_api->context_db_handle
|
||||||
|
#define sqlite3_extended_result_codes sqlite3_api->extended_result_codes
|
||||||
|
#define sqlite3_limit sqlite3_api->limit
|
||||||
|
#define sqlite3_next_stmt sqlite3_api->next_stmt
|
||||||
|
#define sqlite3_sql sqlite3_api->sql
|
||||||
|
#define sqlite3_status sqlite3_api->status
|
||||||
|
#define sqlite3_backup_finish sqlite3_api->backup_finish
|
||||||
|
#define sqlite3_backup_init sqlite3_api->backup_init
|
||||||
|
#define sqlite3_backup_pagecount sqlite3_api->backup_pagecount
|
||||||
|
#define sqlite3_backup_remaining sqlite3_api->backup_remaining
|
||||||
|
#define sqlite3_backup_step sqlite3_api->backup_step
|
||||||
|
#define sqlite3_compileoption_get sqlite3_api->compileoption_get
|
||||||
|
#define sqlite3_compileoption_used sqlite3_api->compileoption_used
|
||||||
|
#define sqlite3_create_function_v2 sqlite3_api->create_function_v2
|
||||||
|
#define sqlite3_db_config sqlite3_api->db_config
|
||||||
|
#define sqlite3_db_mutex sqlite3_api->db_mutex
|
||||||
|
#define sqlite3_db_status sqlite3_api->db_status
|
||||||
|
#define sqlite3_extended_errcode sqlite3_api->extended_errcode
|
||||||
|
#define sqlite3_log sqlite3_api->log
|
||||||
|
#define sqlite3_soft_heap_limit64 sqlite3_api->soft_heap_limit64
|
||||||
|
#define sqlite3_sourceid sqlite3_api->sourceid
|
||||||
|
#define sqlite3_stmt_status sqlite3_api->stmt_status
|
||||||
|
#define sqlite3_strnicmp sqlite3_api->strnicmp
|
||||||
|
#define sqlite3_unlock_notify sqlite3_api->unlock_notify
|
||||||
|
#define sqlite3_wal_autocheckpoint sqlite3_api->wal_autocheckpoint
|
||||||
|
#define sqlite3_wal_checkpoint sqlite3_api->wal_checkpoint
|
||||||
|
#define sqlite3_wal_hook sqlite3_api->wal_hook
|
||||||
|
#define sqlite3_blob_reopen sqlite3_api->blob_reopen
|
||||||
|
#define sqlite3_vtab_config sqlite3_api->vtab_config
|
||||||
|
#define sqlite3_vtab_on_conflict sqlite3_api->vtab_on_conflict
|
||||||
|
/* Version 3.7.16 and later */
|
||||||
|
#define sqlite3_close_v2 sqlite3_api->close_v2
|
||||||
|
#define sqlite3_db_filename sqlite3_api->db_filename
|
||||||
|
#define sqlite3_db_readonly sqlite3_api->db_readonly
|
||||||
|
#define sqlite3_db_release_memory sqlite3_api->db_release_memory
|
||||||
|
#define sqlite3_errstr sqlite3_api->errstr
|
||||||
|
#define sqlite3_stmt_busy sqlite3_api->stmt_busy
|
||||||
|
#define sqlite3_stmt_readonly sqlite3_api->stmt_readonly
|
||||||
|
#define sqlite3_stricmp sqlite3_api->stricmp
|
||||||
|
#define sqlite3_uri_boolean sqlite3_api->uri_boolean
|
||||||
|
#define sqlite3_uri_int64 sqlite3_api->uri_int64
|
||||||
|
#define sqlite3_uri_parameter sqlite3_api->uri_parameter
|
||||||
|
#define sqlite3_uri_vsnprintf sqlite3_api->vsnprintf
|
||||||
|
#define sqlite3_wal_checkpoint_v2 sqlite3_api->wal_checkpoint_v2
|
||||||
|
/* Version 3.8.7 and later */
|
||||||
|
#define sqlite3_auto_extension sqlite3_api->auto_extension
|
||||||
|
#define sqlite3_bind_blob64 sqlite3_api->bind_blob64
|
||||||
|
#define sqlite3_bind_text64 sqlite3_api->bind_text64
|
||||||
|
#define sqlite3_cancel_auto_extension sqlite3_api->cancel_auto_extension
|
||||||
|
#define sqlite3_load_extension sqlite3_api->load_extension
|
||||||
|
#define sqlite3_malloc64 sqlite3_api->malloc64
|
||||||
|
#define sqlite3_msize sqlite3_api->msize
|
||||||
|
#define sqlite3_realloc64 sqlite3_api->realloc64
|
||||||
|
#define sqlite3_reset_auto_extension sqlite3_api->reset_auto_extension
|
||||||
|
#define sqlite3_result_blob64 sqlite3_api->result_blob64
|
||||||
|
#define sqlite3_result_text64 sqlite3_api->result_text64
|
||||||
|
#define sqlite3_strglob sqlite3_api->strglob
|
||||||
|
#endif /* SQLITE_CORE */
|
||||||
|
|
||||||
|
#ifndef SQLITE_CORE
|
||||||
|
/* This case when the file really is being compiled as a loadable
|
||||||
|
** extension */
|
||||||
|
# define SQLITE_EXTENSION_INIT1 const sqlite3_api_routines *sqlite3_api=0;
|
||||||
|
# define SQLITE_EXTENSION_INIT2(v) sqlite3_api=v;
|
||||||
|
# define SQLITE_EXTENSION_INIT3 \
|
||||||
|
extern const sqlite3_api_routines *sqlite3_api;
|
||||||
|
#else
|
||||||
|
/* This case when the file is being statically linked into the
|
||||||
|
** application */
|
||||||
|
# define SQLITE_EXTENSION_INIT1 /*no-op*/
|
||||||
|
# define SQLITE_EXTENSION_INIT2(v) (void)v; /* unused parameter */
|
||||||
|
# define SQLITE_EXTENSION_INIT3 /*no-op*/
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* _SQLITE3EXT_H_ */
|
64
src/libs/codemodelbackendipc/cmbalivecommand.cpp
Normal file
64
src/libs/codemodelbackendipc/cmbalivecommand.cpp
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "cmbalivecommand.h"
|
||||||
|
|
||||||
|
#include <QtDebug>
|
||||||
|
|
||||||
|
#include <QDataStream>
|
||||||
|
|
||||||
|
namespace CodeModelBackEnd {
|
||||||
|
|
||||||
|
QDataStream &operator<<(QDataStream &out, const AliveCommand &/*command*/)
|
||||||
|
{
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDataStream &operator>>(QDataStream &in, AliveCommand &/*command*/)
|
||||||
|
{
|
||||||
|
return in;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator == (const AliveCommand &/*first*/, const AliveCommand &/*second*/)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator < (const AliveCommand &/*first*/, const AliveCommand &/*second*/)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDebug operator <<(QDebug debug, const AliveCommand &/*command*/)
|
||||||
|
{
|
||||||
|
return debug.nospace() << "AliveCommand()";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
55
src/libs/codemodelbackendipc/cmbalivecommand.h
Normal file
55
src/libs/codemodelbackendipc/cmbalivecommand.h
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef CMBALIVECOMMAND_H
|
||||||
|
#define CMBALIVECOMMAND_H
|
||||||
|
|
||||||
|
#include "codemodelbackendipc_global.h"
|
||||||
|
|
||||||
|
#include <QMetaType>
|
||||||
|
|
||||||
|
namespace CodeModelBackEnd {
|
||||||
|
|
||||||
|
class CMBIPC_EXPORT AliveCommand
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const AliveCommand &command);
|
||||||
|
CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, AliveCommand &command);
|
||||||
|
CMBIPC_EXPORT bool operator == (const AliveCommand &first, const AliveCommand &second);
|
||||||
|
CMBIPC_EXPORT bool operator < (const AliveCommand &first, const AliveCommand &second);
|
||||||
|
|
||||||
|
CMBIPC_EXPORT QDebug operator <<(QDebug debug, const AliveCommand &command);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(CodeModelBackEnd::AliveCommand)
|
||||||
|
|
||||||
|
#endif // CMBALIVECOMMAND_H
|
106
src/libs/codemodelbackendipc/cmbcodecompletedcommand.cpp
Normal file
106
src/libs/codemodelbackendipc/cmbcodecompletedcommand.cpp
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "cmbcodecompletedcommand.h"
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
|
#include <QDataStream>
|
||||||
|
|
||||||
|
#include <ostream>
|
||||||
|
|
||||||
|
namespace CodeModelBackEnd {
|
||||||
|
|
||||||
|
CodeCompletedCommand::CodeCompletedCommand(const QVector<CodeCompletion> &codeCompletions, quint64 ticketNumber)
|
||||||
|
: codeCompletions_(codeCompletions),
|
||||||
|
ticketNumber_(ticketNumber)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
const QVector<CodeCompletion> &CodeCompletedCommand::codeCompletions() const
|
||||||
|
{
|
||||||
|
return codeCompletions_;
|
||||||
|
}
|
||||||
|
|
||||||
|
quint64 CodeCompletedCommand::ticketNumber() const
|
||||||
|
{
|
||||||
|
return ticketNumber_;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDataStream &operator<<(QDataStream &out, const CodeCompletedCommand &command)
|
||||||
|
{
|
||||||
|
out << command.codeCompletions_;
|
||||||
|
out << command.ticketNumber_;
|
||||||
|
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDataStream &operator>>(QDataStream &in, CodeCompletedCommand &command)
|
||||||
|
{
|
||||||
|
in >> command.codeCompletions_;
|
||||||
|
in >> command.ticketNumber_;
|
||||||
|
|
||||||
|
return in;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator == (const CodeCompletedCommand &first, const CodeCompletedCommand &second)
|
||||||
|
{
|
||||||
|
return first.ticketNumber_ == second.ticketNumber_
|
||||||
|
&& first.codeCompletions_ == second.codeCompletions_;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator < (const CodeCompletedCommand &first, const CodeCompletedCommand &second)
|
||||||
|
{
|
||||||
|
return first.ticketNumber_ < second.ticketNumber_;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDebug operator <<(QDebug debug, const CodeCompletedCommand &command)
|
||||||
|
{
|
||||||
|
debug.nospace() << "CodeCompletedCommand(";
|
||||||
|
|
||||||
|
debug.nospace() << command.codeCompletions_ << ", " << command.ticketNumber_;
|
||||||
|
|
||||||
|
debug.nospace() << ")";
|
||||||
|
|
||||||
|
return debug;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PrintTo(const CodeCompletedCommand &command, ::std::ostream* os)
|
||||||
|
{
|
||||||
|
QString output;
|
||||||
|
QDebug debug(&output);
|
||||||
|
|
||||||
|
debug << command;
|
||||||
|
|
||||||
|
*os << output.toUtf8().constData();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace CodeModelBackEnd
|
||||||
|
|
74
src/libs/codemodelbackendipc/cmbcodecompletedcommand.h
Normal file
74
src/libs/codemodelbackendipc/cmbcodecompletedcommand.h
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef CODEMODELBACKEND_CODECOMPLETEDCOMMAND_H
|
||||||
|
#define CODEMODELBACKEND_CODECOMPLETEDCOMMAND_H
|
||||||
|
|
||||||
|
#include <QMetaType>
|
||||||
|
#include <QVector>
|
||||||
|
|
||||||
|
#include "codecompletion.h"
|
||||||
|
|
||||||
|
namespace CodeModelBackEnd {
|
||||||
|
|
||||||
|
class CMBIPC_EXPORT CodeCompletedCommand
|
||||||
|
{
|
||||||
|
friend CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const CodeCompletedCommand &command);
|
||||||
|
friend CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, CodeCompletedCommand &command);
|
||||||
|
friend CMBIPC_EXPORT bool operator == (const CodeCompletedCommand &first, const CodeCompletedCommand &second);
|
||||||
|
friend CMBIPC_EXPORT bool operator < (const CodeCompletedCommand &first, const CodeCompletedCommand &second);
|
||||||
|
friend CMBIPC_EXPORT QDebug operator <<(QDebug debug, const CodeCompletedCommand &command);
|
||||||
|
friend void PrintTo(const CodeCompletedCommand &command, ::std::ostream* os);
|
||||||
|
public:
|
||||||
|
CodeCompletedCommand() = default;
|
||||||
|
CodeCompletedCommand(const QVector<CodeCompletion> &codeCompletions, quint64 ticketNumber);
|
||||||
|
|
||||||
|
const QVector<CodeCompletion> &codeCompletions() const;
|
||||||
|
|
||||||
|
quint64 ticketNumber() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
QVector<CodeCompletion> codeCompletions_;
|
||||||
|
quint64 ticketNumber_ = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const CodeCompletedCommand &command);
|
||||||
|
CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, CodeCompletedCommand &command);
|
||||||
|
CMBIPC_EXPORT bool operator == (const CodeCompletedCommand &first, const CodeCompletedCommand &second);
|
||||||
|
CMBIPC_EXPORT bool operator < (const CodeCompletedCommand &first, const CodeCompletedCommand &second);
|
||||||
|
|
||||||
|
CMBIPC_EXPORT QDebug operator <<(QDebug debug, const CodeCompletedCommand &command);
|
||||||
|
void PrintTo(const CodeCompletedCommand &command, ::std::ostream* os);
|
||||||
|
|
||||||
|
} // namespace CodeModelBackEnd
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(CodeModelBackEnd::CodeCompletedCommand)
|
||||||
|
|
||||||
|
#endif // CODEMODELBACKEND_CODECOMPLETEDCOMMAND_H
|
108
src/libs/codemodelbackendipc/cmbcommands.cpp
Normal file
108
src/libs/codemodelbackendipc/cmbcommands.cpp
Normal file
@@ -0,0 +1,108 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "cmbcommands.h"
|
||||||
|
|
||||||
|
#include "cmbalivecommand.h"
|
||||||
|
#include "cmbendcommand.h"
|
||||||
|
#include "cmbechocommand.h"
|
||||||
|
#include "cmbregistertranslationunitsforcodecompletioncommand.h"
|
||||||
|
#include "cmbunregistertranslationunitsforcodecompletioncommand.h"
|
||||||
|
#include "cmbregisterprojectsforcodecompletioncommand.h"
|
||||||
|
#include "cmbunregisterprojectsforcodecompletioncommand.h"
|
||||||
|
#include "cmbcompletecodecommand.h"
|
||||||
|
#include "cmbcodecompletedcommand.h"
|
||||||
|
#include "projectpartsdonotexistcommand.h"
|
||||||
|
#include "translationunitdoesnotexistcommand.h"
|
||||||
|
|
||||||
|
#include <QDataStream>
|
||||||
|
|
||||||
|
namespace CodeModelBackEnd {
|
||||||
|
|
||||||
|
void Commands::registerCommands()
|
||||||
|
{
|
||||||
|
qRegisterMetaType<EndCommand>();
|
||||||
|
qRegisterMetaTypeStreamOperators<EndCommand>();
|
||||||
|
QMetaType::registerComparators<EndCommand>();
|
||||||
|
|
||||||
|
qRegisterMetaType<AliveCommand>();
|
||||||
|
qRegisterMetaTypeStreamOperators<AliveCommand>();
|
||||||
|
QMetaType::registerComparators<AliveCommand>();
|
||||||
|
|
||||||
|
qRegisterMetaType<EchoCommand>();
|
||||||
|
qRegisterMetaTypeStreamOperators<EchoCommand>();
|
||||||
|
|
||||||
|
qRegisterMetaType<RegisterTranslationUnitForCodeCompletionCommand>();
|
||||||
|
qRegisterMetaTypeStreamOperators<RegisterTranslationUnitForCodeCompletionCommand>();
|
||||||
|
QMetaType::registerComparators<RegisterTranslationUnitForCodeCompletionCommand>();
|
||||||
|
|
||||||
|
qRegisterMetaType<FileContainer>();
|
||||||
|
qRegisterMetaTypeStreamOperators<FileContainer>();
|
||||||
|
QMetaType::registerComparators<FileContainer>();
|
||||||
|
|
||||||
|
qRegisterMetaType<UnregisterTranslationUnitsForCodeCompletionCommand>();
|
||||||
|
qRegisterMetaTypeStreamOperators<UnregisterTranslationUnitsForCodeCompletionCommand>();
|
||||||
|
QMetaType::registerComparators<UnregisterTranslationUnitsForCodeCompletionCommand>();
|
||||||
|
|
||||||
|
qRegisterMetaType<CompleteCodeCommand>();
|
||||||
|
qRegisterMetaTypeStreamOperators<CompleteCodeCommand>();
|
||||||
|
QMetaType::registerComparators<CompleteCodeCommand>();
|
||||||
|
|
||||||
|
qRegisterMetaType<CodeCompletion>();
|
||||||
|
qRegisterMetaTypeStreamOperators<CodeCompletion>();
|
||||||
|
QMetaType::registerComparators<CodeCompletion>();
|
||||||
|
|
||||||
|
qRegisterMetaType<CodeCompletedCommand>();
|
||||||
|
qRegisterMetaTypeStreamOperators<CodeCompletedCommand>();
|
||||||
|
QMetaType::registerComparators<CodeCompletedCommand>();
|
||||||
|
|
||||||
|
qRegisterMetaType<RegisterProjectPartsForCodeCompletionCommand>();
|
||||||
|
qRegisterMetaTypeStreamOperators<RegisterProjectPartsForCodeCompletionCommand>();
|
||||||
|
QMetaType::registerComparators<RegisterProjectPartsForCodeCompletionCommand>();
|
||||||
|
|
||||||
|
qRegisterMetaType<ProjectPartContainer>();
|
||||||
|
qRegisterMetaTypeStreamOperators<ProjectPartContainer>();
|
||||||
|
QMetaType::registerComparators<ProjectPartContainer>();
|
||||||
|
|
||||||
|
qRegisterMetaType<UnregisterProjectPartsForCodeCompletionCommand>();
|
||||||
|
qRegisterMetaTypeStreamOperators<UnregisterProjectPartsForCodeCompletionCommand>();
|
||||||
|
QMetaType::registerComparators<UnregisterProjectPartsForCodeCompletionCommand>();
|
||||||
|
|
||||||
|
qRegisterMetaType<TranslationUnitDoesNotExistCommand>();
|
||||||
|
qRegisterMetaTypeStreamOperators<TranslationUnitDoesNotExistCommand>();
|
||||||
|
QMetaType::registerComparators<TranslationUnitDoesNotExistCommand>();
|
||||||
|
|
||||||
|
qRegisterMetaType<ProjectPartsDoNotExistCommand>();
|
||||||
|
qRegisterMetaTypeStreamOperators<ProjectPartsDoNotExistCommand>();
|
||||||
|
QMetaType::registerComparators<ProjectPartsDoNotExistCommand>();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace CodeModelBackEnd
|
||||||
|
|
45
src/libs/codemodelbackendipc/cmbcommands.h
Normal file
45
src/libs/codemodelbackendipc/cmbcommands.h
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef CODEMODELBACKEND_COMMANDS_H
|
||||||
|
#define CODEMODELBACKEND_COMMANDS_H
|
||||||
|
|
||||||
|
#include <codemodelbackendipc_global.h>
|
||||||
|
|
||||||
|
namespace CodeModelBackEnd {
|
||||||
|
|
||||||
|
namespace Commands
|
||||||
|
{
|
||||||
|
CMBIPC_EXPORT void registerCommands();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace CodeModelBackEnd
|
||||||
|
|
||||||
|
#endif // CODEMODELBACKEND_COMMANDS_H
|
146
src/libs/codemodelbackendipc/cmbcompletecodecommand.cpp
Normal file
146
src/libs/codemodelbackendipc/cmbcompletecodecommand.cpp
Normal file
@@ -0,0 +1,146 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "cmbcompletecodecommand.h"
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
|
#include <QDataStream>
|
||||||
|
|
||||||
|
#include <ostream>
|
||||||
|
|
||||||
|
namespace CodeModelBackEnd {
|
||||||
|
|
||||||
|
quint64 CompleteCodeCommand::ticketCounter = 0;
|
||||||
|
|
||||||
|
CompleteCodeCommand::CompleteCodeCommand(const Utf8String &filePath, quint32 line, quint32 column, const Utf8String &projectPartId)
|
||||||
|
: filePath_(filePath),
|
||||||
|
projectPartId_(projectPartId),
|
||||||
|
ticketNumber_(++ticketCounter),
|
||||||
|
line_(line),
|
||||||
|
column_(column)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
const Utf8String &CompleteCodeCommand::filePath() const
|
||||||
|
{
|
||||||
|
return filePath_;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Utf8String &CompleteCodeCommand::projectPartId() const
|
||||||
|
{
|
||||||
|
return projectPartId_;
|
||||||
|
}
|
||||||
|
|
||||||
|
quint32 CompleteCodeCommand::line() const
|
||||||
|
{
|
||||||
|
return line_;
|
||||||
|
}
|
||||||
|
|
||||||
|
quint32 CompleteCodeCommand::column() const
|
||||||
|
{
|
||||||
|
return column_;
|
||||||
|
}
|
||||||
|
|
||||||
|
quint64 CompleteCodeCommand::ticketNumber() const
|
||||||
|
{
|
||||||
|
return ticketNumber_;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDataStream &operator<<(QDataStream &out, const CompleteCodeCommand &command)
|
||||||
|
{
|
||||||
|
out << command.filePath_;
|
||||||
|
out << command.projectPartId_;
|
||||||
|
out << command.ticketNumber_;
|
||||||
|
out << command.line_;
|
||||||
|
out << command.column_;
|
||||||
|
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDataStream &operator>>(QDataStream &in, CompleteCodeCommand &command)
|
||||||
|
{
|
||||||
|
in >> command.filePath_;
|
||||||
|
in >> command.projectPartId_;
|
||||||
|
in >> command.ticketNumber_;
|
||||||
|
in >> command.line_;
|
||||||
|
in >> command.column_;
|
||||||
|
|
||||||
|
return in;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator == (const CompleteCodeCommand &first, const CompleteCodeCommand &second)
|
||||||
|
{
|
||||||
|
return first.ticketNumber_ == second.ticketNumber_
|
||||||
|
&& first.filePath_ == second.filePath_
|
||||||
|
&& first.projectPartId_ == second.projectPartId_
|
||||||
|
&& first.line_ == second.line_
|
||||||
|
&& first.column_ == second.column_;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator < (const CompleteCodeCommand &first, const CompleteCodeCommand &second)
|
||||||
|
{
|
||||||
|
return first.ticketNumber_ < second.ticketNumber_
|
||||||
|
&& first.filePath_ < second.filePath_
|
||||||
|
&& first.projectPartId_ < second.projectPartId_
|
||||||
|
&& first.line_ < second.line_
|
||||||
|
&& first.column_ < second.column_;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDebug operator <<(QDebug debug, const CompleteCodeCommand &command)
|
||||||
|
{
|
||||||
|
debug.nospace() << "CompleteCodeCommand(";
|
||||||
|
|
||||||
|
debug.nospace() << command.filePath_ << ", ";
|
||||||
|
debug.nospace() << command.line_<< ", ";
|
||||||
|
debug.nospace() << command.column_<< ", ";
|
||||||
|
debug.nospace() << command.projectPartId_ << ", ";
|
||||||
|
debug.nospace() << command.ticketNumber_;
|
||||||
|
|
||||||
|
debug.nospace() << ")";
|
||||||
|
|
||||||
|
return debug;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PrintTo(const CompleteCodeCommand &command, ::std::ostream* os)
|
||||||
|
{
|
||||||
|
*os << "CompleteCodeCommand(";
|
||||||
|
|
||||||
|
*os << command.filePath_.constData() << ", ";
|
||||||
|
*os << command.line_ << ", ";
|
||||||
|
*os << command.column_ << ", ";
|
||||||
|
*os << command.projectPartId_.constData() << ", ";
|
||||||
|
*os << command.ticketNumber_;
|
||||||
|
|
||||||
|
*os << ")";
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace CodeModelBackEnd
|
||||||
|
|
86
src/libs/codemodelbackendipc/cmbcompletecodecommand.h
Normal file
86
src/libs/codemodelbackendipc/cmbcompletecodecommand.h
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef CODEMODELBACKEND_COMPLETECODECOMMAND_H
|
||||||
|
#define CODEMODELBACKEND_COMPLETECODECOMMAND_H
|
||||||
|
|
||||||
|
#include "codemodelbackendipc_global.h"
|
||||||
|
|
||||||
|
#include <QMetaType>
|
||||||
|
#include <utf8string.h>
|
||||||
|
|
||||||
|
namespace CodeModelBackEnd {
|
||||||
|
|
||||||
|
class CMBIPC_EXPORT CompleteCodeCommand
|
||||||
|
{
|
||||||
|
friend CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const CompleteCodeCommand &command);
|
||||||
|
friend CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, CompleteCodeCommand &command);
|
||||||
|
friend CMBIPC_EXPORT bool operator == (const CompleteCodeCommand &first, const CompleteCodeCommand &second);
|
||||||
|
friend CMBIPC_EXPORT bool operator < (const CompleteCodeCommand &first, const CompleteCodeCommand &second);
|
||||||
|
friend CMBIPC_EXPORT QDebug operator <<(QDebug debug, const CompleteCodeCommand &command);
|
||||||
|
friend void PrintTo(const CompleteCodeCommand &command, ::std::ostream* os);
|
||||||
|
|
||||||
|
public:
|
||||||
|
CompleteCodeCommand() = default;
|
||||||
|
CompleteCodeCommand(const Utf8String &filePath,
|
||||||
|
quint32 line,
|
||||||
|
quint32 column,
|
||||||
|
const Utf8String &projectPartId);
|
||||||
|
|
||||||
|
const Utf8String &filePath() const;
|
||||||
|
const Utf8String &projectPartId() const;
|
||||||
|
|
||||||
|
quint32 line() const;
|
||||||
|
quint32 column() const;
|
||||||
|
|
||||||
|
quint64 ticketNumber() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
Utf8String filePath_;
|
||||||
|
Utf8String projectPartId_;
|
||||||
|
static quint64 ticketCounter;
|
||||||
|
quint64 ticketNumber_;
|
||||||
|
quint32 line_ = 0;
|
||||||
|
quint32 column_ = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const CompleteCodeCommand &command);
|
||||||
|
CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, CompleteCodeCommand &command);
|
||||||
|
CMBIPC_EXPORT bool operator == (const CompleteCodeCommand &first, const CompleteCodeCommand &second);
|
||||||
|
CMBIPC_EXPORT bool operator < (const CompleteCodeCommand &first, const CompleteCodeCommand &second);
|
||||||
|
|
||||||
|
CMBIPC_EXPORT QDebug operator <<(QDebug debug, const CompleteCodeCommand &command);
|
||||||
|
void PrintTo(const CompleteCodeCommand &command, ::std::ostream* os);
|
||||||
|
|
||||||
|
} // namespace CodeModelBackEnd
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(CodeModelBackEnd::CompleteCodeCommand)
|
||||||
|
|
||||||
|
#endif // CODEMODELBACKEND_COMPLETECODECOMMAND_H
|
92
src/libs/codemodelbackendipc/cmbechocommand.cpp
Normal file
92
src/libs/codemodelbackendipc/cmbechocommand.cpp
Normal file
@@ -0,0 +1,92 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "cmbechocommand.h"
|
||||||
|
|
||||||
|
#include <QtDebug>
|
||||||
|
|
||||||
|
#include <QDataStream>
|
||||||
|
|
||||||
|
#include <ostream>
|
||||||
|
|
||||||
|
namespace CodeModelBackEnd {
|
||||||
|
|
||||||
|
EchoCommand::EchoCommand(const QVariant &command)
|
||||||
|
: command_(command)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
const QVariant &EchoCommand::command() const
|
||||||
|
{
|
||||||
|
return command_;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDataStream &operator<<(QDataStream &out, const EchoCommand &command)
|
||||||
|
{
|
||||||
|
out << command.command();
|
||||||
|
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDataStream &operator>>(QDataStream &in, EchoCommand &command)
|
||||||
|
{
|
||||||
|
in >> command.command_;
|
||||||
|
|
||||||
|
return in;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator == (const EchoCommand &first, const EchoCommand &second)
|
||||||
|
{
|
||||||
|
return first.command_ == second.command_;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator < (const EchoCommand &first, const EchoCommand &second)
|
||||||
|
{
|
||||||
|
return first.command_ < second.command_;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDebug operator <<(QDebug debug, const EchoCommand &command)
|
||||||
|
{
|
||||||
|
return debug.nospace() << "EchoCommand(" << command.command() << ")";
|
||||||
|
}
|
||||||
|
|
||||||
|
void PrintTo(const EchoCommand &command, ::std::ostream* os)
|
||||||
|
{
|
||||||
|
QString output;
|
||||||
|
QDebug debug(&output);
|
||||||
|
|
||||||
|
debug << command;
|
||||||
|
|
||||||
|
*os << output.toUtf8().constData();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace CodeModelBackEnd
|
||||||
|
|
68
src/libs/codemodelbackendipc/cmbechocommand.h
Normal file
68
src/libs/codemodelbackendipc/cmbechocommand.h
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef CODEMODELBACKEND_ECHOCOMMAND_H
|
||||||
|
#define CODEMODELBACKEND_ECHOCOMMAND_H
|
||||||
|
|
||||||
|
#include "codemodelbackendipc_global.h"
|
||||||
|
|
||||||
|
#include <QMetaType>
|
||||||
|
#include <QVariant>
|
||||||
|
|
||||||
|
namespace CodeModelBackEnd {
|
||||||
|
|
||||||
|
class CMBIPC_EXPORT EchoCommand
|
||||||
|
{
|
||||||
|
friend CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, EchoCommand &command);
|
||||||
|
friend CMBIPC_EXPORT bool operator == (const EchoCommand &first, const EchoCommand &second);
|
||||||
|
friend CMBIPC_EXPORT bool operator < (const EchoCommand &first, const EchoCommand &second);
|
||||||
|
public:
|
||||||
|
EchoCommand() = default;
|
||||||
|
explicit EchoCommand(const QVariant &command);
|
||||||
|
|
||||||
|
const QVariant &command() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
QVariant command_;
|
||||||
|
};
|
||||||
|
|
||||||
|
CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const EchoCommand &command);
|
||||||
|
CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, EchoCommand &command);
|
||||||
|
CMBIPC_EXPORT bool operator == (const EchoCommand &first, const EchoCommand &second);
|
||||||
|
CMBIPC_EXPORT bool operator < (const EchoCommand &first, const EchoCommand &second);
|
||||||
|
|
||||||
|
CMBIPC_EXPORT QDebug operator <<(QDebug debug, const EchoCommand &command);
|
||||||
|
void PrintTo(const EchoCommand &command, ::std::ostream* os);
|
||||||
|
|
||||||
|
} // namespace CodeModelBackEnd
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(CodeModelBackEnd::EchoCommand)
|
||||||
|
|
||||||
|
#endif // CODEMODELBACKEND_ECHOCOMMAND_H
|
71
src/libs/codemodelbackendipc/cmbendcommand.cpp
Normal file
71
src/libs/codemodelbackendipc/cmbendcommand.cpp
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "cmbendcommand.h"
|
||||||
|
|
||||||
|
#include <QtDebug>
|
||||||
|
|
||||||
|
#include <QDataStream>
|
||||||
|
|
||||||
|
#include <ostream>
|
||||||
|
|
||||||
|
namespace CodeModelBackEnd {
|
||||||
|
|
||||||
|
QDataStream &operator<<(QDataStream &out, const EndCommand &/*command*/)
|
||||||
|
{
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDataStream &operator>>(QDataStream &in, EndCommand &/*command*/)
|
||||||
|
{
|
||||||
|
return in;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator == (const EndCommand &/*first*/, const EndCommand &/*second*/)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator < (const EndCommand &/*first*/, const EndCommand &/*second*/)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDebug operator <<(QDebug debug, const EndCommand &/*command*/)
|
||||||
|
{
|
||||||
|
return debug.nospace() << "EndCommand()";
|
||||||
|
}
|
||||||
|
|
||||||
|
void PrintTo(const EndCommand &/*command*/, ::std::ostream* os)
|
||||||
|
{
|
||||||
|
*os << "EndCommand()";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
55
src/libs/codemodelbackendipc/cmbendcommand.h
Normal file
55
src/libs/codemodelbackendipc/cmbendcommand.h
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef CMBENDCOMMAND_H
|
||||||
|
#define CMBENDCOMMAND_H
|
||||||
|
|
||||||
|
#include "codemodelbackendipc_global.h"
|
||||||
|
|
||||||
|
#include <QMetaType>
|
||||||
|
|
||||||
|
namespace CodeModelBackEnd {
|
||||||
|
|
||||||
|
class CMBIPC_EXPORT EndCommand
|
||||||
|
{
|
||||||
|
};
|
||||||
|
|
||||||
|
CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const EndCommand &command);
|
||||||
|
CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, EndCommand &command);
|
||||||
|
CMBIPC_EXPORT bool operator == (const EndCommand &first, const EndCommand &second);
|
||||||
|
CMBIPC_EXPORT bool operator < (const EndCommand &first, const EndCommand &second);
|
||||||
|
|
||||||
|
CMBIPC_EXPORT QDebug operator <<(QDebug debug, const EndCommand &command);
|
||||||
|
void PrintTo(const EndCommand &command, ::std::ostream* os);
|
||||||
|
}
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(CodeModelBackEnd::EndCommand)
|
||||||
|
|
||||||
|
#endif // CMBENDCOMMAND_H
|
@@ -0,0 +1,98 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "cmbregisterprojectsforcodecompletioncommand.h"
|
||||||
|
|
||||||
|
#include <QtDebug>
|
||||||
|
|
||||||
|
#include <QDataStream>
|
||||||
|
|
||||||
|
#include <ostream>
|
||||||
|
|
||||||
|
namespace CodeModelBackEnd {
|
||||||
|
|
||||||
|
RegisterProjectPartsForCodeCompletionCommand::RegisterProjectPartsForCodeCompletionCommand(const QVector<ProjectPartContainer> &projectContainers)
|
||||||
|
:projectContainers_(projectContainers)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
const QVector<ProjectPartContainer> &RegisterProjectPartsForCodeCompletionCommand::projectContainers() const
|
||||||
|
{
|
||||||
|
return projectContainers_;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDataStream &operator<<(QDataStream &out, const RegisterProjectPartsForCodeCompletionCommand &command)
|
||||||
|
{
|
||||||
|
out << command.projectContainers_;
|
||||||
|
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDataStream &operator>>(QDataStream &in, RegisterProjectPartsForCodeCompletionCommand &command)
|
||||||
|
{
|
||||||
|
in >> command.projectContainers_;
|
||||||
|
|
||||||
|
return in;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator == (const RegisterProjectPartsForCodeCompletionCommand &first, const RegisterProjectPartsForCodeCompletionCommand &second)
|
||||||
|
{
|
||||||
|
return first.projectContainers_ == second.projectContainers_;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator < (const RegisterProjectPartsForCodeCompletionCommand &first, const RegisterProjectPartsForCodeCompletionCommand &second)
|
||||||
|
{
|
||||||
|
return first.projectContainers_ < second.projectContainers_;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDebug operator <<(QDebug debug, const RegisterProjectPartsForCodeCompletionCommand &command)
|
||||||
|
{
|
||||||
|
debug.nospace() << "RegisterProjectPartsForCodeCompletion(";
|
||||||
|
|
||||||
|
for (const ProjectPartContainer &projectContainer : command.projectContainers())
|
||||||
|
debug.nospace() << projectContainer<< ", ";
|
||||||
|
|
||||||
|
debug.nospace() << ")";
|
||||||
|
|
||||||
|
return debug;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PrintTo(const RegisterProjectPartsForCodeCompletionCommand &command, ::std::ostream* os)
|
||||||
|
{
|
||||||
|
*os << "RegisterProjectPartsForCodeCompletion(";
|
||||||
|
|
||||||
|
for (const ProjectPartContainer &projectContainer : command.projectContainers())
|
||||||
|
PrintTo(projectContainer, os);
|
||||||
|
|
||||||
|
*os << ")";
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace CodeModelBackEnd
|
||||||
|
|
@@ -0,0 +1,69 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef CODEMODELBACKEND_REGISTERPROJECTSFORCODECOMPLETIONCOMAND_H
|
||||||
|
#define CODEMODELBACKEND_REGISTERPROJECTSFORCODECOMPLETIONCOMAND_H
|
||||||
|
|
||||||
|
#include <QMetaType>
|
||||||
|
#include <QVector>
|
||||||
|
|
||||||
|
#include "projectpartcontainer.h"
|
||||||
|
|
||||||
|
namespace CodeModelBackEnd {
|
||||||
|
|
||||||
|
class CMBIPC_EXPORT RegisterProjectPartsForCodeCompletionCommand
|
||||||
|
{
|
||||||
|
friend CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const RegisterProjectPartsForCodeCompletionCommand &command);
|
||||||
|
friend CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, RegisterProjectPartsForCodeCompletionCommand &command);
|
||||||
|
friend CMBIPC_EXPORT bool operator == (const RegisterProjectPartsForCodeCompletionCommand &first, const RegisterProjectPartsForCodeCompletionCommand &second);
|
||||||
|
friend CMBIPC_EXPORT bool operator < (const RegisterProjectPartsForCodeCompletionCommand &first, const RegisterProjectPartsForCodeCompletionCommand &second);
|
||||||
|
friend void PrintTo(const RegisterProjectPartsForCodeCompletionCommand &command, ::std::ostream* os);
|
||||||
|
public:
|
||||||
|
RegisterProjectPartsForCodeCompletionCommand() = default;
|
||||||
|
RegisterProjectPartsForCodeCompletionCommand(const QVector<ProjectPartContainer> &projectContainers);
|
||||||
|
|
||||||
|
const QVector<ProjectPartContainer> &projectContainers() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
QVector<ProjectPartContainer> projectContainers_;
|
||||||
|
};
|
||||||
|
|
||||||
|
CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const RegisterProjectPartsForCodeCompletionCommand &command);
|
||||||
|
CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, RegisterProjectPartsForCodeCompletionCommand &command);
|
||||||
|
CMBIPC_EXPORT bool operator == (const RegisterProjectPartsForCodeCompletionCommand &first, const RegisterProjectPartsForCodeCompletionCommand &second);
|
||||||
|
CMBIPC_EXPORT bool operator < (const RegisterProjectPartsForCodeCompletionCommand &first, const RegisterProjectPartsForCodeCompletionCommand &second);
|
||||||
|
|
||||||
|
CMBIPC_EXPORT QDebug operator <<(QDebug debug, const RegisterProjectPartsForCodeCompletionCommand &command);
|
||||||
|
void PrintTo(const RegisterProjectPartsForCodeCompletionCommand &command, ::std::ostream* os);
|
||||||
|
} // namespace CodeModelBackEnd
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(CodeModelBackEnd::RegisterProjectPartsForCodeCompletionCommand)
|
||||||
|
|
||||||
|
#endif // CODEMODELBACKEND_REGISTERPROJECTSFORCODECOMPLETIONCOMAND_H
|
@@ -0,0 +1,98 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "cmbregistertranslationunitsforcodecompletioncommand.h"
|
||||||
|
|
||||||
|
#include <QtDebug>
|
||||||
|
|
||||||
|
#include <QDataStream>
|
||||||
|
|
||||||
|
#include <ostream>
|
||||||
|
|
||||||
|
namespace CodeModelBackEnd {
|
||||||
|
|
||||||
|
RegisterTranslationUnitForCodeCompletionCommand::RegisterTranslationUnitForCodeCompletionCommand(const QVector<FileContainer> &fileContainers)
|
||||||
|
: fileContainers_(fileContainers)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
const QVector<FileContainer> &RegisterTranslationUnitForCodeCompletionCommand::fileContainers() const
|
||||||
|
{
|
||||||
|
return fileContainers_;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDataStream &operator<<(QDataStream &out, const RegisterTranslationUnitForCodeCompletionCommand &command)
|
||||||
|
{
|
||||||
|
out << command.fileContainers_;
|
||||||
|
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDataStream &operator>>(QDataStream &in, RegisterTranslationUnitForCodeCompletionCommand &command)
|
||||||
|
{
|
||||||
|
in >> command.fileContainers_;
|
||||||
|
|
||||||
|
return in;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator == (const RegisterTranslationUnitForCodeCompletionCommand &first, const RegisterTranslationUnitForCodeCompletionCommand &second)
|
||||||
|
{
|
||||||
|
return first.fileContainers_ == second.fileContainers_;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator < (const RegisterTranslationUnitForCodeCompletionCommand &first, const RegisterTranslationUnitForCodeCompletionCommand &second)
|
||||||
|
{
|
||||||
|
return first.fileContainers_ < second.fileContainers_;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDebug operator <<(QDebug debug, const RegisterTranslationUnitForCodeCompletionCommand &command)
|
||||||
|
{
|
||||||
|
debug.nospace() << "RegisterTranslationUnitForCodeCompletionCommand(";
|
||||||
|
|
||||||
|
for (const FileContainer &fileContainer : command.fileContainers())
|
||||||
|
debug.nospace() << fileContainer<< ", ";
|
||||||
|
|
||||||
|
debug.nospace() << ")";
|
||||||
|
|
||||||
|
return debug;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PrintTo(const RegisterTranslationUnitForCodeCompletionCommand &command, ::std::ostream* os)
|
||||||
|
{
|
||||||
|
*os << "RegisterTranslationUnitForCodeCompletionCommand(";
|
||||||
|
|
||||||
|
for (const FileContainer &fileContainer : command.fileContainers())
|
||||||
|
PrintTo(fileContainer, os);
|
||||||
|
|
||||||
|
*os << ")";
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace CodeModelBackEnd
|
||||||
|
|
@@ -0,0 +1,69 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef CODEMODELBACKEND_REGISTERFILEFORCODECOMPLETION_H
|
||||||
|
#define CODEMODELBACKEND_REGISTERFILEFORCODECOMPLETION_H
|
||||||
|
|
||||||
|
#include <qmetatype.h>
|
||||||
|
|
||||||
|
#include <QVector>
|
||||||
|
#include "filecontainer.h"
|
||||||
|
|
||||||
|
namespace CodeModelBackEnd {
|
||||||
|
|
||||||
|
class CMBIPC_EXPORT RegisterTranslationUnitForCodeCompletionCommand
|
||||||
|
{
|
||||||
|
friend CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const RegisterTranslationUnitForCodeCompletionCommand &command);
|
||||||
|
friend CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, RegisterTranslationUnitForCodeCompletionCommand &command);
|
||||||
|
friend CMBIPC_EXPORT bool operator == (const RegisterTranslationUnitForCodeCompletionCommand &first, const RegisterTranslationUnitForCodeCompletionCommand &second);
|
||||||
|
friend CMBIPC_EXPORT bool operator < (const RegisterTranslationUnitForCodeCompletionCommand &first, const RegisterTranslationUnitForCodeCompletionCommand &second);
|
||||||
|
friend void PrintTo(const RegisterTranslationUnitForCodeCompletionCommand &command, ::std::ostream* os);
|
||||||
|
public:
|
||||||
|
RegisterTranslationUnitForCodeCompletionCommand() = default;
|
||||||
|
RegisterTranslationUnitForCodeCompletionCommand(const QVector<FileContainer> &fileContainers);
|
||||||
|
|
||||||
|
const QVector<FileContainer> &fileContainers() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
QVector<FileContainer> fileContainers_;
|
||||||
|
};
|
||||||
|
|
||||||
|
CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const RegisterTranslationUnitForCodeCompletionCommand &command);
|
||||||
|
CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, RegisterTranslationUnitForCodeCompletionCommand &command);
|
||||||
|
CMBIPC_EXPORT bool operator == (const RegisterTranslationUnitForCodeCompletionCommand &first, const RegisterTranslationUnitForCodeCompletionCommand &second);
|
||||||
|
CMBIPC_EXPORT bool operator < (const RegisterTranslationUnitForCodeCompletionCommand &first, const RegisterTranslationUnitForCodeCompletionCommand &second);
|
||||||
|
|
||||||
|
CMBIPC_EXPORT QDebug operator <<(QDebug debug, const RegisterTranslationUnitForCodeCompletionCommand &command);
|
||||||
|
void PrintTo(const RegisterTranslationUnitForCodeCompletionCommand &command, ::std::ostream* os);
|
||||||
|
} // namespace CodeModelBackEnd
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(CodeModelBackEnd::RegisterTranslationUnitForCodeCompletionCommand)
|
||||||
|
|
||||||
|
#endif // CODEMODELBACKEND_REGISTERFILEFORCODECOMPLITION_H
|
@@ -0,0 +1,99 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "cmbunregisterprojectsforcodecompletioncommand.h"
|
||||||
|
|
||||||
|
#include <QtDebug>
|
||||||
|
|
||||||
|
#include <QDataStream>
|
||||||
|
|
||||||
|
#include <ostream>
|
||||||
|
|
||||||
|
namespace CodeModelBackEnd {
|
||||||
|
|
||||||
|
|
||||||
|
UnregisterProjectPartsForCodeCompletionCommand::UnregisterProjectPartsForCodeCompletionCommand(const Utf8StringVector &filePaths)
|
||||||
|
: filePaths_(filePaths)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
const Utf8StringVector &UnregisterProjectPartsForCodeCompletionCommand::filePaths() const
|
||||||
|
{
|
||||||
|
return filePaths_;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDataStream &operator<<(QDataStream &out, const UnregisterProjectPartsForCodeCompletionCommand &command)
|
||||||
|
{
|
||||||
|
out << command.filePaths_;
|
||||||
|
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDataStream &operator>>(QDataStream &in, UnregisterProjectPartsForCodeCompletionCommand &command)
|
||||||
|
{
|
||||||
|
in >> command.filePaths_;
|
||||||
|
|
||||||
|
return in;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator == (const UnregisterProjectPartsForCodeCompletionCommand &first, const UnregisterProjectPartsForCodeCompletionCommand &second)
|
||||||
|
{
|
||||||
|
return first.filePaths_ == second.filePaths_;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator < (const UnregisterProjectPartsForCodeCompletionCommand &first, const UnregisterProjectPartsForCodeCompletionCommand &second)
|
||||||
|
{
|
||||||
|
return first.filePaths_ < second.filePaths_;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDebug operator <<(QDebug debug, const UnregisterProjectPartsForCodeCompletionCommand &command)
|
||||||
|
{
|
||||||
|
debug.nospace() << "UnregisterProjectPartsForCodeCompletionCommand(";
|
||||||
|
|
||||||
|
for (const Utf8String &fileNames_ : command.filePaths())
|
||||||
|
debug.nospace() << fileNames_ << ", ";
|
||||||
|
|
||||||
|
debug.nospace() << ")";
|
||||||
|
|
||||||
|
return debug;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PrintTo(const UnregisterProjectPartsForCodeCompletionCommand &command, ::std::ostream* os)
|
||||||
|
{
|
||||||
|
*os << "UnregisterProjectPartsForCodeCompletionCommand(";
|
||||||
|
|
||||||
|
for (const Utf8String &fileNames_ : command.filePaths())
|
||||||
|
*os << fileNames_.constData() << ", ";
|
||||||
|
|
||||||
|
*os << ")";
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace CodeModelBackEnd
|
||||||
|
|
@@ -0,0 +1,71 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef CODEMODELBACKEND_UNREGISTERPROJECTSFORCODECOMPLETION_H
|
||||||
|
#define CODEMODELBACKEND_UNREGISTERPROJECTSFORCODECOMPLETION_H
|
||||||
|
|
||||||
|
#include "codemodelbackendipc_global.h"
|
||||||
|
|
||||||
|
#include <utf8stringvector.h>
|
||||||
|
|
||||||
|
#include <QMetaType>
|
||||||
|
|
||||||
|
namespace CodeModelBackEnd {
|
||||||
|
|
||||||
|
class CMBIPC_EXPORT UnregisterProjectPartsForCodeCompletionCommand
|
||||||
|
{
|
||||||
|
friend CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const UnregisterProjectPartsForCodeCompletionCommand &command);
|
||||||
|
friend CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, UnregisterProjectPartsForCodeCompletionCommand &command);
|
||||||
|
friend CMBIPC_EXPORT bool operator == (const UnregisterProjectPartsForCodeCompletionCommand &first, const UnregisterProjectPartsForCodeCompletionCommand &second);
|
||||||
|
friend CMBIPC_EXPORT bool operator < (const UnregisterProjectPartsForCodeCompletionCommand &first, const UnregisterProjectPartsForCodeCompletionCommand &second);
|
||||||
|
friend void PrintTo(const UnregisterProjectPartsForCodeCompletionCommand &command, ::std::ostream* os);
|
||||||
|
|
||||||
|
public:
|
||||||
|
UnregisterProjectPartsForCodeCompletionCommand() = default;
|
||||||
|
UnregisterProjectPartsForCodeCompletionCommand(const Utf8StringVector &filePaths);
|
||||||
|
|
||||||
|
const Utf8StringVector &filePaths() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
Utf8StringVector filePaths_;
|
||||||
|
};
|
||||||
|
|
||||||
|
CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const UnregisterProjectPartsForCodeCompletionCommand &command);
|
||||||
|
CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, UnregisterProjectPartsForCodeCompletionCommand &command);
|
||||||
|
CMBIPC_EXPORT bool operator == (const UnregisterProjectPartsForCodeCompletionCommand &first, const UnregisterProjectPartsForCodeCompletionCommand &second);
|
||||||
|
CMBIPC_EXPORT bool operator < (const UnregisterProjectPartsForCodeCompletionCommand &first, const UnregisterProjectPartsForCodeCompletionCommand &second);
|
||||||
|
|
||||||
|
CMBIPC_EXPORT QDebug operator <<(QDebug debug, const UnregisterProjectPartsForCodeCompletionCommand &command);
|
||||||
|
void PrintTo(const UnregisterProjectPartsForCodeCompletionCommand &command, ::std::ostream* os);
|
||||||
|
} // namespace CodeModelBackEnd
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(CodeModelBackEnd::UnregisterProjectPartsForCodeCompletionCommand)
|
||||||
|
|
||||||
|
#endif // CODEMODELBACKEND_UNREGISTERPROJECTSFORCODECOMPLETION_H
|
@@ -0,0 +1,104 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "cmbunregistertranslationunitsforcodecompletioncommand.h"
|
||||||
|
|
||||||
|
#include <QtDebug>
|
||||||
|
|
||||||
|
#ifdef CODEMODELBACKEND_TESTS
|
||||||
|
#include <gtest/gtest-printers.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <QDataStream>
|
||||||
|
|
||||||
|
namespace CodeModelBackEnd {
|
||||||
|
|
||||||
|
|
||||||
|
UnregisterTranslationUnitsForCodeCompletionCommand::UnregisterTranslationUnitsForCodeCompletionCommand(const QVector<FileContainer> &fileContainers)
|
||||||
|
: fileContainers_(fileContainers)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
const QVector<FileContainer> &UnregisterTranslationUnitsForCodeCompletionCommand::fileContainers() const
|
||||||
|
{
|
||||||
|
return fileContainers_;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDataStream &operator<<(QDataStream &out, const UnregisterTranslationUnitsForCodeCompletionCommand &command)
|
||||||
|
{
|
||||||
|
out << command.fileContainers_;
|
||||||
|
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDataStream &operator>>(QDataStream &in, UnregisterTranslationUnitsForCodeCompletionCommand &command)
|
||||||
|
{
|
||||||
|
in >> command.fileContainers_;
|
||||||
|
|
||||||
|
return in;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator == (const UnregisterTranslationUnitsForCodeCompletionCommand &first, const UnregisterTranslationUnitsForCodeCompletionCommand &second)
|
||||||
|
{
|
||||||
|
return first.fileContainers_ == second.fileContainers_;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator < (const UnregisterTranslationUnitsForCodeCompletionCommand &first, const UnregisterTranslationUnitsForCodeCompletionCommand &second)
|
||||||
|
{
|
||||||
|
return first.fileContainers_ < second.fileContainers_;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDebug operator <<(QDebug debug, const UnregisterTranslationUnitsForCodeCompletionCommand &command)
|
||||||
|
{
|
||||||
|
debug.nospace() << "UnregisterTranslationUnitsForCodeCompletionCommand(";
|
||||||
|
|
||||||
|
for (const FileContainer &fileContainer : command.fileContainers())
|
||||||
|
debug.nospace() << fileContainer << ", ";
|
||||||
|
|
||||||
|
debug.nospace() << ")";
|
||||||
|
|
||||||
|
return debug;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef CODEMODELBACKEND_TESTS
|
||||||
|
void PrintTo(const UnregisterTranslationUnitsForCodeCompletionCommand &command, ::std::ostream* os)
|
||||||
|
{
|
||||||
|
*os << "UnregisterTranslationUnitsForCodeCompletionCommand(";
|
||||||
|
|
||||||
|
for (const FileContainer &fileContainer : command.fileContainers())
|
||||||
|
*os << ::testing::PrintToString(fileContainer) << ", ";
|
||||||
|
|
||||||
|
*os << ")";
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace CodeModelBackEnd
|
||||||
|
|
@@ -0,0 +1,74 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef CODEMODELBACKEND_UNRegisterTranslationUnitForCodeCompletionCommand_H
|
||||||
|
#define CODEMODELBACKEND_UNRegisterTranslationUnitForCodeCompletionCommand_H
|
||||||
|
|
||||||
|
#include "codemodelbackendipc_global.h"
|
||||||
|
|
||||||
|
#include "filecontainer.h"
|
||||||
|
|
||||||
|
#include <QVector>
|
||||||
|
#include <QMetaType>
|
||||||
|
|
||||||
|
namespace CodeModelBackEnd {
|
||||||
|
|
||||||
|
class CMBIPC_EXPORT UnregisterTranslationUnitsForCodeCompletionCommand
|
||||||
|
{
|
||||||
|
friend CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const UnregisterTranslationUnitsForCodeCompletionCommand &command);
|
||||||
|
friend CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, UnregisterTranslationUnitsForCodeCompletionCommand &command);
|
||||||
|
friend CMBIPC_EXPORT bool operator == (const UnregisterTranslationUnitsForCodeCompletionCommand &first, const UnregisterTranslationUnitsForCodeCompletionCommand &second);
|
||||||
|
friend CMBIPC_EXPORT bool operator < (const UnregisterTranslationUnitsForCodeCompletionCommand &first, const UnregisterTranslationUnitsForCodeCompletionCommand &second);
|
||||||
|
friend void PrintTo(const UnregisterTranslationUnitsForCodeCompletionCommand &command, ::std::ostream* os);
|
||||||
|
|
||||||
|
public:
|
||||||
|
UnregisterTranslationUnitsForCodeCompletionCommand() = default;
|
||||||
|
UnregisterTranslationUnitsForCodeCompletionCommand(const QVector<FileContainer> &fileContainers);
|
||||||
|
|
||||||
|
const QVector<FileContainer> &fileContainers() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
QVector<FileContainer> fileContainers_;
|
||||||
|
};
|
||||||
|
|
||||||
|
CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const UnregisterTranslationUnitsForCodeCompletionCommand &command);
|
||||||
|
CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, UnregisterTranslationUnitsForCodeCompletionCommand &command);
|
||||||
|
CMBIPC_EXPORT bool operator == (const UnregisterTranslationUnitsForCodeCompletionCommand &first, const UnregisterTranslationUnitsForCodeCompletionCommand &second);
|
||||||
|
CMBIPC_EXPORT bool operator < (const UnregisterTranslationUnitsForCodeCompletionCommand &first, const UnregisterTranslationUnitsForCodeCompletionCommand &second);
|
||||||
|
|
||||||
|
CMBIPC_EXPORT QDebug operator <<(QDebug debug, const UnregisterTranslationUnitsForCodeCompletionCommand &command);
|
||||||
|
#ifdef CODEMODELBACKEND_TESTS
|
||||||
|
void PrintTo(const UnregisterTranslationUnitsForCodeCompletionCommand &command, ::std::ostream* os);
|
||||||
|
#endif
|
||||||
|
} // namespace CodeModelBackEnd
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(CodeModelBackEnd::UnregisterTranslationUnitsForCodeCompletionCommand)
|
||||||
|
|
||||||
|
#endif // CODEMODELBACKEND_UNRegisterTranslationUnitForCodeCompletionCommand_H
|
255
src/libs/codemodelbackendipc/codecompletion.cpp
Normal file
255
src/libs/codemodelbackendipc/codecompletion.cpp
Normal file
@@ -0,0 +1,255 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "codecompletion.h"
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
|
#include <QDataStream>
|
||||||
|
|
||||||
|
#include <ostream>
|
||||||
|
|
||||||
|
namespace CodeModelBackEnd {
|
||||||
|
|
||||||
|
CodeCompletion::CodeCompletion(const Utf8String &text,
|
||||||
|
const Utf8String &hint,
|
||||||
|
const Utf8String &snippet,
|
||||||
|
quint32 priority,
|
||||||
|
Kind completionKind,
|
||||||
|
Availability availability,
|
||||||
|
bool hasParameters)
|
||||||
|
: text_(text),
|
||||||
|
hint_(hint),
|
||||||
|
snippet_(snippet),
|
||||||
|
priority_(priority),
|
||||||
|
completionKind_(completionKind),
|
||||||
|
availability_(availability),
|
||||||
|
hasParameters_(hasParameters)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void CodeCompletion::setText(const Utf8String &text)
|
||||||
|
{
|
||||||
|
text_ = text;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Utf8String &CodeCompletion::text() const
|
||||||
|
{
|
||||||
|
return text_;
|
||||||
|
}
|
||||||
|
const Utf8String &CodeCompletion::hint() const
|
||||||
|
{
|
||||||
|
return hint_;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Utf8String &CodeCompletion::snippet() const
|
||||||
|
{
|
||||||
|
return snippet_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CodeCompletion::setCompletionKind(CodeCompletion::Kind completionKind)
|
||||||
|
{
|
||||||
|
completionKind_ = completionKind;
|
||||||
|
}
|
||||||
|
|
||||||
|
CodeCompletion::Kind CodeCompletion::completionKind() const
|
||||||
|
{
|
||||||
|
return completionKind_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CodeCompletion::setChunks(const QVector<CodeCompletionChunk> &chunks)
|
||||||
|
{
|
||||||
|
chunks_ = chunks;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QVector<CodeCompletionChunk> &CodeCompletion::chunks() const
|
||||||
|
{
|
||||||
|
return chunks_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CodeCompletion::setAvailability(CodeCompletion::Availability availability)
|
||||||
|
{
|
||||||
|
availability_ = availability;
|
||||||
|
}
|
||||||
|
|
||||||
|
CodeCompletion::Availability CodeCompletion::availability() const
|
||||||
|
{
|
||||||
|
return availability_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CodeCompletion::setHasParameters(bool hasParameters)
|
||||||
|
{
|
||||||
|
hasParameters_ = hasParameters;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CodeCompletion::hasParameters() const
|
||||||
|
{
|
||||||
|
return hasParameters_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CodeCompletion::setPriority(quint32 priority)
|
||||||
|
{
|
||||||
|
priority_ = priority;
|
||||||
|
}
|
||||||
|
|
||||||
|
quint32 CodeCompletion::priority() const
|
||||||
|
{
|
||||||
|
return priority_;
|
||||||
|
}
|
||||||
|
|
||||||
|
quint32 &CodeCompletion::completionKindAsInt()
|
||||||
|
{
|
||||||
|
return reinterpret_cast<quint32&>(completionKind_);
|
||||||
|
}
|
||||||
|
|
||||||
|
quint32 &CodeCompletion::availabilityAsInt()
|
||||||
|
{
|
||||||
|
return reinterpret_cast<quint32&>(availability_);
|
||||||
|
}
|
||||||
|
|
||||||
|
QDataStream &operator<<(QDataStream &out, const CodeCompletion &command)
|
||||||
|
{
|
||||||
|
out << command.text_;
|
||||||
|
out << command.hint_;
|
||||||
|
out << command.snippet_;
|
||||||
|
out << command.chunks_;
|
||||||
|
out << command.priority_;
|
||||||
|
out << command.completionKind_;
|
||||||
|
out << command.availability_;
|
||||||
|
out << command.hasParameters_;
|
||||||
|
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDataStream &operator>>(QDataStream &in, CodeCompletion &command)
|
||||||
|
{
|
||||||
|
in >> command.text_;
|
||||||
|
in >> command.hint_;
|
||||||
|
in >> command.snippet_;
|
||||||
|
in >> command.chunks_;
|
||||||
|
in >> command.priority_;
|
||||||
|
in >> command.completionKindAsInt();
|
||||||
|
in >> command.availabilityAsInt();
|
||||||
|
in >> command.hasParameters_;
|
||||||
|
|
||||||
|
return in;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator == (const CodeCompletion &first, const CodeCompletion &second)
|
||||||
|
{
|
||||||
|
return first.text_ == second.text_
|
||||||
|
&& first.completionKind_ == second.completionKind_;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator < (const CodeCompletion &first, const CodeCompletion &second)
|
||||||
|
{
|
||||||
|
return first.text_ < second.text_;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const char *completionKindToString(CodeCompletion::Kind kind)
|
||||||
|
{
|
||||||
|
switch (kind) {
|
||||||
|
case CodeCompletion::Other: return "Other";
|
||||||
|
case CodeCompletion::FunctionCompletionKind: return "Function";
|
||||||
|
case CodeCompletion::TemplateFunctionCompletionKind: return "TemplateFunction";
|
||||||
|
case CodeCompletion::ConstructorCompletionKind: return "Constructor";
|
||||||
|
case CodeCompletion::DestructorCompletionKind: return "Destructor";
|
||||||
|
case CodeCompletion::VariableCompletionKind: return "Variable";
|
||||||
|
case CodeCompletion::ClassCompletionKind: return "Class";
|
||||||
|
case CodeCompletion::TemplateClassCompletionKind: return "TemplateClass";
|
||||||
|
case CodeCompletion::EnumerationCompletionKind: return "Enumeration";
|
||||||
|
case CodeCompletion::EnumeratorCompletionKind: return "Enumerator";
|
||||||
|
case CodeCompletion::NamespaceCompletionKind: return "Namespace";
|
||||||
|
case CodeCompletion::PreProcessorCompletionKind: return "PreProcessor";
|
||||||
|
case CodeCompletion::SignalCompletionKind: return "Signal";
|
||||||
|
case CodeCompletion::SlotCompletionKind: return "Slot";
|
||||||
|
case CodeCompletion::ObjCMessageCompletionKind: return "ObjCMessage";
|
||||||
|
case CodeCompletion::KeywordCompletionKind: return "Keyword";
|
||||||
|
case CodeCompletion::ClangSnippetKind: return "ClangSnippet";
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const char *availabilityToString(CodeCompletion::Availability availability)
|
||||||
|
{
|
||||||
|
switch (availability) {
|
||||||
|
case CodeCompletion::Available: return "Available";
|
||||||
|
case CodeCompletion::Deprecated: return "Deprecated";
|
||||||
|
case CodeCompletion::NotAvailable: return "NotAvailable";
|
||||||
|
case CodeCompletion::NotAccessible: return "NotAccessible";
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDebug operator <<(QDebug debug, const CodeCompletion &command)
|
||||||
|
{
|
||||||
|
debug.nospace() << "CodeCompletion(";
|
||||||
|
|
||||||
|
debug.nospace() << command.text_ << ", ";
|
||||||
|
debug.nospace() << command.hint_ << ", ";
|
||||||
|
debug.nospace() << command.snippet_ << ", ";
|
||||||
|
debug.nospace() << command.priority_ << ", ";
|
||||||
|
debug.nospace() << completionKindToString(command.completionKind_) << ", ";
|
||||||
|
debug.nospace() << availabilityToString(command.availability_) << ", ";
|
||||||
|
debug.nospace() << command.hasParameters_;
|
||||||
|
|
||||||
|
debug.nospace() << ")";
|
||||||
|
|
||||||
|
return debug;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PrintTo(const CodeCompletion &command, ::std::ostream* os)
|
||||||
|
{
|
||||||
|
*os << "CodeCompletion(";
|
||||||
|
|
||||||
|
*os << command.text_.constData() << ", ";
|
||||||
|
*os << command.hint_.constData() << ", ";
|
||||||
|
*os << command.snippet_.constData() << ", ";
|
||||||
|
*os << command.priority_ << ", ";
|
||||||
|
*os << completionKindToString(command.completionKind_) << ", ";
|
||||||
|
*os << availabilityToString(command.availability_) << ", ";
|
||||||
|
*os << command.hasParameters_;
|
||||||
|
|
||||||
|
*os << ")";
|
||||||
|
}
|
||||||
|
|
||||||
|
void PrintTo(CodeCompletion::Kind kind, ::std::ostream *os)
|
||||||
|
{
|
||||||
|
*os << completionKindToString(kind);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PrintTo(CodeCompletion::Availability availability, std::ostream *os)
|
||||||
|
{
|
||||||
|
*os << availabilityToString(availability);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace CodeModelBackEnd
|
||||||
|
|
141
src/libs/codemodelbackendipc/codecompletion.h
Normal file
141
src/libs/codemodelbackendipc/codecompletion.h
Normal file
@@ -0,0 +1,141 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef CODEMODELBACKEND_CODECOMPLETION_H
|
||||||
|
#define CODEMODELBACKEND_CODECOMPLETION_H
|
||||||
|
|
||||||
|
#include <QMetaType>
|
||||||
|
#include <utf8string.h>
|
||||||
|
|
||||||
|
#include "codecompletionchunk.h"
|
||||||
|
|
||||||
|
#include "codemodelbackendipc_global.h"
|
||||||
|
|
||||||
|
namespace CodeModelBackEnd {
|
||||||
|
|
||||||
|
class CMBIPC_EXPORT CodeCompletion
|
||||||
|
{
|
||||||
|
friend CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const CodeCompletion &command);
|
||||||
|
friend CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, CodeCompletion &command);
|
||||||
|
friend CMBIPC_EXPORT bool operator == (const CodeCompletion &first, const CodeCompletion &second);
|
||||||
|
friend CMBIPC_EXPORT bool operator < (const CodeCompletion &first, const CodeCompletion &second);
|
||||||
|
friend CMBIPC_EXPORT QDebug operator <<(QDebug debug, const CodeCompletion &command);
|
||||||
|
friend void PrintTo(const CodeCompletion &command, ::std::ostream* os);
|
||||||
|
|
||||||
|
public:
|
||||||
|
enum Kind : quint32 {
|
||||||
|
Other = 0,
|
||||||
|
FunctionCompletionKind,
|
||||||
|
TemplateFunctionCompletionKind,
|
||||||
|
ConstructorCompletionKind,
|
||||||
|
DestructorCompletionKind,
|
||||||
|
VariableCompletionKind,
|
||||||
|
ClassCompletionKind,
|
||||||
|
TemplateClassCompletionKind,
|
||||||
|
EnumerationCompletionKind,
|
||||||
|
EnumeratorCompletionKind,
|
||||||
|
NamespaceCompletionKind,
|
||||||
|
PreProcessorCompletionKind,
|
||||||
|
SignalCompletionKind,
|
||||||
|
SlotCompletionKind,
|
||||||
|
ObjCMessageCompletionKind,
|
||||||
|
KeywordCompletionKind,
|
||||||
|
ClangSnippetKind
|
||||||
|
};
|
||||||
|
|
||||||
|
enum Availability : quint32 {
|
||||||
|
Available,
|
||||||
|
Deprecated,
|
||||||
|
NotAvailable,
|
||||||
|
NotAccessible
|
||||||
|
};
|
||||||
|
|
||||||
|
public:
|
||||||
|
CodeCompletion() = default;
|
||||||
|
CodeCompletion(const Utf8String &text,
|
||||||
|
const Utf8String &hint = Utf8String(),
|
||||||
|
const Utf8String &snippet = Utf8String(),
|
||||||
|
quint32 priority = 0,
|
||||||
|
Kind completionKind = Other,
|
||||||
|
Availability availability = Available,
|
||||||
|
bool hasParameters = false);
|
||||||
|
|
||||||
|
void setText(const Utf8String &text);
|
||||||
|
const Utf8String &text() const;
|
||||||
|
|
||||||
|
const Utf8String &hint() const;
|
||||||
|
const Utf8String &snippet() const;
|
||||||
|
|
||||||
|
void setCompletionKind(Kind completionKind);
|
||||||
|
Kind completionKind() const;
|
||||||
|
|
||||||
|
void setChunks(const QVector<CodeCompletionChunk> &chunks);
|
||||||
|
const QVector<CodeCompletionChunk> &chunks() const;
|
||||||
|
|
||||||
|
void setAvailability(Availability availability);
|
||||||
|
Availability availability() const;
|
||||||
|
|
||||||
|
void setHasParameters(bool hasParameters);
|
||||||
|
bool hasParameters() const;
|
||||||
|
|
||||||
|
void setPriority(quint32 priority);
|
||||||
|
quint32 priority() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
quint32 &completionKindAsInt();
|
||||||
|
quint32 &availabilityAsInt();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Utf8String text_;
|
||||||
|
Utf8String hint_;
|
||||||
|
Utf8String snippet_;
|
||||||
|
QVector<CodeCompletionChunk> chunks_;
|
||||||
|
quint32 priority_ = 0;
|
||||||
|
Kind completionKind_ = Other;
|
||||||
|
Availability availability_ = NotAvailable;
|
||||||
|
bool hasParameters_ = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const CodeCompletion &command);
|
||||||
|
CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, CodeCompletion &command);
|
||||||
|
CMBIPC_EXPORT bool operator == (const CodeCompletion &first, const CodeCompletion &second);
|
||||||
|
CMBIPC_EXPORT bool operator < (const CodeCompletion &first, const CodeCompletion &second);
|
||||||
|
|
||||||
|
CMBIPC_EXPORT QDebug operator <<(QDebug debug, const CodeCompletion &command);
|
||||||
|
CMBIPC_EXPORT QDebug operator <<(QDebug debug, CodeCompletion::Kind kind);
|
||||||
|
|
||||||
|
void PrintTo(const CodeCompletion &command, ::std::ostream* os);
|
||||||
|
void PrintTo(CodeCompletion::Kind kind, ::std::ostream *os);
|
||||||
|
void PrintTo(CodeCompletion::Availability availability, ::std::ostream *os);
|
||||||
|
} // namespace CodeModelBackEnd
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(CodeModelBackEnd::CodeCompletion)
|
||||||
|
|
||||||
|
#endif // CODEMODELBACKEND_CODECOMPLETION_H
|
178
src/libs/codemodelbackendipc/codecompletionchunk.cpp
Normal file
178
src/libs/codemodelbackendipc/codecompletionchunk.cpp
Normal file
@@ -0,0 +1,178 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "codecompletionchunk.h"
|
||||||
|
|
||||||
|
#include <QDataStream>
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
|
#include <ostream>
|
||||||
|
|
||||||
|
namespace CodeModelBackEnd {
|
||||||
|
|
||||||
|
CodeCompletionChunk::CodeCompletionChunk()
|
||||||
|
: kind_(Invalid)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
CodeCompletionChunk::CodeCompletionChunk(CodeCompletionChunk::Kind kind,
|
||||||
|
const Utf8String &text,
|
||||||
|
const QVector<CodeCompletionChunk> &optionalChunks)
|
||||||
|
: text_(text),
|
||||||
|
optionalChunks_(optionalChunks),
|
||||||
|
kind_(kind)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
CodeCompletionChunk::Kind CodeCompletionChunk::kind() const
|
||||||
|
{
|
||||||
|
return kind_;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Utf8String &CodeCompletionChunk::text() const
|
||||||
|
{
|
||||||
|
return text_;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QVector<CodeCompletionChunk> &CodeCompletionChunk::optionalChunks() const
|
||||||
|
{
|
||||||
|
return optionalChunks_;
|
||||||
|
}
|
||||||
|
|
||||||
|
quint32 &CodeCompletionChunk::kindAsInt()
|
||||||
|
{
|
||||||
|
return reinterpret_cast<quint32&>(kind_);
|
||||||
|
}
|
||||||
|
|
||||||
|
QDataStream &operator <<(QDataStream &out, const CodeCompletionChunk &chunk)
|
||||||
|
{
|
||||||
|
out << chunk.kind_;
|
||||||
|
out << chunk.text_;
|
||||||
|
|
||||||
|
if (chunk.kind() == CodeCompletionChunk::Optional)
|
||||||
|
out << chunk.optionalChunks_;
|
||||||
|
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDataStream &operator >>(QDataStream &in, CodeCompletionChunk &chunk)
|
||||||
|
{
|
||||||
|
in >> chunk.kindAsInt();
|
||||||
|
in >> chunk.text_;
|
||||||
|
|
||||||
|
if (chunk.kind_ == CodeCompletionChunk::Optional)
|
||||||
|
in >> chunk.optionalChunks_;
|
||||||
|
|
||||||
|
return in;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator ==(const CodeCompletionChunk &first, const CodeCompletionChunk &second)
|
||||||
|
{
|
||||||
|
return first.kind() == second.kind()
|
||||||
|
&& first.text() == second.text()
|
||||||
|
&& first.optionalChunks() == second.optionalChunks();
|
||||||
|
}
|
||||||
|
|
||||||
|
static const char *completionChunkKindToString(CodeCompletionChunk::Kind kind)
|
||||||
|
{
|
||||||
|
switch (kind) {
|
||||||
|
case CodeCompletionChunk::Optional: return "Optional";
|
||||||
|
case CodeCompletionChunk::TypedText: return "TypedText";
|
||||||
|
case CodeCompletionChunk::Text: return "Text";
|
||||||
|
case CodeCompletionChunk::Placeholder: return "Placeholder";
|
||||||
|
case CodeCompletionChunk::Informative: return "Informative";
|
||||||
|
case CodeCompletionChunk::CurrentParameter: return "CurrentParameter";
|
||||||
|
case CodeCompletionChunk::LeftParen: return "LeftParen";
|
||||||
|
case CodeCompletionChunk::RightParen: return "RightParen";
|
||||||
|
case CodeCompletionChunk::LeftBracket: return "LeftBracket";
|
||||||
|
case CodeCompletionChunk::RightBracket: return "RightBracket";
|
||||||
|
case CodeCompletionChunk::LeftBrace: return "LeftBrace";
|
||||||
|
case CodeCompletionChunk::RightBrace: return "RightBrace";
|
||||||
|
case CodeCompletionChunk::LeftAngle: return "LeftAngle";
|
||||||
|
case CodeCompletionChunk::RightAngle: return "RightAngle";
|
||||||
|
case CodeCompletionChunk::Comma: return "Comma";
|
||||||
|
case CodeCompletionChunk::ResultType: return "ResultType";
|
||||||
|
case CodeCompletionChunk::Colon: return "Colon";
|
||||||
|
case CodeCompletionChunk::SemiColon: return "SemiColon";
|
||||||
|
case CodeCompletionChunk::Equal: return "Equal";
|
||||||
|
case CodeCompletionChunk::HorizontalSpace: return "HorizontalSpace";
|
||||||
|
case CodeCompletionChunk::VerticalSpace: return "VerticalSpace";
|
||||||
|
case CodeCompletionChunk::Invalid: return "Invalid";
|
||||||
|
}
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDebug operator <<(QDebug debug, const CodeCompletionChunk &chunk)
|
||||||
|
{
|
||||||
|
debug.nospace() << "CodeCompletionChunk(";
|
||||||
|
debug.nospace() << completionChunkKindToString(chunk.kind()) << ", ";
|
||||||
|
debug.nospace() << chunk.text();
|
||||||
|
|
||||||
|
if (chunk.kind() == CodeCompletionChunk::Optional)
|
||||||
|
debug.nospace() << ", " << chunk.optionalChunks();
|
||||||
|
|
||||||
|
debug.nospace() << ")";
|
||||||
|
|
||||||
|
return debug;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PrintTo(const CodeCompletionChunk &chunk, ::std::ostream* os)
|
||||||
|
{
|
||||||
|
*os << "{";
|
||||||
|
*os << completionChunkKindToString(chunk.kind()) << ", ";
|
||||||
|
*os << chunk.text().constData();
|
||||||
|
|
||||||
|
if (chunk.kind() == CodeCompletionChunk::Optional) {
|
||||||
|
const auto optionalChunks = chunk.optionalChunks();
|
||||||
|
*os << ", {";
|
||||||
|
|
||||||
|
for (auto optionalChunkPosition = optionalChunks.cbegin();
|
||||||
|
optionalChunkPosition != optionalChunks.cend();
|
||||||
|
++optionalChunkPosition) {
|
||||||
|
PrintTo(*optionalChunkPosition, os);
|
||||||
|
if (std::next(optionalChunkPosition) != optionalChunks.cend())
|
||||||
|
*os << ", ";
|
||||||
|
}
|
||||||
|
|
||||||
|
*os << "}";
|
||||||
|
}
|
||||||
|
|
||||||
|
*os << "}";
|
||||||
|
}
|
||||||
|
|
||||||
|
void PrintTo(const CodeCompletionChunk::Kind &kind, ::std::ostream* os)
|
||||||
|
{
|
||||||
|
*os << completionChunkKindToString(kind);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace CodeModelBackEnd
|
||||||
|
|
105
src/libs/codemodelbackendipc/codecompletionchunk.h
Normal file
105
src/libs/codemodelbackendipc/codecompletionchunk.h
Normal file
@@ -0,0 +1,105 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef CODEMODELBACKEND_CODECOMPLETIONCHUNK_H
|
||||||
|
#define CODEMODELBACKEND_CODECOMPLETIONCHUNK_H
|
||||||
|
|
||||||
|
#include <utf8string.h>
|
||||||
|
|
||||||
|
#include <QVector>
|
||||||
|
|
||||||
|
#include "codemodelbackendipc_global.h"
|
||||||
|
|
||||||
|
namespace CodeModelBackEnd {
|
||||||
|
|
||||||
|
class CMBIPC_EXPORT CodeCompletionChunk
|
||||||
|
{
|
||||||
|
friend CMBIPC_EXPORT QDataStream &operator <<(QDataStream &out, const CodeCompletionChunk &chunk);
|
||||||
|
friend CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, CodeCompletionChunk &chunk);
|
||||||
|
friend CMBIPC_EXPORT bool operator == (const CodeCompletionChunk &first, const CodeCompletionChunk &second);
|
||||||
|
|
||||||
|
public:
|
||||||
|
enum Kind : quint32 {
|
||||||
|
Optional,
|
||||||
|
TypedText,
|
||||||
|
Text,
|
||||||
|
Placeholder,
|
||||||
|
Informative,
|
||||||
|
CurrentParameter,
|
||||||
|
LeftParen,
|
||||||
|
RightParen,
|
||||||
|
LeftBracket,
|
||||||
|
RightBracket,
|
||||||
|
LeftBrace,
|
||||||
|
RightBrace,
|
||||||
|
LeftAngle,
|
||||||
|
RightAngle,
|
||||||
|
Comma,
|
||||||
|
ResultType,
|
||||||
|
Colon,
|
||||||
|
SemiColon,
|
||||||
|
Equal,
|
||||||
|
HorizontalSpace,
|
||||||
|
VerticalSpace,
|
||||||
|
Invalid = 255};
|
||||||
|
|
||||||
|
CodeCompletionChunk();
|
||||||
|
CodeCompletionChunk(Kind kind,
|
||||||
|
const Utf8String &text,
|
||||||
|
const QVector<CodeCompletionChunk> &optionalChunks = QVector<CodeCompletionChunk>());
|
||||||
|
|
||||||
|
Kind kind() const;
|
||||||
|
const Utf8String &text() const;
|
||||||
|
const QVector<CodeCompletionChunk> &optionalChunks() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
quint32 &kindAsInt();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Utf8String text_;
|
||||||
|
QVector<CodeCompletionChunk> optionalChunks_;
|
||||||
|
Kind kind_ = Invalid;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
CMBIPC_EXPORT QDataStream &operator <<(QDataStream &out, const CodeCompletionChunk &chunk);
|
||||||
|
CMBIPC_EXPORT QDataStream &operator >>(QDataStream &in, CodeCompletionChunk &chunk);
|
||||||
|
CMBIPC_EXPORT bool operator ==(const CodeCompletionChunk &first, const CodeCompletionChunk &second);
|
||||||
|
|
||||||
|
CMBIPC_EXPORT QDebug operator <<(QDebug debug, const CodeCompletionChunk &chunk);
|
||||||
|
|
||||||
|
void PrintTo(const CodeCompletionChunk &chunk, ::std::ostream* os);
|
||||||
|
void PrintTo(const CodeCompletionChunk::Kind &kind, ::std::ostream* os);
|
||||||
|
|
||||||
|
} // namespace CodeModelBackEnd
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(CodeModelBackEnd::CodeCompletionChunk)
|
||||||
|
|
||||||
|
#endif // CODEMODELBACKEND_CODECOMPLETIONCHUNK_H
|
72
src/libs/codemodelbackendipc/codemodelbackendipc-lib.pri
Normal file
72
src/libs/codemodelbackendipc/codemodelbackendipc-lib.pri
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
contains(CONFIG, dll) {
|
||||||
|
DEFINES += CODEMODELBACKENDIPC_BUILD_LIB
|
||||||
|
} else {
|
||||||
|
DEFINES += CODEMODELBACKENDIPC_BUILD_STATIC_LIB
|
||||||
|
}
|
||||||
|
|
||||||
|
QT += network
|
||||||
|
|
||||||
|
DEFINES += CODEMODELBACKENDIPC_LIBRARY
|
||||||
|
|
||||||
|
INCLUDEPATH += $$PWD
|
||||||
|
|
||||||
|
SOURCES += $$PWD/ipcserverinterface.cpp \
|
||||||
|
$$PWD/ipcserverproxy.cpp \
|
||||||
|
$$PWD/ipcserver.cpp \
|
||||||
|
$$PWD/ipcclientinterface.cpp \
|
||||||
|
$$PWD/cmbendcommand.cpp \
|
||||||
|
$$PWD/cmbalivecommand.cpp \
|
||||||
|
$$PWD/ipcclientproxy.cpp \
|
||||||
|
$$PWD/cmbcommands.cpp \
|
||||||
|
$$PWD/writecommandblock.cpp \
|
||||||
|
$$PWD/readcommandblock.cpp \
|
||||||
|
$$PWD/ipcinterface.cpp \
|
||||||
|
$$PWD/connectionserver.cpp \
|
||||||
|
$$PWD/connectionclient.cpp \
|
||||||
|
$$PWD/cmbechocommand.cpp \
|
||||||
|
$$PWD/ipcclientdispatcher.cpp \
|
||||||
|
$$PWD/cmbregistertranslationunitsforcodecompletioncommand.cpp \
|
||||||
|
$$PWD/filecontainer.cpp \
|
||||||
|
$$PWD/cmbunregistertranslationunitsforcodecompletioncommand.cpp \
|
||||||
|
$$PWD/cmbcompletecodecommand.cpp \
|
||||||
|
$$PWD/cmbcodecompletedcommand.cpp \
|
||||||
|
$$PWD/codecompletion.cpp \
|
||||||
|
$$PWD/codemodelbackendipc_global.cpp \
|
||||||
|
$$PWD/cmbregisterprojectsforcodecompletioncommand.cpp \
|
||||||
|
$$PWD/cmbunregisterprojectsforcodecompletioncommand.cpp \
|
||||||
|
$$PWD/translationunitdoesnotexistcommand.cpp \
|
||||||
|
$$PWD/codecompletionchunk.cpp \
|
||||||
|
$$PWD/projectpartcontainer.cpp \
|
||||||
|
$$PWD/projectpartsdonotexistcommand.cpp
|
||||||
|
|
||||||
|
|
||||||
|
HEADERS += $$PWD/codemodelbackendipc_global.h \
|
||||||
|
$$PWD/ipcserverinterface.h \
|
||||||
|
$$PWD/ipcserverproxy.h \
|
||||||
|
$$PWD/ipcserver.h \
|
||||||
|
$$PWD/ipcclientinterface.h \
|
||||||
|
$$PWD/cmbendcommand.h \
|
||||||
|
$$PWD/cmbalivecommand.h \
|
||||||
|
$$PWD/ipcclientproxy.h \
|
||||||
|
$$PWD/cmbcommands.h \
|
||||||
|
$$PWD/writecommandblock.h \
|
||||||
|
$$PWD/readcommandblock.h \
|
||||||
|
$$PWD/ipcinterface.h \
|
||||||
|
$$PWD/connectionserver.h \
|
||||||
|
$$PWD/connectionclient.h \
|
||||||
|
$$PWD/cmbechocommand.h \
|
||||||
|
$$PWD/ipcclientdispatcher.h \
|
||||||
|
$$PWD/cmbregistertranslationunitsforcodecompletioncommand.h \
|
||||||
|
$$PWD/filecontainer.h \
|
||||||
|
$$PWD/cmbunregistertranslationunitsforcodecompletioncommand.h \
|
||||||
|
$$PWD/cmbcompletecodecommand.h \
|
||||||
|
$$PWD/cmbcodecompletedcommand.h \
|
||||||
|
$$PWD/codecompletion.h \
|
||||||
|
$$PWD/cmbregisterprojectsforcodecompletioncommand.h \
|
||||||
|
$$PWD/cmbunregisterprojectsforcodecompletioncommand.h \
|
||||||
|
$$PWD/translationunitdoesnotexistcommand.h \
|
||||||
|
$$PWD/codecompletionchunk.h \
|
||||||
|
$$PWD/projectpartcontainer.h \
|
||||||
|
$$PWD/projectpartsdonotexistcommand.h
|
||||||
|
|
||||||
|
contains(QT_CONFIG, reduce_exports):CONFIG += hide_symbols
|
2
src/libs/codemodelbackendipc/codemodelbackendipc.pro
Normal file
2
src/libs/codemodelbackendipc/codemodelbackendipc.pro
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
include(../../qtcreatorlibrary.pri)
|
||||||
|
include(codemodelbackendipc-lib.pri)
|
28
src/libs/codemodelbackendipc/codemodelbackendipc.qbs
Normal file
28
src/libs/codemodelbackendipc/codemodelbackendipc.qbs
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
import qbs 1.0
|
||||||
|
|
||||||
|
QtcLibrary {
|
||||||
|
name: "CodeModelBackEndIpc"
|
||||||
|
|
||||||
|
Depends { name: "Qt.network" }
|
||||||
|
Depends { name: "Sqlite" }
|
||||||
|
|
||||||
|
cpp.defines: base.concat("CODEMODELBACKENDIPC_LIBRARY")
|
||||||
|
cpp.includePaths: base.concat(".")
|
||||||
|
|
||||||
|
Group {
|
||||||
|
files: [
|
||||||
|
"*.h",
|
||||||
|
"*.cpp"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
Export {
|
||||||
|
Depends { name: "Sqlite" }
|
||||||
|
Depends { name: "Qt.network" }
|
||||||
|
cpp.includePaths: [
|
||||||
|
"."
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@@ -0,0 +1,3 @@
|
|||||||
|
QTC_LIB_NAME = Codemodelbackendipc
|
||||||
|
QTC_LIB_DEPENDS += sqlite
|
||||||
|
INCLUDEPATH *= $$IDE_SOURCE_TREE/src/libs/codemodelbackendipc
|
37
src/libs/codemodelbackendipc/codemodelbackendipc_global.cpp
Normal file
37
src/libs/codemodelbackendipc/codemodelbackendipc_global.cpp
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "codecompletion.h"
|
||||||
|
|
||||||
|
namespace CodeModelBackEnd {
|
||||||
|
void registerTypes()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
50
src/libs/codemodelbackendipc/codemodelbackendipc_global.h
Normal file
50
src/libs/codemodelbackendipc/codemodelbackendipc_global.h
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef CODEMODELBACKENDIPC_GLOBAL_H
|
||||||
|
#define CODEMODELBACKENDIPC_GLOBAL_H
|
||||||
|
|
||||||
|
#include <QtCore/qglobal.h>
|
||||||
|
|
||||||
|
#if defined(CODEMODELBACKENDIPC_LIBRARY)
|
||||||
|
# define CMBIPC_EXPORT Q_DECL_EXPORT
|
||||||
|
#else
|
||||||
|
# define CMBIPC_EXPORT Q_DECL_IMPORT
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef CODEMODELBACKENDPROCESSPATH
|
||||||
|
# define CODEMODELBACKENDPROCESSPATH ""
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace CodeModelBackEnd {
|
||||||
|
CMBIPC_EXPORT void registerTypes();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // CODEMODELBACKENDIPC_GLOBAL_H
|
300
src/libs/codemodelbackendipc/connectionclient.cpp
Normal file
300
src/libs/codemodelbackendipc/connectionclient.cpp
Normal file
@@ -0,0 +1,300 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "connectionclient.h"
|
||||||
|
|
||||||
|
#include <QProcess>
|
||||||
|
#include <QThread>
|
||||||
|
#include <QCoreApplication>
|
||||||
|
|
||||||
|
#include "cmbregistertranslationunitsforcodecompletioncommand.h"
|
||||||
|
#include "cmbunregistertranslationunitsforcodecompletioncommand.h"
|
||||||
|
#include "cmbcompletecodecommand.h"
|
||||||
|
|
||||||
|
namespace CodeModelBackEnd {
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
QString currentProcessId()
|
||||||
|
{
|
||||||
|
return QString::number(QCoreApplication::applicationPid());
|
||||||
|
}
|
||||||
|
|
||||||
|
QString connectionName()
|
||||||
|
{
|
||||||
|
return QStringLiteral("CodeModelBackEnd-") + currentProcessId();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ConnectionClient::ConnectionClient(IpcClientInterface *client)
|
||||||
|
: serverProxy_(client, &localSocket),
|
||||||
|
isAliveTimerResetted(false)
|
||||||
|
{
|
||||||
|
processAliveTimer.setInterval(10000);
|
||||||
|
|
||||||
|
connect(&processAliveTimer, &QTimer::timeout,
|
||||||
|
this, &ConnectionClient::restartProcessIfTimerIsNotResettedAndSocketIsEmpty);
|
||||||
|
|
||||||
|
connect(&localSocket,
|
||||||
|
static_cast<void (QLocalSocket::*)(QLocalSocket::LocalSocketError)>(&QLocalSocket::error),
|
||||||
|
this,
|
||||||
|
&ConnectionClient::printLocalSocketError);
|
||||||
|
}
|
||||||
|
|
||||||
|
ConnectionClient::~ConnectionClient()
|
||||||
|
{
|
||||||
|
finishProcess();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ConnectionClient::connectToServer()
|
||||||
|
{
|
||||||
|
startProcess();
|
||||||
|
resetProcessAliveTimer();
|
||||||
|
const bool isConnected = connectToLocalSocket();
|
||||||
|
|
||||||
|
return isConnected;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ConnectionClient::disconnectFromServer()
|
||||||
|
{
|
||||||
|
localSocket.disconnectFromServer();
|
||||||
|
if (localSocket.state() != QLocalSocket::UnconnectedState)
|
||||||
|
return localSocket.waitForDisconnected();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ConnectionClient::isConnected() const
|
||||||
|
{
|
||||||
|
return localSocket.state() == QLocalSocket::ConnectedState;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConnectionClient::waitUntilSocketIsFlushed() const
|
||||||
|
{
|
||||||
|
// Avoid to call QAbstractSocket::waitForBytesWritten(), which is known to
|
||||||
|
// be unreliable on Windows. Instead, call processEvents() to actually send
|
||||||
|
// the data.
|
||||||
|
while (localSocket.bytesToWrite() > 0) {
|
||||||
|
QCoreApplication::processEvents();
|
||||||
|
QThread::msleep(20);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConnectionClient::sendEndCommand()
|
||||||
|
{
|
||||||
|
serverProxy_.end();
|
||||||
|
localSocket.flush();
|
||||||
|
waitUntilSocketIsFlushed();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConnectionClient::resetProcessAliveTimer()
|
||||||
|
{
|
||||||
|
isAliveTimerResetted = true;
|
||||||
|
processAliveTimer.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConnectionClient::setProcessAliveTimerInterval(int processTimerInterval)
|
||||||
|
{
|
||||||
|
processAliveTimer.setInterval(processTimerInterval);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConnectionClient::startProcess()
|
||||||
|
{
|
||||||
|
if (!isProcessIsRunning()) {
|
||||||
|
connectProcessFinished();
|
||||||
|
connectStandardOutputAndError();
|
||||||
|
process()->start(processPath(), {connectionName()});
|
||||||
|
process()->waitForStarted();
|
||||||
|
resetProcessAliveTimer();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConnectionClient::restartProcess()
|
||||||
|
{
|
||||||
|
finishProcess();
|
||||||
|
startProcess();
|
||||||
|
|
||||||
|
connectToServer();
|
||||||
|
|
||||||
|
emit processRestarted();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConnectionClient::restartProcessIfTimerIsNotResettedAndSocketIsEmpty()
|
||||||
|
{
|
||||||
|
if (isAliveTimerResetted) {
|
||||||
|
isAliveTimerResetted = false;
|
||||||
|
return; // Already reset, but we were scheduled after.
|
||||||
|
}
|
||||||
|
|
||||||
|
if (localSocket.bytesAvailable() > 0)
|
||||||
|
return; // We come first, the incoming data was not yet processed.
|
||||||
|
|
||||||
|
restartProcess();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ConnectionClient::connectToLocalSocket()
|
||||||
|
{
|
||||||
|
QThread::msleep(30);
|
||||||
|
|
||||||
|
for (int counter = 0; counter < 1000; counter++) {
|
||||||
|
localSocket.connectToServer(connectionName());
|
||||||
|
bool isConnected = localSocket.waitForConnected(20);
|
||||||
|
|
||||||
|
if (isConnected)
|
||||||
|
return isConnected;
|
||||||
|
else
|
||||||
|
QThread::msleep(30);
|
||||||
|
}
|
||||||
|
|
||||||
|
qDebug() << "Cannot connect:" <<localSocket.errorString();
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConnectionClient::endProcess()
|
||||||
|
{
|
||||||
|
if (isProcessIsRunning()) {
|
||||||
|
sendEndCommand();
|
||||||
|
process()->waitForFinished();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConnectionClient::terminateProcess()
|
||||||
|
{
|
||||||
|
#ifndef Q_OS_WIN32
|
||||||
|
if (isProcessIsRunning()) {
|
||||||
|
process()->terminate();
|
||||||
|
process()->waitForFinished();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConnectionClient::killProcess()
|
||||||
|
{
|
||||||
|
if (isProcessIsRunning()) {
|
||||||
|
process()->kill();
|
||||||
|
process()->waitForFinished();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConnectionClient::printLocalSocketError(QLocalSocket::LocalSocketError /*socketError*/)
|
||||||
|
{
|
||||||
|
qWarning() << "ClangCodeModel ConnectionClient LocalSocket Error:" << localSocket.errorString();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConnectionClient::printStandardOutput()
|
||||||
|
{
|
||||||
|
qWarning() << "CodeModelBackEnd:" << process_->readAllStandardOutput();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConnectionClient::printStandardError()
|
||||||
|
{
|
||||||
|
qWarning() << "CodeModelBackEnd Error:" << process_->readAllStandardError();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConnectionClient::finishProcess()
|
||||||
|
{
|
||||||
|
processAliveTimer.stop();
|
||||||
|
|
||||||
|
disconnectProcessFinished();
|
||||||
|
endProcess();
|
||||||
|
disconnectFromServer();
|
||||||
|
terminateProcess();
|
||||||
|
killProcess();
|
||||||
|
|
||||||
|
process_.reset();
|
||||||
|
|
||||||
|
serverProxy_.resetCounter();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ConnectionClient::waitForEcho()
|
||||||
|
{
|
||||||
|
return localSocket.waitForReadyRead();
|
||||||
|
}
|
||||||
|
|
||||||
|
IpcServerProxy &ConnectionClient::serverProxy()
|
||||||
|
{
|
||||||
|
return serverProxy_;
|
||||||
|
}
|
||||||
|
|
||||||
|
QProcess *ConnectionClient::processForTestOnly() const
|
||||||
|
{
|
||||||
|
return process_.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ConnectionClient::isProcessIsRunning() const
|
||||||
|
{
|
||||||
|
return process_ && process_->state() == QProcess::Running;
|
||||||
|
}
|
||||||
|
|
||||||
|
QProcess *ConnectionClient::process() const
|
||||||
|
{
|
||||||
|
if (!process_)
|
||||||
|
process_.reset(new QProcess);
|
||||||
|
|
||||||
|
return process_.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConnectionClient::connectProcessFinished() const
|
||||||
|
{
|
||||||
|
connect(process(),
|
||||||
|
static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished),
|
||||||
|
this,
|
||||||
|
&ConnectionClient::restartProcess);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConnectionClient::disconnectProcessFinished() const
|
||||||
|
{
|
||||||
|
if (process_) {
|
||||||
|
disconnect(process_.get(),
|
||||||
|
static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished),
|
||||||
|
this,
|
||||||
|
&ConnectionClient::restartProcess);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConnectionClient::connectStandardOutputAndError() const
|
||||||
|
{
|
||||||
|
connect(process(), &QProcess::readyReadStandardOutput, this, &ConnectionClient::printStandardOutput);
|
||||||
|
connect(process(), &QProcess::readyReadStandardError, this, &ConnectionClient::printStandardError);
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString &ConnectionClient::processPath() const
|
||||||
|
{
|
||||||
|
return processPath_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConnectionClient::setProcessPath(const QString &processPath)
|
||||||
|
{
|
||||||
|
processPath_ = processPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace CodeModelBackEnd
|
||||||
|
|
113
src/libs/codemodelbackendipc/connectionclient.h
Normal file
113
src/libs/codemodelbackendipc/connectionclient.h
Normal file
@@ -0,0 +1,113 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef CODEMODELBACKEND_CONNECTIONCLIENT_H
|
||||||
|
#define CODEMODELBACKEND_CONNECTIONCLIENT_H
|
||||||
|
|
||||||
|
#include <QLocalSocket>
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
#include "ipcserverproxy.h"
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
class QProcess;
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
class Utf8String;
|
||||||
|
class Utf8StringVector;
|
||||||
|
|
||||||
|
namespace CodeModelBackEnd {
|
||||||
|
|
||||||
|
class FileContainer;
|
||||||
|
|
||||||
|
class CMBIPC_EXPORT ConnectionClient : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
ConnectionClient(IpcClientInterface *client);
|
||||||
|
~ConnectionClient();
|
||||||
|
|
||||||
|
bool connectToServer();
|
||||||
|
bool disconnectFromServer();
|
||||||
|
bool isConnected() const;
|
||||||
|
|
||||||
|
void sendEndCommand();
|
||||||
|
|
||||||
|
void resetProcessAliveTimer();
|
||||||
|
void setProcessAliveTimerInterval(int processTimerInterval);
|
||||||
|
|
||||||
|
const QString &processPath() const;
|
||||||
|
void setProcessPath(const QString &processPath);
|
||||||
|
|
||||||
|
void startProcess();
|
||||||
|
void restartProcess();
|
||||||
|
void restartProcessIfTimerIsNotResettedAndSocketIsEmpty();
|
||||||
|
void finishProcess();
|
||||||
|
bool isProcessIsRunning() const;
|
||||||
|
|
||||||
|
bool waitForEcho();
|
||||||
|
|
||||||
|
IpcServerProxy &serverProxy();
|
||||||
|
|
||||||
|
QProcess *processForTestOnly() const;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void processRestarted();
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool connectToLocalSocket();
|
||||||
|
void endProcess();
|
||||||
|
void terminateProcess();
|
||||||
|
void killProcess();
|
||||||
|
void printLocalSocketError(QLocalSocket::LocalSocketError socketError);
|
||||||
|
void printStandardOutput();
|
||||||
|
void printStandardError();
|
||||||
|
|
||||||
|
QProcess *process() const;
|
||||||
|
void connectProcessFinished() const;
|
||||||
|
void disconnectProcessFinished() const;
|
||||||
|
void connectStandardOutputAndError() const;
|
||||||
|
|
||||||
|
void waitUntilSocketIsFlushed() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
mutable std::unique_ptr<QProcess> process_;
|
||||||
|
QLocalSocket localSocket;
|
||||||
|
IpcServerProxy serverProxy_;
|
||||||
|
QTimer processAliveTimer;
|
||||||
|
QString processPath_;
|
||||||
|
bool isAliveTimerResetted;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace CodeModelBackEnd
|
||||||
|
|
||||||
|
#endif // CODEMODELBACKEND_CONNECTIONCLIENT_H
|
150
src/libs/codemodelbackendipc/connectionserver.cpp
Normal file
150
src/libs/codemodelbackendipc/connectionserver.cpp
Normal file
@@ -0,0 +1,150 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "connectionserver.h"
|
||||||
|
|
||||||
|
#include <QLocalSocket>
|
||||||
|
#include <QCoreApplication>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
|
#include <ipcserverinterface.h>
|
||||||
|
|
||||||
|
#include <cstdlib>
|
||||||
|
|
||||||
|
namespace CodeModelBackEnd {
|
||||||
|
|
||||||
|
QString ConnectionServer::connectionName;
|
||||||
|
|
||||||
|
ConnectionServer::ConnectionServer(const QString &connectionName)
|
||||||
|
: aliveTimerId(startTimer(5000))
|
||||||
|
{
|
||||||
|
this->connectionName = connectionName;
|
||||||
|
|
||||||
|
connect(&localServer, &QLocalServer::newConnection, this, &ConnectionServer::handleNewConnection);
|
||||||
|
std::atexit(&ConnectionServer::removeServer);
|
||||||
|
#if defined(Q_OS_LINUX)
|
||||||
|
std::at_quick_exit(&ConnectionServer::removeServer);
|
||||||
|
#endif
|
||||||
|
std::set_terminate(&ConnectionServer::removeServer);
|
||||||
|
}
|
||||||
|
|
||||||
|
ConnectionServer::~ConnectionServer()
|
||||||
|
{
|
||||||
|
removeServer();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConnectionServer::start()
|
||||||
|
{
|
||||||
|
QLocalServer::removeServer(connectionName);
|
||||||
|
localServer.listen(connectionName);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConnectionServer::setIpcServer(IpcServerInterface *ipcServer)
|
||||||
|
{
|
||||||
|
this->ipcServer = ipcServer;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
int ConnectionServer::clientProxyCount() const
|
||||||
|
{
|
||||||
|
return ipcClientProxies.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConnectionServer::timerEvent(QTimerEvent *timerEvent)
|
||||||
|
{
|
||||||
|
if (aliveTimerId == timerEvent->timerId())
|
||||||
|
sendAliveCommand();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConnectionServer::handleNewConnection()
|
||||||
|
{
|
||||||
|
QLocalSocket *localSocket(nextPendingConnection());
|
||||||
|
|
||||||
|
ipcClientProxies.emplace_back(ipcServer, localSocket);
|
||||||
|
|
||||||
|
ipcServer->addClient(&ipcClientProxies.back());
|
||||||
|
|
||||||
|
localSockets.push_back(localSocket);
|
||||||
|
|
||||||
|
emit newConnection();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConnectionServer::sendAliveCommand()
|
||||||
|
{
|
||||||
|
ipcServer->client()->alive();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConnectionServer::handleSocketDisconnect()
|
||||||
|
{
|
||||||
|
QLocalSocket *senderLocalSocket = static_cast<QLocalSocket*>(sender());
|
||||||
|
|
||||||
|
removeClientProxyWithLocalSocket(senderLocalSocket);
|
||||||
|
localSockets.erase(std::remove_if(localSockets.begin(),
|
||||||
|
localSockets.end(),
|
||||||
|
[senderLocalSocket](QLocalSocket *localSocketInList) { return localSocketInList == senderLocalSocket;}));
|
||||||
|
|
||||||
|
delayedExitApplicationIfNoSockedIsConnected();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConnectionServer::removeClientProxyWithLocalSocket(QLocalSocket *localSocket)
|
||||||
|
{
|
||||||
|
ipcClientProxies.erase(std::remove_if(ipcClientProxies.begin(),
|
||||||
|
ipcClientProxies.end(),
|
||||||
|
[localSocket](const IpcClientProxy &client) { return client.isUsingThatIoDevice(localSocket);}));
|
||||||
|
}
|
||||||
|
|
||||||
|
QLocalSocket *ConnectionServer::nextPendingConnection()
|
||||||
|
{
|
||||||
|
QLocalSocket *localSocket = localServer.nextPendingConnection();
|
||||||
|
|
||||||
|
connect(localSocket, &QLocalSocket::disconnected, this, &ConnectionServer::handleSocketDisconnect);
|
||||||
|
|
||||||
|
return localSocket;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConnectionServer::removeServer()
|
||||||
|
{
|
||||||
|
QLocalServer::removeServer(connectionName);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConnectionServer::delayedExitApplicationIfNoSockedIsConnected()
|
||||||
|
{
|
||||||
|
if (localSockets.size() == 0)
|
||||||
|
QTimer::singleShot(60000, this, &ConnectionServer::exitApplicationIfNoSockedIsConnected);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConnectionServer::exitApplicationIfNoSockedIsConnected()
|
||||||
|
{
|
||||||
|
if (localSockets.size() == 0)
|
||||||
|
QCoreApplication::exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace CodeModelBackEnd
|
||||||
|
|
83
src/libs/codemodelbackendipc/connectionserver.h
Normal file
83
src/libs/codemodelbackendipc/connectionserver.h
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef CODEMODELBACKEND_CONNECTIONSERVER_H
|
||||||
|
#define CODEMODELBACKEND_CONNECTIONSERVER_H
|
||||||
|
|
||||||
|
#include <QLocalServer>
|
||||||
|
#include <ipcclientproxy.h>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
namespace CodeModelBackEnd {
|
||||||
|
|
||||||
|
class IpcServerInterface;
|
||||||
|
class IpcClientProxy;
|
||||||
|
|
||||||
|
class CMBIPC_EXPORT ConnectionServer : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
ConnectionServer(const QString &connectionName);
|
||||||
|
~ConnectionServer();
|
||||||
|
|
||||||
|
void start();
|
||||||
|
void setIpcServer(IpcServerInterface *ipcServer);
|
||||||
|
|
||||||
|
int clientProxyCount() const;
|
||||||
|
|
||||||
|
static void removeServer();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void newConnection();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void timerEvent(QTimerEvent *timerEvent);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void handleNewConnection();
|
||||||
|
void sendAliveCommand();
|
||||||
|
void handleSocketDisconnect();
|
||||||
|
void removeClientProxyWithLocalSocket(QLocalSocket *localSocket);
|
||||||
|
QLocalSocket *nextPendingConnection();
|
||||||
|
void delayedExitApplicationIfNoSockedIsConnected();
|
||||||
|
void exitApplicationIfNoSockedIsConnected();
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::vector<IpcClientProxy> ipcClientProxies;
|
||||||
|
std::vector<QLocalSocket*> localSockets;
|
||||||
|
IpcServerInterface *ipcServer;
|
||||||
|
QLocalServer localServer;
|
||||||
|
static QString connectionName;
|
||||||
|
int aliveTimerId;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace CodeModelBackEnd
|
||||||
|
|
||||||
|
#endif // CODEMODELBACKEND_CONNECTIONSERVER_H
|
136
src/libs/codemodelbackendipc/filecontainer.cpp
Normal file
136
src/libs/codemodelbackendipc/filecontainer.cpp
Normal file
@@ -0,0 +1,136 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "filecontainer.h"
|
||||||
|
|
||||||
|
#include <QtDebug>
|
||||||
|
|
||||||
|
#include <QDataStream>
|
||||||
|
|
||||||
|
#include <ostream>
|
||||||
|
|
||||||
|
namespace CodeModelBackEnd {
|
||||||
|
|
||||||
|
FileContainer::FileContainer(const Utf8String &fileName,
|
||||||
|
const Utf8String &projectPartId,
|
||||||
|
const Utf8String &unsavedFileContent,
|
||||||
|
bool hasUnsavedFileContent)
|
||||||
|
: filePath_(fileName),
|
||||||
|
projectPartId_(projectPartId),
|
||||||
|
unsavedFileContent_(unsavedFileContent),
|
||||||
|
hasUnsavedFileContent_(hasUnsavedFileContent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
const Utf8String &FileContainer::filePath() const
|
||||||
|
{
|
||||||
|
return filePath_;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Utf8String &FileContainer::projectPartId() const
|
||||||
|
{
|
||||||
|
return projectPartId_;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Utf8String &FileContainer::unsavedFileContent() const
|
||||||
|
{
|
||||||
|
return unsavedFileContent_;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FileContainer::hasUnsavedFileContent() const
|
||||||
|
{
|
||||||
|
return hasUnsavedFileContent_;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDataStream &operator<<(QDataStream &out, const FileContainer &container)
|
||||||
|
{
|
||||||
|
out << container.filePath_;
|
||||||
|
out << container.projectPartId_;
|
||||||
|
out << container.unsavedFileContent_;
|
||||||
|
out << container.hasUnsavedFileContent_;
|
||||||
|
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDataStream &operator>>(QDataStream &in, FileContainer &container)
|
||||||
|
{
|
||||||
|
in >> container.filePath_;
|
||||||
|
in >> container.projectPartId_;
|
||||||
|
in >> container.unsavedFileContent_;
|
||||||
|
in >> container.hasUnsavedFileContent_;
|
||||||
|
|
||||||
|
return in;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator == (const FileContainer &first, const FileContainer &second)
|
||||||
|
{
|
||||||
|
return first.filePath_ == second.filePath_ && first.projectPartId_ == second.projectPartId_;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator < (const FileContainer &first, const FileContainer &second)
|
||||||
|
{
|
||||||
|
if (first.filePath_ == second.filePath_)
|
||||||
|
return first.projectPartId_ < second.projectPartId_;
|
||||||
|
|
||||||
|
return first.filePath_ < second.filePath_;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDebug operator <<(QDebug debug, const FileContainer &container)
|
||||||
|
{
|
||||||
|
debug.nospace() << "FileContainer("
|
||||||
|
<< container.filePath()
|
||||||
|
<< ", "
|
||||||
|
<< container.projectPartId();
|
||||||
|
|
||||||
|
if (container.hasUnsavedFileContent())
|
||||||
|
debug.nospace() << ", "
|
||||||
|
<< container.unsavedFileContent();
|
||||||
|
|
||||||
|
debug.nospace() << ")";
|
||||||
|
|
||||||
|
return debug;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PrintTo(const FileContainer &container, ::std::ostream* os)
|
||||||
|
{
|
||||||
|
*os << "FileContainer("
|
||||||
|
<< container.filePath().constData()
|
||||||
|
<< ", "
|
||||||
|
<< container.projectPartId().constData();
|
||||||
|
|
||||||
|
if (container.hasUnsavedFileContent())
|
||||||
|
*os << ", "
|
||||||
|
<< container.unsavedFileContent().constData();
|
||||||
|
|
||||||
|
*os << ")";
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace CodeModelBackEnd
|
||||||
|
|
79
src/libs/codemodelbackendipc/filecontainer.h
Normal file
79
src/libs/codemodelbackendipc/filecontainer.h
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef CODEMODELBACKEND_FILECONTAINER_H
|
||||||
|
#define CODEMODELBACKEND_FILECONTAINER_H
|
||||||
|
|
||||||
|
#include <qmetatype.h>
|
||||||
|
|
||||||
|
#include <utf8string.h>
|
||||||
|
|
||||||
|
#include <codemodelbackendipc_global.h>
|
||||||
|
|
||||||
|
namespace CodeModelBackEnd {
|
||||||
|
|
||||||
|
class CMBIPC_EXPORT FileContainer
|
||||||
|
{
|
||||||
|
friend CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const FileContainer &container);
|
||||||
|
friend CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, FileContainer &container);
|
||||||
|
friend CMBIPC_EXPORT bool operator == (const FileContainer &first, const FileContainer &second);
|
||||||
|
friend CMBIPC_EXPORT bool operator < (const FileContainer &first, const FileContainer &second);
|
||||||
|
public:
|
||||||
|
FileContainer() = default;
|
||||||
|
FileContainer(const Utf8String &filePath,
|
||||||
|
const Utf8String &projectPartId,
|
||||||
|
const Utf8String &unsavedFileContent = Utf8String(),
|
||||||
|
bool hasUnsavedFileContent = false);
|
||||||
|
|
||||||
|
const Utf8String &filePath() const;
|
||||||
|
const Utf8String &projectPartId() const;
|
||||||
|
const Utf8String &unsavedFileContent() const;
|
||||||
|
bool hasUnsavedFileContent() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
Utf8String filePath_;
|
||||||
|
Utf8String projectPartId_;
|
||||||
|
Utf8String unsavedFileContent_;
|
||||||
|
bool hasUnsavedFileContent_ = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const FileContainer &container);
|
||||||
|
CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, FileContainer &container);
|
||||||
|
CMBIPC_EXPORT bool operator == (const FileContainer &first, const FileContainer &second);
|
||||||
|
CMBIPC_EXPORT bool operator < (const FileContainer &first, const FileContainer &second);
|
||||||
|
|
||||||
|
CMBIPC_EXPORT QDebug operator <<(QDebug debug, const FileContainer &container);
|
||||||
|
void PrintTo(const FileContainer &container, ::std::ostream* os);
|
||||||
|
|
||||||
|
} // namespace CodeModelBackEnd
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(CodeModelBackEnd::FileContainer)
|
||||||
|
|
||||||
|
#endif // CODEMODELBACKEND_FILECONTAINER_H
|
78
src/libs/codemodelbackendipc/ipcclientdispatcher.cpp
Normal file
78
src/libs/codemodelbackendipc/ipcclientdispatcher.cpp
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "ipcclientdispatcher.h"
|
||||||
|
|
||||||
|
#include <QtDebug>
|
||||||
|
|
||||||
|
namespace CodeModelBackEnd {
|
||||||
|
|
||||||
|
void IpcClientDispatcher::addClient(IpcClientInterface *client)
|
||||||
|
{
|
||||||
|
clients.append(client);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IpcClientDispatcher::removeClient(IpcClientInterface *client)
|
||||||
|
{
|
||||||
|
clients.removeOne(client);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IpcClientDispatcher::alive()
|
||||||
|
{
|
||||||
|
for (auto *client : clients)
|
||||||
|
client->alive();
|
||||||
|
}
|
||||||
|
|
||||||
|
void IpcClientDispatcher::echo(const EchoCommand &command)
|
||||||
|
{
|
||||||
|
for (auto *client : clients)
|
||||||
|
client->echo(command);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IpcClientDispatcher::codeCompleted(const CodeCompletedCommand &command)
|
||||||
|
{
|
||||||
|
for (auto *client : clients)
|
||||||
|
client->codeCompleted(command);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IpcClientDispatcher::translationUnitDoesNotExist(const TranslationUnitDoesNotExistCommand &command)
|
||||||
|
{
|
||||||
|
for (auto *client : clients)
|
||||||
|
client->translationUnitDoesNotExist(command);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IpcClientDispatcher::projectPartsDoNotExist(const ProjectPartsDoNotExistCommand &command)
|
||||||
|
{
|
||||||
|
for (auto *client : clients)
|
||||||
|
client->projectPartsDoNotExist(command);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace CodeModelBackEnd
|
||||||
|
|
58
src/libs/codemodelbackendipc/ipcclientdispatcher.h
Normal file
58
src/libs/codemodelbackendipc/ipcclientdispatcher.h
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef CODEMODELBACKEND_IPCCLIENTDISPATCHER_H
|
||||||
|
#define CODEMODELBACKEND_IPCCLIENTDISPATCHER_H
|
||||||
|
|
||||||
|
#include "ipcclientinterface.h"
|
||||||
|
|
||||||
|
#include <QVector>
|
||||||
|
|
||||||
|
namespace CodeModelBackEnd {
|
||||||
|
|
||||||
|
class CMBIPC_EXPORT IpcClientDispatcher : public CodeModelBackEnd::IpcClientInterface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
void addClient(IpcClientInterface *client);
|
||||||
|
void removeClient(IpcClientInterface *client);
|
||||||
|
|
||||||
|
void alive() override;
|
||||||
|
void echo(const EchoCommand &command) override;
|
||||||
|
void codeCompleted(const CodeCompletedCommand &command) override;
|
||||||
|
void translationUnitDoesNotExist(const TranslationUnitDoesNotExistCommand &command) override;
|
||||||
|
void projectPartsDoNotExist(const ProjectPartsDoNotExistCommand &command) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
QVector<IpcClientInterface*> clients;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace CodeModelBackEnd
|
||||||
|
|
||||||
|
#endif // CODEMODELBACKEND_IPCCLIENTDISPATCHER_H
|
69
src/libs/codemodelbackendipc/ipcclientinterface.cpp
Normal file
69
src/libs/codemodelbackendipc/ipcclientinterface.cpp
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "ipcclientinterface.h"
|
||||||
|
|
||||||
|
#include <QVariant>
|
||||||
|
#include <QtDebug>
|
||||||
|
|
||||||
|
#include "cmbechocommand.h"
|
||||||
|
#include "cmbcodecompletedcommand.h"
|
||||||
|
#include "translationunitdoesnotexistcommand.h"
|
||||||
|
#include "projectpartsdonotexistcommand.h"
|
||||||
|
|
||||||
|
namespace CodeModelBackEnd {
|
||||||
|
|
||||||
|
|
||||||
|
void IpcClientInterface::dispatch(const QVariant &command)
|
||||||
|
{
|
||||||
|
static const int aliveCommandType = QMetaType::type("CodeModelBackEnd::AliveCommand");
|
||||||
|
static const int echoCommandType = QMetaType::type("CodeModelBackEnd::EchoCommand");
|
||||||
|
static const int codeCompletedCommandType = QMetaType::type("CodeModelBackEnd::CodeCompletedCommand");
|
||||||
|
static const int translationUnitDoesNotExistCommand = QMetaType::type("CodeModelBackEnd::TranslationUnitDoesNotExistCommand");
|
||||||
|
static const int projectPartsDoNotExistCommand = QMetaType::type("CodeModelBackEnd::ProjectPartsDoNotExistCommand");
|
||||||
|
|
||||||
|
int type = command.userType();
|
||||||
|
|
||||||
|
if (type == aliveCommandType)
|
||||||
|
alive();
|
||||||
|
else if (type == echoCommandType)
|
||||||
|
echo(command.value<EchoCommand>());
|
||||||
|
else if (type == codeCompletedCommandType)
|
||||||
|
codeCompleted(command.value<CodeCompletedCommand>());
|
||||||
|
else if (type == translationUnitDoesNotExistCommand)
|
||||||
|
translationUnitDoesNotExist(command.value<TranslationUnitDoesNotExistCommand>());
|
||||||
|
else if (type == projectPartsDoNotExistCommand)
|
||||||
|
projectPartsDoNotExist(command.value<ProjectPartsDoNotExistCommand>());
|
||||||
|
else
|
||||||
|
qWarning() << "Unknown IpcClientCommand";
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace CodeModelBackEnd
|
||||||
|
|
63
src/libs/codemodelbackendipc/ipcclientinterface.h
Normal file
63
src/libs/codemodelbackendipc/ipcclientinterface.h
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef CODEMODELBACKEND_IPCCLIENTINTERFACE_H
|
||||||
|
#define CODEMODELBACKEND_IPCCLIENTINTERFACE_H
|
||||||
|
|
||||||
|
#include "ipcinterface.h"
|
||||||
|
|
||||||
|
namespace CodeModelBackEnd {
|
||||||
|
|
||||||
|
class IpcServerInterface;
|
||||||
|
class RegisterTranslationUnitForCodeCompletionCommand;
|
||||||
|
class RegisterProjectPartsForCodeCompletionCommand;
|
||||||
|
class UnregisterTranslationUnitsForCodeCompletionCommand;
|
||||||
|
class UnregisterProjectPartsForCodeCompletionCommand;
|
||||||
|
class EchoCommand;
|
||||||
|
class CompleteCodeCommand;
|
||||||
|
class CodeCompletedCommand;
|
||||||
|
class TranslationUnitDoesNotExistCommand;
|
||||||
|
class ProjectPartsDoNotExistCommand;
|
||||||
|
|
||||||
|
class CMBIPC_EXPORT IpcClientInterface : public IpcInterface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
void dispatch(const QVariant &command) override;
|
||||||
|
|
||||||
|
virtual void alive() = 0;
|
||||||
|
virtual void echo(const EchoCommand &command) = 0;
|
||||||
|
virtual void codeCompleted(const CodeCompletedCommand &command) = 0;
|
||||||
|
virtual void translationUnitDoesNotExist(const TranslationUnitDoesNotExistCommand &command) = 0;
|
||||||
|
virtual void projectPartsDoNotExist(const ProjectPartsDoNotExistCommand &command) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace CodeModelBackEnd
|
||||||
|
|
||||||
|
#endif // CODEMODELBACKEND_IPCCLIENTINTERFACE_H
|
114
src/libs/codemodelbackendipc/ipcclientproxy.cpp
Normal file
114
src/libs/codemodelbackendipc/ipcclientproxy.cpp
Normal file
@@ -0,0 +1,114 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "ipcclientproxy.h"
|
||||||
|
|
||||||
|
#include <cmbalivecommand.h>
|
||||||
|
|
||||||
|
#include <QVariant>
|
||||||
|
#include <QVector>
|
||||||
|
#include <QIODevice>
|
||||||
|
#include <QtDebug>
|
||||||
|
|
||||||
|
#include "ipcserverinterface.h"
|
||||||
|
#include "cmbechocommand.h"
|
||||||
|
#include "cmbregistertranslationunitsforcodecompletioncommand.h"
|
||||||
|
#include "cmbcodecompletedcommand.h"
|
||||||
|
#include "translationunitdoesnotexistcommand.h"
|
||||||
|
#include "projectpartsdonotexistcommand.h"
|
||||||
|
|
||||||
|
namespace CodeModelBackEnd {
|
||||||
|
|
||||||
|
IpcClientProxy::IpcClientProxy(IpcServerInterface *server, QIODevice *ioDevice)
|
||||||
|
: writeCommandBlock(ioDevice),
|
||||||
|
readCommandBlock(ioDevice),
|
||||||
|
server(server),
|
||||||
|
ioDevice(ioDevice)
|
||||||
|
{
|
||||||
|
QObject::connect(ioDevice, &QIODevice::readyRead, [this] () {IpcClientProxy::readCommands();});
|
||||||
|
}
|
||||||
|
|
||||||
|
IpcClientProxy::IpcClientProxy(IpcClientProxy &&other)
|
||||||
|
: writeCommandBlock(std::move(other.writeCommandBlock)),
|
||||||
|
readCommandBlock(std::move(other.readCommandBlock)),
|
||||||
|
server(std::move(other.server)),
|
||||||
|
ioDevice(std::move(other.ioDevice))
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
IpcClientProxy &IpcClientProxy::operator =(IpcClientProxy &&other)
|
||||||
|
{
|
||||||
|
writeCommandBlock = std::move(other.writeCommandBlock);
|
||||||
|
readCommandBlock = std::move(other.readCommandBlock);
|
||||||
|
server = std::move(other.server);
|
||||||
|
ioDevice = std::move(other.ioDevice);
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
void IpcClientProxy::alive()
|
||||||
|
{
|
||||||
|
writeCommandBlock.write(QVariant::fromValue(AliveCommand()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void IpcClientProxy::echo(const EchoCommand &command)
|
||||||
|
{
|
||||||
|
writeCommandBlock.write(QVariant::fromValue(command));
|
||||||
|
}
|
||||||
|
|
||||||
|
void IpcClientProxy::codeCompleted(const CodeCompletedCommand &command)
|
||||||
|
{
|
||||||
|
writeCommandBlock.write(QVariant::fromValue(command));
|
||||||
|
}
|
||||||
|
|
||||||
|
void IpcClientProxy::translationUnitDoesNotExist(const TranslationUnitDoesNotExistCommand &command)
|
||||||
|
{
|
||||||
|
writeCommandBlock.write(QVariant::fromValue(command));
|
||||||
|
}
|
||||||
|
|
||||||
|
void IpcClientProxy::projectPartsDoNotExist(const ProjectPartsDoNotExistCommand &command)
|
||||||
|
{
|
||||||
|
writeCommandBlock.write(QVariant::fromValue(command));
|
||||||
|
}
|
||||||
|
|
||||||
|
void IpcClientProxy::readCommands()
|
||||||
|
{
|
||||||
|
for (const QVariant &command : readCommandBlock.readAll())
|
||||||
|
server->dispatch(command);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IpcClientProxy::isUsingThatIoDevice(QIODevice *ioDevice) const
|
||||||
|
{
|
||||||
|
return this->ioDevice == ioDevice;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace CodeModelBackEnd
|
||||||
|
|
80
src/libs/codemodelbackendipc/ipcclientproxy.h
Normal file
80
src/libs/codemodelbackendipc/ipcclientproxy.h
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef CODELMODELBACKEND_IPCCLIENTPROXY_H
|
||||||
|
#define CODELMODELBACKEND_IPCCLIENTPROXY_H
|
||||||
|
|
||||||
|
#include <QtGlobal>
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
#include "codemodelbackendipc_global.h"
|
||||||
|
#include "ipcclientinterface.h"
|
||||||
|
|
||||||
|
#include "writecommandblock.h"
|
||||||
|
#include "readcommandblock.h"
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
class QLocalServer;
|
||||||
|
class QIODevice;
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
namespace CodeModelBackEnd {
|
||||||
|
|
||||||
|
class CMBIPC_EXPORT IpcClientProxy : public IpcClientInterface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit IpcClientProxy(IpcServerInterface *server, QIODevice *ioDevice);
|
||||||
|
IpcClientProxy(const IpcClientProxy&) = delete;
|
||||||
|
const IpcClientProxy &operator =(const IpcClientProxy&) = delete;
|
||||||
|
|
||||||
|
IpcClientProxy(IpcClientProxy&&other);
|
||||||
|
IpcClientProxy &operator =(IpcClientProxy&&other);
|
||||||
|
|
||||||
|
void alive() override;
|
||||||
|
void echo(const EchoCommand &command) override;
|
||||||
|
void codeCompleted(const CodeCompletedCommand &command) override;
|
||||||
|
void translationUnitDoesNotExist(const TranslationUnitDoesNotExistCommand &command) override;
|
||||||
|
void projectPartsDoNotExist(const ProjectPartsDoNotExistCommand &command) override;
|
||||||
|
|
||||||
|
void readCommands();
|
||||||
|
|
||||||
|
bool isUsingThatIoDevice(QIODevice *ioDevice) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
CodeModelBackEnd::WriteCommandBlock writeCommandBlock;
|
||||||
|
CodeModelBackEnd::ReadCommandBlock readCommandBlock;
|
||||||
|
IpcServerInterface *server = nullptr;
|
||||||
|
QIODevice *ioDevice = nullptr;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace CodeModelBackEnd
|
||||||
|
|
||||||
|
#endif // CODELMODELBACKEND_IPCCLIENTPROXY_H
|
40
src/libs/codemodelbackendipc/ipcinterface.cpp
Normal file
40
src/libs/codemodelbackendipc/ipcinterface.cpp
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "ipcinterface.h"
|
||||||
|
|
||||||
|
namespace CodeModelBackEnd {
|
||||||
|
|
||||||
|
IpcInterface::~IpcInterface()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace CodeModelBackEnd
|
||||||
|
|
53
src/libs/codemodelbackendipc/ipcinterface.h
Normal file
53
src/libs/codemodelbackendipc/ipcinterface.h
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef CODEMODELBACKEND_IPCINTERFACE_H
|
||||||
|
#define CODEMODELBACKEND_IPCINTERFACE_H
|
||||||
|
|
||||||
|
#include <QtGlobal>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
class QVariant;
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
#include <codemodelbackendipc_global.h>
|
||||||
|
|
||||||
|
namespace CodeModelBackEnd {
|
||||||
|
|
||||||
|
class CMBIPC_EXPORT IpcInterface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual ~IpcInterface();
|
||||||
|
virtual void dispatch(const QVariant &command) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace CodeModelBackEnd
|
||||||
|
|
||||||
|
#endif // CODEMODELBACKEND_IPCINTERFACE_H
|
46
src/libs/codemodelbackendipc/ipcserver.cpp
Normal file
46
src/libs/codemodelbackendipc/ipcserver.cpp
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "ipcserver.h"
|
||||||
|
|
||||||
|
namespace CodeModelBackEnd {
|
||||||
|
|
||||||
|
IpcServer::IpcServer()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
IpcServer::~IpcServer()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace CodeModelBackEnd
|
||||||
|
|
47
src/libs/codemodelbackendipc/ipcserver.h
Normal file
47
src/libs/codemodelbackendipc/ipcserver.h
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef CODEMODELBACKEND_IPCSERVER_H
|
||||||
|
#define CODEMODELBACKEND_IPCSERVER_H
|
||||||
|
|
||||||
|
#include "ipcserverinterface.h"
|
||||||
|
|
||||||
|
namespace CodeModelBackEnd {
|
||||||
|
|
||||||
|
class IpcServer : public IpcServerInterface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
IpcServer();
|
||||||
|
~IpcServer();
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace CodeModelBackEnd
|
||||||
|
|
||||||
|
#endif // CODEMODELBACKEND_IPCSERVER_H
|
87
src/libs/codemodelbackendipc/ipcserverinterface.cpp
Normal file
87
src/libs/codemodelbackendipc/ipcserverinterface.cpp
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "ipcserverinterface.h"
|
||||||
|
|
||||||
|
#include <QVariant>
|
||||||
|
#include <QtDebug>
|
||||||
|
|
||||||
|
#include "cmbregistertranslationunitsforcodecompletioncommand.h"
|
||||||
|
#include "cmbunregistertranslationunitsforcodecompletioncommand.h"
|
||||||
|
#include "cmbregisterprojectsforcodecompletioncommand.h"
|
||||||
|
#include "cmbunregisterprojectsforcodecompletioncommand.h"
|
||||||
|
#include "cmbcompletecodecommand.h"
|
||||||
|
|
||||||
|
namespace CodeModelBackEnd {
|
||||||
|
|
||||||
|
void IpcServerInterface::dispatch(const QVariant &command)
|
||||||
|
{
|
||||||
|
static const int endCommandType = QMetaType::type("CodeModelBackEnd::EndCommand");
|
||||||
|
static const int registerTranslationUnitsForCodeCompletionCommandType = QMetaType::type("CodeModelBackEnd::RegisterTranslationUnitForCodeCompletionCommand");
|
||||||
|
static const int unregisterTranslationUnitsForCodeCompletionCommandType = QMetaType::type("CodeModelBackEnd::UnregisterTranslationUnitsForCodeCompletionCommand");
|
||||||
|
static const int registerProjectPartsForCodeCompletionCommandType = QMetaType::type("CodeModelBackEnd::RegisterProjectPartsForCodeCompletionCommand");
|
||||||
|
static const int unregisterProjectPartsForCodeCompletionCommandType = QMetaType::type("CodeModelBackEnd::UnregisterProjectPartsForCodeCompletionCommand");
|
||||||
|
static const int completeCodeCommandType = QMetaType::type("CodeModelBackEnd::CompleteCodeCommand");
|
||||||
|
|
||||||
|
int type = command.userType();
|
||||||
|
|
||||||
|
if (type == endCommandType)
|
||||||
|
end();
|
||||||
|
else if (type == registerTranslationUnitsForCodeCompletionCommandType)
|
||||||
|
registerTranslationUnitsForCodeCompletion(command.value<RegisterTranslationUnitForCodeCompletionCommand>());
|
||||||
|
else if (type == unregisterTranslationUnitsForCodeCompletionCommandType)
|
||||||
|
unregisterTranslationUnitsForCodeCompletion(command.value<UnregisterTranslationUnitsForCodeCompletionCommand>());
|
||||||
|
else if (type == registerProjectPartsForCodeCompletionCommandType)
|
||||||
|
registerProjectPartsForCodeCompletion(command.value<RegisterProjectPartsForCodeCompletionCommand>());
|
||||||
|
else if (type == unregisterProjectPartsForCodeCompletionCommandType)
|
||||||
|
unregisterProjectPartsForCodeCompletion(command.value<UnregisterProjectPartsForCodeCompletionCommand>());
|
||||||
|
else if (type == completeCodeCommandType)
|
||||||
|
completeCode(command.value<CompleteCodeCommand>());
|
||||||
|
else
|
||||||
|
qWarning() << "Unknown IpcServerCommand";
|
||||||
|
}
|
||||||
|
|
||||||
|
void IpcServerInterface::addClient(IpcClientInterface *client)
|
||||||
|
{
|
||||||
|
clientDispatcher.addClient(client);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IpcServerInterface::removeClient(IpcClientInterface *client)
|
||||||
|
{
|
||||||
|
clientDispatcher.removeClient(client);
|
||||||
|
}
|
||||||
|
|
||||||
|
IpcClientInterface *IpcServerInterface::client()
|
||||||
|
{
|
||||||
|
return &clientDispatcher;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace CodeModelBackEnd
|
||||||
|
|
65
src/libs/codemodelbackendipc/ipcserverinterface.h
Normal file
65
src/libs/codemodelbackendipc/ipcserverinterface.h
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef CODEMODELBACKEND_IPCSERVERINTERFACE_H
|
||||||
|
#define CODEMODELBACKEND_IPCSERVERINTERFACE_H
|
||||||
|
|
||||||
|
#include "ipcinterface.h"
|
||||||
|
|
||||||
|
#include "ipcclientdispatcher.h"
|
||||||
|
|
||||||
|
namespace CodeModelBackEnd {
|
||||||
|
|
||||||
|
class IpcClientInterface;
|
||||||
|
|
||||||
|
class CMBIPC_EXPORT IpcServerInterface : public IpcInterface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
void dispatch(const QVariant &command) override;
|
||||||
|
|
||||||
|
virtual void end() = 0;
|
||||||
|
virtual void registerTranslationUnitsForCodeCompletion(const RegisterTranslationUnitForCodeCompletionCommand &command) = 0;
|
||||||
|
virtual void unregisterTranslationUnitsForCodeCompletion(const UnregisterTranslationUnitsForCodeCompletionCommand &command) = 0;
|
||||||
|
virtual void registerProjectPartsForCodeCompletion(const RegisterProjectPartsForCodeCompletionCommand &command) = 0;
|
||||||
|
virtual void unregisterProjectPartsForCodeCompletion(const UnregisterProjectPartsForCodeCompletionCommand &command) = 0;
|
||||||
|
virtual void completeCode(const CompleteCodeCommand &command) = 0;
|
||||||
|
|
||||||
|
void addClient(IpcClientInterface *client);
|
||||||
|
void removeClient(IpcClientInterface *client);
|
||||||
|
|
||||||
|
IpcClientInterface *client();
|
||||||
|
|
||||||
|
private:
|
||||||
|
IpcClientDispatcher clientDispatcher;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace CodeModelBackEnd
|
||||||
|
|
||||||
|
#endif // CODEMODELBACKEND_IPCSERVERINTERFACE_H
|
100
src/libs/codemodelbackendipc/ipcserverproxy.cpp
Normal file
100
src/libs/codemodelbackendipc/ipcserverproxy.cpp
Normal file
@@ -0,0 +1,100 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "ipcserverproxy.h"
|
||||||
|
|
||||||
|
#include <QProcess>
|
||||||
|
#include <QLocalSocket>
|
||||||
|
#include <QLocalServer>
|
||||||
|
|
||||||
|
#include <cmbendcommand.h>
|
||||||
|
#include <cmbalivecommand.h>
|
||||||
|
#include <cmbregistertranslationunitsforcodecompletioncommand.h>
|
||||||
|
#include <cmbunregistertranslationunitsforcodecompletioncommand.h>
|
||||||
|
#include <cmbregisterprojectsforcodecompletioncommand.h>
|
||||||
|
#include <cmbunregisterprojectsforcodecompletioncommand.h>
|
||||||
|
#include <cmbcompletecodecommand.h>
|
||||||
|
|
||||||
|
#include <ipcclientinterface.h>
|
||||||
|
|
||||||
|
namespace CodeModelBackEnd {
|
||||||
|
|
||||||
|
IpcServerProxy::IpcServerProxy(IpcClientInterface *client, QIODevice *ioDevice)
|
||||||
|
: writeCommandBlock(ioDevice),
|
||||||
|
readCommandBlock(ioDevice),
|
||||||
|
client(client)
|
||||||
|
{
|
||||||
|
QObject::connect(ioDevice, &QIODevice::readyRead, [this] () {IpcServerProxy::readCommands();});
|
||||||
|
}
|
||||||
|
|
||||||
|
void IpcServerProxy::readCommands()
|
||||||
|
{
|
||||||
|
for (const QVariant &command : readCommandBlock.readAll())
|
||||||
|
client->dispatch(command);
|
||||||
|
}
|
||||||
|
|
||||||
|
void IpcServerProxy::resetCounter()
|
||||||
|
{
|
||||||
|
writeCommandBlock.resetCounter();
|
||||||
|
readCommandBlock.resetCounter();
|
||||||
|
}
|
||||||
|
|
||||||
|
void IpcServerProxy::end()
|
||||||
|
{
|
||||||
|
writeCommandBlock.write(QVariant::fromValue(EndCommand()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void IpcServerProxy::registerTranslationUnitsForCodeCompletion(const RegisterTranslationUnitForCodeCompletionCommand &command)
|
||||||
|
{
|
||||||
|
writeCommandBlock.write(QVariant::fromValue(command));
|
||||||
|
}
|
||||||
|
|
||||||
|
void IpcServerProxy::unregisterTranslationUnitsForCodeCompletion(const UnregisterTranslationUnitsForCodeCompletionCommand &command)
|
||||||
|
{
|
||||||
|
writeCommandBlock.write(QVariant::fromValue(command));
|
||||||
|
}
|
||||||
|
|
||||||
|
void IpcServerProxy::registerProjectPartsForCodeCompletion(const RegisterProjectPartsForCodeCompletionCommand &command)
|
||||||
|
{
|
||||||
|
writeCommandBlock.write(QVariant::fromValue(command));
|
||||||
|
}
|
||||||
|
|
||||||
|
void IpcServerProxy::unregisterProjectPartsForCodeCompletion(const UnregisterProjectPartsForCodeCompletionCommand &command)
|
||||||
|
{
|
||||||
|
writeCommandBlock.write(QVariant::fromValue(command));
|
||||||
|
}
|
||||||
|
|
||||||
|
void IpcServerProxy::completeCode(const CompleteCodeCommand &command)
|
||||||
|
{
|
||||||
|
writeCommandBlock.write(QVariant::fromValue(command));
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace CodeModelBackEnd
|
||||||
|
|
78
src/libs/codemodelbackendipc/ipcserverproxy.h
Normal file
78
src/libs/codemodelbackendipc/ipcserverproxy.h
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef CODEMODELBACKEND_IPCSERVERPROXY_H
|
||||||
|
#define CODEMODELBACKEND_IPCSERVERPROXY_H
|
||||||
|
|
||||||
|
#include <qglobal.h>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
#include "ipcserverinterface.h"
|
||||||
|
#include "writecommandblock.h"
|
||||||
|
#include "readcommandblock.h"
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
class QVariant;
|
||||||
|
class QProcess;
|
||||||
|
class QLocalServer;
|
||||||
|
class QLocalSocket;
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
namespace CodeModelBackEnd {
|
||||||
|
|
||||||
|
class CMBIPC_EXPORT IpcServerProxy : public IpcServerInterface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
IpcServerProxy(IpcClientInterface *client, QIODevice *ioDevice);
|
||||||
|
IpcServerProxy(const IpcServerProxy&) = delete;
|
||||||
|
IpcServerProxy &operator =(const IpcServerProxy&) = delete;
|
||||||
|
|
||||||
|
void end() override;
|
||||||
|
void registerTranslationUnitsForCodeCompletion(const RegisterTranslationUnitForCodeCompletionCommand &command) override;
|
||||||
|
void unregisterTranslationUnitsForCodeCompletion(const UnregisterTranslationUnitsForCodeCompletionCommand &command) override;
|
||||||
|
void registerProjectPartsForCodeCompletion(const RegisterProjectPartsForCodeCompletionCommand &command) override;
|
||||||
|
void unregisterProjectPartsForCodeCompletion(const UnregisterProjectPartsForCodeCompletionCommand &command) override;
|
||||||
|
void completeCode(const CompleteCodeCommand &command) override;
|
||||||
|
|
||||||
|
void readCommands();
|
||||||
|
|
||||||
|
void resetCounter();
|
||||||
|
|
||||||
|
private:
|
||||||
|
CodeModelBackEnd::WriteCommandBlock writeCommandBlock;
|
||||||
|
CodeModelBackEnd::ReadCommandBlock readCommandBlock;
|
||||||
|
IpcClientInterface *client;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace CodeModelBackEnd
|
||||||
|
|
||||||
|
#endif // CODEMODELBACKEND_IPCSERVERPROXY_H
|
107
src/libs/codemodelbackendipc/projectpartcontainer.cpp
Normal file
107
src/libs/codemodelbackendipc/projectpartcontainer.cpp
Normal file
@@ -0,0 +1,107 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "projectpartcontainer.h"
|
||||||
|
|
||||||
|
#include <QtDebug>
|
||||||
|
|
||||||
|
#include <QDataStream>
|
||||||
|
|
||||||
|
#include <ostream>
|
||||||
|
|
||||||
|
namespace CodeModelBackEnd {
|
||||||
|
|
||||||
|
ProjectPartContainer::ProjectPartContainer(const Utf8String &projectPathId,
|
||||||
|
const Utf8StringVector &arguments)
|
||||||
|
: projectPartId_(projectPathId),
|
||||||
|
arguments_(arguments)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
const Utf8String &ProjectPartContainer::projectPartId() const
|
||||||
|
{
|
||||||
|
return projectPartId_;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Utf8StringVector &ProjectPartContainer::arguments() const
|
||||||
|
{
|
||||||
|
return arguments_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QDataStream &operator<<(QDataStream &out, const ProjectPartContainer &container)
|
||||||
|
{
|
||||||
|
out << container.projectPartId_;
|
||||||
|
out << container.arguments_;
|
||||||
|
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDataStream &operator>>(QDataStream &in, ProjectPartContainer &container)
|
||||||
|
{
|
||||||
|
in >> container.projectPartId_;
|
||||||
|
in >> container.arguments_;
|
||||||
|
|
||||||
|
return in;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator == (const ProjectPartContainer &first, const ProjectPartContainer &second)
|
||||||
|
{
|
||||||
|
return first.projectPartId_ == second.projectPartId_;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator < (const ProjectPartContainer &first, const ProjectPartContainer &second)
|
||||||
|
{
|
||||||
|
return first.projectPartId_ < second.projectPartId_;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDebug operator <<(QDebug debug, const ProjectPartContainer &container)
|
||||||
|
{
|
||||||
|
debug.nospace() << "ProjectPartContainer("
|
||||||
|
<< container.projectPartId()
|
||||||
|
<< ","
|
||||||
|
<< container.arguments()
|
||||||
|
<< ")";
|
||||||
|
|
||||||
|
return debug;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PrintTo(const ProjectPartContainer &container, ::std::ostream* os)
|
||||||
|
{
|
||||||
|
*os << "ProjectPartContainer("
|
||||||
|
<< container.projectPartId().constData()
|
||||||
|
<< ","
|
||||||
|
<< container.arguments().constData()
|
||||||
|
<< ")";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace CodeModelBackEnd
|
||||||
|
|
73
src/libs/codemodelbackendipc/projectpartcontainer.h
Normal file
73
src/libs/codemodelbackendipc/projectpartcontainer.h
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef CODEMODELBACKEND_PROJECTCONTAINER_H
|
||||||
|
#define CODEMODELBACKEND_PROJECTCONTAINER_H
|
||||||
|
|
||||||
|
#include <QMetaType>
|
||||||
|
|
||||||
|
#include <utf8stringvector.h>
|
||||||
|
|
||||||
|
#include <codemodelbackendipc_global.h>
|
||||||
|
|
||||||
|
namespace CodeModelBackEnd {
|
||||||
|
|
||||||
|
class CMBIPC_EXPORT ProjectPartContainer
|
||||||
|
{
|
||||||
|
friend CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const ProjectPartContainer &container);
|
||||||
|
friend CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, ProjectPartContainer &container);
|
||||||
|
friend CMBIPC_EXPORT bool operator == (const ProjectPartContainer &first, const ProjectPartContainer &second);
|
||||||
|
friend CMBIPC_EXPORT bool operator < (const ProjectPartContainer &first, const ProjectPartContainer &second);
|
||||||
|
public:
|
||||||
|
ProjectPartContainer() = default;
|
||||||
|
ProjectPartContainer(const Utf8String &projectPartId,
|
||||||
|
const Utf8StringVector &arguments = Utf8StringVector());
|
||||||
|
|
||||||
|
const Utf8String &projectPartId() const;
|
||||||
|
const Utf8StringVector &arguments() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
Utf8String projectPartId_;
|
||||||
|
Utf8StringVector arguments_;
|
||||||
|
};
|
||||||
|
|
||||||
|
CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const ProjectPartContainer &container);
|
||||||
|
CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, ProjectPartContainer &container);
|
||||||
|
CMBIPC_EXPORT bool operator == (const ProjectPartContainer &first, const ProjectPartContainer &second);
|
||||||
|
CMBIPC_EXPORT bool operator < (const ProjectPartContainer &first, const ProjectPartContainer &second);
|
||||||
|
|
||||||
|
QDebug operator <<(QDebug debug, const ProjectPartContainer &container);
|
||||||
|
void PrintTo(const ProjectPartContainer &container, ::std::ostream* os);
|
||||||
|
|
||||||
|
} // namespace CodeModelBackEnd
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(CodeModelBackEnd::ProjectPartContainer)
|
||||||
|
|
||||||
|
#endif // CODEMODELBACKEND_PROJECTCONTAINER_H
|
@@ -0,0 +1,99 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "projectpartsdonotexistcommand.h"
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
|
#include <QDataStream>
|
||||||
|
|
||||||
|
#include <ostream>
|
||||||
|
|
||||||
|
namespace CodeModelBackEnd {
|
||||||
|
|
||||||
|
ProjectPartsDoNotExistCommand::ProjectPartsDoNotExistCommand(const Utf8StringVector &projectPartIds)
|
||||||
|
: projectPartIds_(projectPartIds)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const Utf8StringVector &ProjectPartsDoNotExistCommand::projectPartIds() const
|
||||||
|
{
|
||||||
|
return projectPartIds_;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDataStream &operator<<(QDataStream &out, const ProjectPartsDoNotExistCommand &command)
|
||||||
|
{
|
||||||
|
out << command.projectPartIds_;
|
||||||
|
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDataStream &operator>>(QDataStream &in, ProjectPartsDoNotExistCommand &command)
|
||||||
|
{
|
||||||
|
in >> command.projectPartIds_;
|
||||||
|
|
||||||
|
return in;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator == (const ProjectPartsDoNotExistCommand &first, const ProjectPartsDoNotExistCommand &second)
|
||||||
|
{
|
||||||
|
return first.projectPartIds_ == second.projectPartIds_;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator < (const ProjectPartsDoNotExistCommand &first, const ProjectPartsDoNotExistCommand &second)
|
||||||
|
{
|
||||||
|
return first.projectPartIds_ < second.projectPartIds_;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDebug operator <<(QDebug debug, const ProjectPartsDoNotExistCommand &command)
|
||||||
|
{
|
||||||
|
debug.nospace() << "ProjectPartDoesNotExistCommand(";
|
||||||
|
|
||||||
|
debug.nospace() << command.projectPartIds_;
|
||||||
|
|
||||||
|
debug.nospace() << ")";
|
||||||
|
|
||||||
|
return debug;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PrintTo(const ProjectPartsDoNotExistCommand &command, ::std::ostream* os)
|
||||||
|
{
|
||||||
|
QString output;
|
||||||
|
QDebug debug(&output);
|
||||||
|
|
||||||
|
debug << command;
|
||||||
|
|
||||||
|
*os << output.toUtf8().constData();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace CodeModelBackEnd
|
||||||
|
|
72
src/libs/codemodelbackendipc/projectpartsdonotexistcommand.h
Normal file
72
src/libs/codemodelbackendipc/projectpartsdonotexistcommand.h
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef CODEMODELBACKEND_PROJECTPARTSDONOTEXISTCOMMAND_H
|
||||||
|
#define CODEMODELBACKEND_PROJECTPARTSDONOTEXISTCOMMAND_H
|
||||||
|
|
||||||
|
#include <QMetaType>
|
||||||
|
|
||||||
|
#include <utf8stringvector.h>
|
||||||
|
|
||||||
|
#include "codemodelbackendipc_global.h"
|
||||||
|
|
||||||
|
namespace CodeModelBackEnd {
|
||||||
|
|
||||||
|
class CMBIPC_EXPORT ProjectPartsDoNotExistCommand
|
||||||
|
{
|
||||||
|
friend CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const ProjectPartsDoNotExistCommand &command);
|
||||||
|
friend CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, ProjectPartsDoNotExistCommand &command);
|
||||||
|
friend CMBIPC_EXPORT bool operator == (const ProjectPartsDoNotExistCommand &first, const ProjectPartsDoNotExistCommand &second);
|
||||||
|
friend CMBIPC_EXPORT bool operator < (const ProjectPartsDoNotExistCommand &first, const ProjectPartsDoNotExistCommand &second);
|
||||||
|
friend CMBIPC_EXPORT QDebug operator <<(QDebug debug, const ProjectPartsDoNotExistCommand &command);
|
||||||
|
friend void PrintTo(const ProjectPartsDoNotExistCommand &command, ::std::ostream* os);
|
||||||
|
public:
|
||||||
|
ProjectPartsDoNotExistCommand() = default;
|
||||||
|
ProjectPartsDoNotExistCommand(const Utf8StringVector &projectPartIds);
|
||||||
|
|
||||||
|
const Utf8StringVector &projectPartIds() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
Utf8StringVector projectPartIds_;
|
||||||
|
};
|
||||||
|
|
||||||
|
CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const ProjectPartsDoNotExistCommand &command);
|
||||||
|
CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, ProjectPartsDoNotExistCommand &command);
|
||||||
|
CMBIPC_EXPORT bool operator == (const ProjectPartsDoNotExistCommand &first, const ProjectPartsDoNotExistCommand &second);
|
||||||
|
CMBIPC_EXPORT bool operator < (const ProjectPartsDoNotExistCommand &first, const ProjectPartsDoNotExistCommand &second);
|
||||||
|
|
||||||
|
CMBIPC_EXPORT QDebug operator <<(QDebug debug, const ProjectPartsDoNotExistCommand &command);
|
||||||
|
void PrintTo(const ProjectPartsDoNotExistCommand &command, ::std::ostream* os);
|
||||||
|
|
||||||
|
} // namespace CodeModelBackEnd
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(CodeModelBackEnd::ProjectPartsDoNotExistCommand)
|
||||||
|
|
||||||
|
#endif // CODEMODELBACKEND_PROJECTPARTSDONOTEXISTCOMMAND_H
|
115
src/libs/codemodelbackendipc/readcommandblock.cpp
Normal file
115
src/libs/codemodelbackendipc/readcommandblock.cpp
Normal file
@@ -0,0 +1,115 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "readcommandblock.h"
|
||||||
|
|
||||||
|
#include <QDataStream>
|
||||||
|
#include <QIODevice>
|
||||||
|
#include <QVariant>
|
||||||
|
#include <QtDebug>
|
||||||
|
|
||||||
|
namespace CodeModelBackEnd {
|
||||||
|
|
||||||
|
ReadCommandBlock::ReadCommandBlock(QIODevice *ioDevice)
|
||||||
|
: ioDevice(ioDevice),
|
||||||
|
commandCounter(0),
|
||||||
|
blockSize(0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void ReadCommandBlock::checkIfCommandIsLost(QDataStream &in)
|
||||||
|
{
|
||||||
|
qint64 currentCommandCounter;
|
||||||
|
|
||||||
|
in >> currentCommandCounter;
|
||||||
|
|
||||||
|
#ifndef DONT_CHECK_COMMAND_COUNTER
|
||||||
|
bool commandLost = !((currentCommandCounter == 0 && commandCounter == 0) || (commandCounter + 1 == currentCommandCounter));
|
||||||
|
if (commandLost)
|
||||||
|
qWarning() << "client command lost: " << commandCounter << currentCommandCounter;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
commandCounter = currentCommandCounter;
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant ReadCommandBlock::read()
|
||||||
|
{
|
||||||
|
QDataStream in(ioDevice);
|
||||||
|
|
||||||
|
QVariant command;
|
||||||
|
|
||||||
|
if (isTheWholeCommandReadable(in)) {
|
||||||
|
checkIfCommandIsLost(in);
|
||||||
|
in >> command;
|
||||||
|
}
|
||||||
|
|
||||||
|
return command;
|
||||||
|
}
|
||||||
|
|
||||||
|
QVector<QVariant> ReadCommandBlock::readAll()
|
||||||
|
{
|
||||||
|
QVector<QVariant> commands;
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
const QVariant command = read();
|
||||||
|
if (command.isValid())
|
||||||
|
commands.append(command);
|
||||||
|
else
|
||||||
|
return commands;
|
||||||
|
}
|
||||||
|
|
||||||
|
Q_UNREACHABLE();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ReadCommandBlock::resetCounter()
|
||||||
|
{
|
||||||
|
commandCounter = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ReadCommandBlock::isTheWholeCommandReadable(QDataStream &in)
|
||||||
|
{
|
||||||
|
const qint64 bytesAvailable = ioDevice->bytesAvailable();
|
||||||
|
|
||||||
|
if (bytesAvailable == 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (blockSize == 0)
|
||||||
|
in >> blockSize;
|
||||||
|
|
||||||
|
if (bytesAvailable < blockSize)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
blockSize = 0;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace CodeModelBackEnd
|
||||||
|
|
66
src/libs/codemodelbackendipc/readcommandblock.h
Normal file
66
src/libs/codemodelbackendipc/readcommandblock.h
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef CODEMODELBACKEND_READCOMMANDBLOCK_H
|
||||||
|
#define CODEMODELBACKEND_READCOMMANDBLOCK_H
|
||||||
|
|
||||||
|
#include <QtGlobal>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
class QVariant;
|
||||||
|
class QDataStream;
|
||||||
|
class QIODevice;
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
namespace CodeModelBackEnd {
|
||||||
|
|
||||||
|
class ReadCommandBlock
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ReadCommandBlock(QIODevice *ioDevice = nullptr);
|
||||||
|
|
||||||
|
QVariant read();
|
||||||
|
QVector<QVariant> readAll();
|
||||||
|
|
||||||
|
void resetCounter();
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool isTheWholeCommandReadable(QDataStream &in);
|
||||||
|
void checkIfCommandIsLost(QDataStream &in);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QIODevice *ioDevice;
|
||||||
|
qint64 commandCounter;
|
||||||
|
qint32 blockSize;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace CodeModelBackEnd
|
||||||
|
|
||||||
|
#endif // CODEMODELBACKEND_READCOMMANDBLOCK_H
|
@@ -0,0 +1,112 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "translationunitdoesnotexistcommand.h"
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
|
#include <QDataStream>
|
||||||
|
|
||||||
|
#include <ostream>
|
||||||
|
|
||||||
|
namespace CodeModelBackEnd {
|
||||||
|
|
||||||
|
TranslationUnitDoesNotExistCommand::TranslationUnitDoesNotExistCommand(const FileContainer &fileContainer)
|
||||||
|
: fileContainer_(fileContainer)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
TranslationUnitDoesNotExistCommand::TranslationUnitDoesNotExistCommand(const Utf8String &filePath, const Utf8String &projectPartId)
|
||||||
|
: fileContainer_(filePath, projectPartId)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
const FileContainer &TranslationUnitDoesNotExistCommand::fileContainer() const
|
||||||
|
{
|
||||||
|
return fileContainer_;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Utf8String &TranslationUnitDoesNotExistCommand::filePath() const
|
||||||
|
{
|
||||||
|
return fileContainer_.filePath();
|
||||||
|
}
|
||||||
|
|
||||||
|
const Utf8String &TranslationUnitDoesNotExistCommand::projectPartId() const
|
||||||
|
{
|
||||||
|
return fileContainer_.projectPartId();
|
||||||
|
}
|
||||||
|
|
||||||
|
QDataStream &operator<<(QDataStream &out, const TranslationUnitDoesNotExistCommand &command)
|
||||||
|
{
|
||||||
|
out << command.fileContainer_;
|
||||||
|
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDataStream &operator>>(QDataStream &in, TranslationUnitDoesNotExistCommand &command)
|
||||||
|
{
|
||||||
|
in >> command.fileContainer_;
|
||||||
|
|
||||||
|
return in;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator == (const TranslationUnitDoesNotExistCommand &first, const TranslationUnitDoesNotExistCommand &second)
|
||||||
|
{
|
||||||
|
return first.fileContainer_ == second.fileContainer_;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator < (const TranslationUnitDoesNotExistCommand &first, const TranslationUnitDoesNotExistCommand &second)
|
||||||
|
{
|
||||||
|
return first.fileContainer_ < second.fileContainer_;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDebug operator <<(QDebug debug, const TranslationUnitDoesNotExistCommand &command)
|
||||||
|
{
|
||||||
|
debug.nospace() << "TranslationUnitDoesNotExistCommand(";
|
||||||
|
|
||||||
|
debug.nospace() << command.fileContainer_;
|
||||||
|
|
||||||
|
debug.nospace() << ")";
|
||||||
|
|
||||||
|
return debug;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PrintTo(const TranslationUnitDoesNotExistCommand &command, ::std::ostream* os)
|
||||||
|
{
|
||||||
|
QString output;
|
||||||
|
QDebug debug(&output);
|
||||||
|
|
||||||
|
debug << command;
|
||||||
|
|
||||||
|
*os << output.toUtf8().constData();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace CodeModelBackEnd
|
||||||
|
|
@@ -0,0 +1,73 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef CODEMODELBACKEND_TRANSLATIONUNITDOESNOTEXISTSCOMMAND_H
|
||||||
|
#define CODEMODELBACKEND_TRANSLATIONUNITDOESNOTEXISTSCOMMAND_H
|
||||||
|
|
||||||
|
#include <QMetaType>
|
||||||
|
|
||||||
|
#include "filecontainer.h"
|
||||||
|
|
||||||
|
namespace CodeModelBackEnd {
|
||||||
|
|
||||||
|
class CMBIPC_EXPORT TranslationUnitDoesNotExistCommand
|
||||||
|
{
|
||||||
|
friend CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const TranslationUnitDoesNotExistCommand &command);
|
||||||
|
friend CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, TranslationUnitDoesNotExistCommand &command);
|
||||||
|
friend CMBIPC_EXPORT bool operator == (const TranslationUnitDoesNotExistCommand &first, const TranslationUnitDoesNotExistCommand &second);
|
||||||
|
friend CMBIPC_EXPORT bool operator < (const TranslationUnitDoesNotExistCommand &first, const TranslationUnitDoesNotExistCommand &second);
|
||||||
|
friend CMBIPC_EXPORT QDebug operator <<(QDebug debug, const TranslationUnitDoesNotExistCommand &command);
|
||||||
|
friend void PrintTo(const TranslationUnitDoesNotExistCommand &command, ::std::ostream* os);
|
||||||
|
public:
|
||||||
|
TranslationUnitDoesNotExistCommand() = default;
|
||||||
|
TranslationUnitDoesNotExistCommand(const FileContainer &fileContainer);
|
||||||
|
TranslationUnitDoesNotExistCommand(const Utf8String &filePath, const Utf8String &projectPartId);
|
||||||
|
|
||||||
|
const FileContainer &fileContainer() const;
|
||||||
|
const Utf8String &filePath() const;
|
||||||
|
const Utf8String &projectPartId() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
FileContainer fileContainer_;
|
||||||
|
};
|
||||||
|
|
||||||
|
CMBIPC_EXPORT QDataStream &operator<<(QDataStream &out, const TranslationUnitDoesNotExistCommand &command);
|
||||||
|
CMBIPC_EXPORT QDataStream &operator>>(QDataStream &in, TranslationUnitDoesNotExistCommand &command);
|
||||||
|
CMBIPC_EXPORT bool operator == (const TranslationUnitDoesNotExistCommand &first, const TranslationUnitDoesNotExistCommand &second);
|
||||||
|
CMBIPC_EXPORT bool operator < (const TranslationUnitDoesNotExistCommand &first, const TranslationUnitDoesNotExistCommand &second);
|
||||||
|
|
||||||
|
CMBIPC_EXPORT QDebug operator <<(QDebug debug, const TranslationUnitDoesNotExistCommand &command);
|
||||||
|
void PrintTo(const TranslationUnitDoesNotExistCommand &command, ::std::ostream* os);
|
||||||
|
|
||||||
|
} // namespace CodeModelBackEnd
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(CodeModelBackEnd::TranslationUnitDoesNotExistCommand)
|
||||||
|
|
||||||
|
#endif // CODEMODELBACKEND_TRANSLATIONUNITDOESNOTEXISTSCOMMAND_H
|
78
src/libs/codemodelbackendipc/writecommandblock.cpp
Normal file
78
src/libs/codemodelbackendipc/writecommandblock.cpp
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "writecommandblock.h"
|
||||||
|
|
||||||
|
#include <QDataStream>
|
||||||
|
#include <QIODevice>
|
||||||
|
#include <QVariant>
|
||||||
|
#include <QtDebug>
|
||||||
|
|
||||||
|
namespace CodeModelBackEnd {
|
||||||
|
|
||||||
|
WriteCommandBlock::WriteCommandBlock(QIODevice *ioDevice)
|
||||||
|
: commandCounter(0),
|
||||||
|
ioDevice(ioDevice)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void WriteCommandBlock::write(const QVariant &command)
|
||||||
|
{
|
||||||
|
QByteArray block;
|
||||||
|
QDataStream out(&block, QIODevice::WriteOnly);
|
||||||
|
|
||||||
|
const qint32 dummyBockSize = 0;
|
||||||
|
out << dummyBockSize;
|
||||||
|
|
||||||
|
out << commandCounter;
|
||||||
|
|
||||||
|
out << command;
|
||||||
|
|
||||||
|
out.device()->seek(0);
|
||||||
|
out << qint32(block.size());
|
||||||
|
|
||||||
|
++commandCounter;
|
||||||
|
|
||||||
|
ioDevice->write(block);
|
||||||
|
}
|
||||||
|
|
||||||
|
qint64 WriteCommandBlock::counter() const
|
||||||
|
{
|
||||||
|
return commandCounter;
|
||||||
|
}
|
||||||
|
|
||||||
|
void WriteCommandBlock::resetCounter()
|
||||||
|
{
|
||||||
|
commandCounter = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace CodeModelBackEnd
|
||||||
|
|
62
src/libs/codemodelbackendipc/writecommandblock.h
Normal file
62
src/libs/codemodelbackendipc/writecommandblock.h
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef CODEMODELBACKEND_WRITECOMMANDBLOCK_H
|
||||||
|
#define CODEMODELBACKEND_WRITECOMMANDBLOCK_H
|
||||||
|
|
||||||
|
#include <QtGlobal>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
class QVariant;
|
||||||
|
class QDataStream;
|
||||||
|
class QIODevice;
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
namespace CodeModelBackEnd {
|
||||||
|
|
||||||
|
class WriteCommandBlock
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
WriteCommandBlock(QIODevice *ioDevice = nullptr);
|
||||||
|
|
||||||
|
void write(const QVariant &command);
|
||||||
|
|
||||||
|
qint64 counter() const;
|
||||||
|
|
||||||
|
void resetCounter();
|
||||||
|
|
||||||
|
private:
|
||||||
|
qint64 commandCounter;
|
||||||
|
QIODevice *ioDevice;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace CodeModelBackEnd
|
||||||
|
|
||||||
|
#endif // CODEMODELBACKEND_WRITECOMMANDBLOCK_H
|
@@ -13,7 +13,9 @@ SUBDIRS = \
|
|||||||
qmleditorwidgets \
|
qmleditorwidgets \
|
||||||
glsl \
|
glsl \
|
||||||
ssh \
|
ssh \
|
||||||
timeline
|
timeline \
|
||||||
|
sqlite \
|
||||||
|
codemodelbackendipc
|
||||||
|
|
||||||
for(l, SUBDIRS) {
|
for(l, SUBDIRS) {
|
||||||
QTC_LIB_DEPENDS =
|
QTC_LIB_DEPENDS =
|
||||||
|
@@ -4,6 +4,7 @@ Project {
|
|||||||
name: "Libs"
|
name: "Libs"
|
||||||
references: [
|
references: [
|
||||||
"aggregation/aggregation.qbs",
|
"aggregation/aggregation.qbs",
|
||||||
|
"codemodelbackendipc/codemodelbackendipc.qbs",
|
||||||
"cplusplus/cplusplus.qbs",
|
"cplusplus/cplusplus.qbs",
|
||||||
"extensionsystem/extensionsystem.qbs",
|
"extensionsystem/extensionsystem.qbs",
|
||||||
"glsl/glsl.qbs",
|
"glsl/glsl.qbs",
|
||||||
@@ -12,6 +13,7 @@ Project {
|
|||||||
"qmljs/qmljs.qbs",
|
"qmljs/qmljs.qbs",
|
||||||
"qmldebug/qmldebug.qbs",
|
"qmldebug/qmldebug.qbs",
|
||||||
"qtcreatorcdbext/qtcreatorcdbext.qbs",
|
"qtcreatorcdbext/qtcreatorcdbext.qbs",
|
||||||
|
"sqlite/sqlite.qbs",
|
||||||
"ssh/ssh.qbs",
|
"ssh/ssh.qbs",
|
||||||
"timeline/timeline.qbs",
|
"timeline/timeline.qbs",
|
||||||
"utils/process_stub.qbs",
|
"utils/process_stub.qbs",
|
||||||
|
78
src/libs/sqlite/columndefinition.cpp
Normal file
78
src/libs/sqlite/columndefinition.cpp
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "columndefinition.h"
|
||||||
|
|
||||||
|
namespace Internal {
|
||||||
|
|
||||||
|
void ColumnDefinition::setName(const Utf8String &name)
|
||||||
|
{
|
||||||
|
name_ = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Utf8String &ColumnDefinition::name() const
|
||||||
|
{
|
||||||
|
return name_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ColumnDefinition::setType(ColumnType type)
|
||||||
|
{
|
||||||
|
type_ = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
ColumnType ColumnDefinition::type() const
|
||||||
|
{
|
||||||
|
return type_;
|
||||||
|
}
|
||||||
|
|
||||||
|
Utf8String ColumnDefinition::typeString() const
|
||||||
|
{
|
||||||
|
switch (type_) {
|
||||||
|
case ColumnType::None: return Utf8String();
|
||||||
|
case ColumnType::Numeric: return Utf8StringLiteral("NUMERIC");
|
||||||
|
case ColumnType::Integer: return Utf8StringLiteral("INTEGER");
|
||||||
|
case ColumnType::Real: return Utf8StringLiteral("REAL");
|
||||||
|
case ColumnType::Text: return Utf8StringLiteral("TEXT");
|
||||||
|
}
|
||||||
|
|
||||||
|
Q_UNREACHABLE();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ColumnDefinition::setIsPrimaryKey(bool isPrimaryKey)
|
||||||
|
{
|
||||||
|
isPrimaryKey_ = isPrimaryKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ColumnDefinition::isPrimaryKey() const
|
||||||
|
{
|
||||||
|
return isPrimaryKey_;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
60
src/libs/sqlite/columndefinition.h
Normal file
60
src/libs/sqlite/columndefinition.h
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef COLUMNDEFINITION_H
|
||||||
|
#define COLUMNDEFINITION_H
|
||||||
|
|
||||||
|
#include "sqliteglobal.h"
|
||||||
|
#include "utf8string.h"
|
||||||
|
|
||||||
|
namespace Internal {
|
||||||
|
|
||||||
|
class ColumnDefinition
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
void setName(const Utf8String &name);
|
||||||
|
const Utf8String &name() const;
|
||||||
|
|
||||||
|
void setType(ColumnType type);
|
||||||
|
ColumnType type() const;
|
||||||
|
Utf8String typeString() const;
|
||||||
|
|
||||||
|
void setIsPrimaryKey(bool isPrimaryKey);
|
||||||
|
bool isPrimaryKey() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
Utf8String name_;
|
||||||
|
ColumnType type_;
|
||||||
|
bool isPrimaryKey_ = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // COLUMNDEFINITION_H
|
41
src/libs/sqlite/createtablecommand.cpp
Normal file
41
src/libs/sqlite/createtablecommand.cpp
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "createtablecommand.h"
|
||||||
|
|
||||||
|
namespace Internal {
|
||||||
|
|
||||||
|
void CreateTableCommand::registerType()
|
||||||
|
{
|
||||||
|
qRegisterMetaType<CreateTableCommand>("CreateTableCommand");
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Internal
|
||||||
|
|
57
src/libs/sqlite/createtablecommand.h
Normal file
57
src/libs/sqlite/createtablecommand.h
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef INTERNAL_CREATETABLECOMMAND_H
|
||||||
|
#define INTERNAL_CREATETABLECOMMAND_H
|
||||||
|
|
||||||
|
#include <QMetaType>
|
||||||
|
#include <QVector>
|
||||||
|
|
||||||
|
#include "utf8string.h"
|
||||||
|
#include "columndefinition.h"
|
||||||
|
|
||||||
|
namespace Internal {
|
||||||
|
|
||||||
|
class CreateTableCommand
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
QVector<ColumnDefinition> definitions;
|
||||||
|
Utf8String tableName;
|
||||||
|
bool useWithoutRowId;
|
||||||
|
|
||||||
|
static void registerType();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Internal
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(Internal::CreateTableCommand)
|
||||||
|
|
||||||
|
#endif // INTERNAL_CREATETABLECOMMAND_H
|
131
src/libs/sqlite/createtablesqlstatementbuilder.cpp
Normal file
131
src/libs/sqlite/createtablesqlstatementbuilder.cpp
Normal file
@@ -0,0 +1,131 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "createtablesqlstatementbuilder.h"
|
||||||
|
|
||||||
|
#include "utf8stringvector.h"
|
||||||
|
|
||||||
|
namespace Internal {
|
||||||
|
|
||||||
|
CreateTableSqlStatementBuilder::CreateTableSqlStatementBuilder()
|
||||||
|
: sqlStatementBuilder(Utf8StringLiteral("CREATE TABLE IF NOT EXISTS $table($columnDefinitions)$withoutRowId")),
|
||||||
|
useWithoutRowId(false)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void CreateTableSqlStatementBuilder::setTable(const Utf8String &tableName)
|
||||||
|
{
|
||||||
|
sqlStatementBuilder.clear();
|
||||||
|
|
||||||
|
this->tableName = tableName;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CreateTableSqlStatementBuilder::addColumnDefinition(const Utf8String &columnName,
|
||||||
|
ColumnType columnType,
|
||||||
|
bool isPrimaryKey)
|
||||||
|
{
|
||||||
|
sqlStatementBuilder.clear();
|
||||||
|
|
||||||
|
ColumnDefinition columnDefinition;
|
||||||
|
columnDefinition.setName(columnName);
|
||||||
|
columnDefinition.setType(columnType);
|
||||||
|
columnDefinition.setIsPrimaryKey(isPrimaryKey);
|
||||||
|
|
||||||
|
columnDefinitions.append(columnDefinition);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CreateTableSqlStatementBuilder::setColumnDefinitions(const QVector<ColumnDefinition> &columnDefinitions)
|
||||||
|
{
|
||||||
|
sqlStatementBuilder.clear();
|
||||||
|
|
||||||
|
this->columnDefinitions = columnDefinitions;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CreateTableSqlStatementBuilder::setUseWithoutRowId(bool useWithoutRowId)
|
||||||
|
{
|
||||||
|
this->useWithoutRowId = useWithoutRowId;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CreateTableSqlStatementBuilder::clear()
|
||||||
|
{
|
||||||
|
sqlStatementBuilder.clear();
|
||||||
|
columnDefinitions.clear();
|
||||||
|
tableName.clear();
|
||||||
|
useWithoutRowId = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CreateTableSqlStatementBuilder::clearColumns()
|
||||||
|
{
|
||||||
|
sqlStatementBuilder.clear();
|
||||||
|
columnDefinitions.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
Utf8String CreateTableSqlStatementBuilder::sqlStatement() const
|
||||||
|
{
|
||||||
|
if (!sqlStatementBuilder.isBuild())
|
||||||
|
bindAll();
|
||||||
|
|
||||||
|
return sqlStatementBuilder.sqlStatement();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CreateTableSqlStatementBuilder::isValid() const
|
||||||
|
{
|
||||||
|
return tableName.hasContent() && !columnDefinitions.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CreateTableSqlStatementBuilder::bindColumnDefinitions() const
|
||||||
|
{
|
||||||
|
Utf8StringVector columnDefinitionStrings;
|
||||||
|
|
||||||
|
foreach (const ColumnDefinition &columnDefinition, columnDefinitions) {
|
||||||
|
Utf8String columnDefinitionString = columnDefinition.name() + Utf8StringLiteral(" ") + columnDefinition.typeString();
|
||||||
|
|
||||||
|
if (columnDefinition.isPrimaryKey())
|
||||||
|
columnDefinitionString.append(Utf8StringLiteral(" PRIMARY KEY"));
|
||||||
|
|
||||||
|
columnDefinitionStrings.append(columnDefinitionString);
|
||||||
|
}
|
||||||
|
|
||||||
|
sqlStatementBuilder.bind(Utf8StringLiteral("$columnDefinitions"), columnDefinitionStrings);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CreateTableSqlStatementBuilder::bindAll() const
|
||||||
|
{
|
||||||
|
sqlStatementBuilder.bind(Utf8StringLiteral("$table"), tableName);
|
||||||
|
|
||||||
|
bindColumnDefinitions();
|
||||||
|
|
||||||
|
if (useWithoutRowId)
|
||||||
|
sqlStatementBuilder.bind(Utf8StringLiteral("$withoutRowId"), Utf8StringLiteral(" WITHOUT ROWID"));
|
||||||
|
else
|
||||||
|
sqlStatementBuilder.bindEmptyText(Utf8StringLiteral("$withoutRowId"));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
72
src/libs/sqlite/createtablesqlstatementbuilder.h
Normal file
72
src/libs/sqlite/createtablesqlstatementbuilder.h
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef CREATETABLESQLSTATEMENTBUILDER_H
|
||||||
|
#define CREATETABLESQLSTATEMENTBUILDER_H
|
||||||
|
|
||||||
|
#include <QVector>
|
||||||
|
|
||||||
|
#include "sqlstatementbuilder.h"
|
||||||
|
|
||||||
|
#include "columndefinition.h"
|
||||||
|
|
||||||
|
namespace Internal {
|
||||||
|
|
||||||
|
class SQLITE_EXPORT CreateTableSqlStatementBuilder
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CreateTableSqlStatementBuilder();
|
||||||
|
|
||||||
|
void setTable(const Utf8String &tableName);
|
||||||
|
void addColumnDefinition(const Utf8String &columnName, ColumnType columnType, bool isPrimaryKey = false);
|
||||||
|
void setColumnDefinitions(const QVector<ColumnDefinition> & columnDefinitions);
|
||||||
|
void setUseWithoutRowId(bool useWithoutRowId);
|
||||||
|
|
||||||
|
void clear();
|
||||||
|
void clearColumns();
|
||||||
|
|
||||||
|
Utf8String sqlStatement() const;
|
||||||
|
|
||||||
|
bool isValid() const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void bindColumnDefinitions() const;
|
||||||
|
void bindAll() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
mutable SqlStatementBuilder sqlStatementBuilder;
|
||||||
|
Utf8String tableName;
|
||||||
|
QVector<ColumnDefinition> columnDefinitions;
|
||||||
|
bool useWithoutRowId;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // CREATETABLESQLSTATEMENTBUILDER_H
|
64
src/libs/sqlite/sqlite-lib.pri
Normal file
64
src/libs/sqlite/sqlite-lib.pri
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
contains(CONFIG, dll) {
|
||||||
|
DEFINES += BUILD_SQLITE_LIBRARY
|
||||||
|
} else {
|
||||||
|
DEFINES += BUILD_SQLITE_STATIC_LIBRARY
|
||||||
|
}
|
||||||
|
|
||||||
|
INCLUDEPATH += $$PWD
|
||||||
|
|
||||||
|
unix:LIBS += -ldl
|
||||||
|
|
||||||
|
include(../3rdparty/sqlite/sqlite.pri)
|
||||||
|
|
||||||
|
SOURCES += \
|
||||||
|
$$PWD/columndefinition.cpp \
|
||||||
|
$$PWD/createtablecommand.cpp \
|
||||||
|
$$PWD/createtablesqlstatementbuilder.cpp \
|
||||||
|
$$PWD/sqlitedatabasebackend.cpp \
|
||||||
|
$$PWD/sqlitedatabaseconnection.cpp \
|
||||||
|
$$PWD/sqlitedatabaseconnectionproxy.cpp \
|
||||||
|
$$PWD/sqliteexception.cpp \
|
||||||
|
$$PWD/sqliteglobal.cpp \
|
||||||
|
$$PWD/sqlitereadstatement.cpp \
|
||||||
|
$$PWD/sqlitereadwritestatement.cpp \
|
||||||
|
$$PWD/sqlitestatement.cpp \
|
||||||
|
$$PWD/sqlitetransaction.cpp \
|
||||||
|
$$PWD/sqliteworkerthread.cpp \
|
||||||
|
$$PWD/sqlitewritestatement.cpp \
|
||||||
|
$$PWD/sqlstatementbuilder.cpp \
|
||||||
|
$$PWD/sqlstatementbuilderexception.cpp \
|
||||||
|
$$PWD/utf8string.cpp \
|
||||||
|
$$PWD/utf8stringvector.cpp \
|
||||||
|
$$PWD/sqlitedatabase.cpp \
|
||||||
|
$$PWD/sqlitetable.cpp \
|
||||||
|
$$PWD/sqlitecolumn.cpp \
|
||||||
|
$$PWD/tablewriteworker.cpp \
|
||||||
|
$$PWD/tablewriteworkerproxy.cpp
|
||||||
|
HEADERS += \
|
||||||
|
$$PWD/columndefinition.h \
|
||||||
|
$$PWD/createtablesqlstatementbuilder.h \
|
||||||
|
$$PWD/sqlitedatabasebackend.h \
|
||||||
|
$$PWD/sqlitedatabaseconnection.h \
|
||||||
|
$$PWD/sqlitedatabaseconnectionproxy.h \
|
||||||
|
$$PWD/sqliteexception.h \
|
||||||
|
$$PWD/sqliteglobal.h \
|
||||||
|
$$PWD/sqlitereadstatement.h \
|
||||||
|
$$PWD/sqlitereadwritestatement.h \
|
||||||
|
$$PWD/sqlitestatement.h \
|
||||||
|
$$PWD/sqlitetransaction.h \
|
||||||
|
$$PWD/sqliteworkerthread.h \
|
||||||
|
$$PWD/sqlitewritestatement.h \
|
||||||
|
$$PWD/sqlstatementbuilder.h \
|
||||||
|
$$PWD/sqlstatementbuilderexception.h \
|
||||||
|
$$PWD/utf8string.h \
|
||||||
|
$$PWD/utf8stringvector.h \
|
||||||
|
$$PWD/sqlitedatabase.h \
|
||||||
|
$$PWD/sqlitetable.h \
|
||||||
|
$$PWD/sqlitecolumn.h \
|
||||||
|
$$PWD/tablewriteworker.h \
|
||||||
|
$$PWD/tablewriteworkerproxy.h \
|
||||||
|
$$PWD/createtablecommand.h
|
||||||
|
|
||||||
|
DEFINES += SQLITE_THREADSAFE=2 SQLITE_ENABLE_FTS4 SQLITE_ENABLE_FTS3_PARENTHESIS SQLITE_ENABLE_UNLOCK_NOTIFY SQLITE_ENABLE_COLUMN_METADATA
|
||||||
|
|
||||||
|
contains(QT_CONFIG, reduce_exports):CONFIG += hide_symbols
|
53
src/libs/sqlite/sqlite-source.pri
Normal file
53
src/libs/sqlite/sqlite-source.pri
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
INCLUDEPATH += $$PWD
|
||||||
|
VPATH += $$PWD
|
||||||
|
|
||||||
|
SOURCES += \
|
||||||
|
columndefinition.cpp \
|
||||||
|
createtablecommand.cpp \
|
||||||
|
createtablesqlstatementbuilder.cpp \
|
||||||
|
sqlitedatabasebackend.cpp \
|
||||||
|
sqlitedatabaseconnection.cpp \
|
||||||
|
sqlitedatabaseconnectionproxy.cpp \
|
||||||
|
sqliteexception.cpp \
|
||||||
|
sqliteglobal.cpp \
|
||||||
|
sqlitereadstatement.cpp \
|
||||||
|
sqlitereadwritestatement.cpp \
|
||||||
|
sqlitestatement.cpp \
|
||||||
|
sqlitetransaction.cpp \
|
||||||
|
sqliteworkerthread.cpp \
|
||||||
|
sqlitewritestatement.cpp \
|
||||||
|
sqlstatementbuilder.cpp \
|
||||||
|
sqlstatementbuilderexception.cpp \
|
||||||
|
utf8string.cpp \
|
||||||
|
utf8stringvector.cpp \
|
||||||
|
sqlitedatabase.cpp \
|
||||||
|
sqlitetable.cpp \
|
||||||
|
sqlitecolumn.cpp \
|
||||||
|
tablewriteworker.cpp \
|
||||||
|
tablewriteworkerproxy.cpp
|
||||||
|
HEADERS += \
|
||||||
|
columndefinition.h \
|
||||||
|
createtablesqlstatementbuilder.h \
|
||||||
|
sqlitedatabasebackend.h \
|
||||||
|
sqlitedatabaseconnection.h \
|
||||||
|
sqlitedatabaseconnectionproxy.h \
|
||||||
|
sqliteexception.h \
|
||||||
|
sqliteglobal.h \
|
||||||
|
sqlitereadstatement.h \
|
||||||
|
sqlitereadwritestatement.h \
|
||||||
|
sqlitestatement.h \
|
||||||
|
sqlitetransaction.h \
|
||||||
|
sqliteworkerthread.h \
|
||||||
|
sqlitewritestatement.h \
|
||||||
|
sqlstatementbuilder.h \
|
||||||
|
sqlstatementbuilderexception.h \
|
||||||
|
utf8string.h \
|
||||||
|
utf8stringvector.h \
|
||||||
|
sqlitedatabase.h \
|
||||||
|
sqlitetable.h \
|
||||||
|
sqlitecolumn.h \
|
||||||
|
tablewriteworker.h \
|
||||||
|
tablewriteworkerproxy.h \
|
||||||
|
createtablecommand.h
|
||||||
|
|
||||||
|
|
5
src/libs/sqlite/sqlite.pro
Normal file
5
src/libs/sqlite/sqlite.pro
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
unix:QMAKE_CXXFLAGS_DEBUG += -O2
|
||||||
|
win32:QMAKE_CXXFLAGS_DEBUG += -O2
|
||||||
|
|
||||||
|
include(../../qtcreatorlibrary.pri)
|
||||||
|
include(sqlite-lib.pri)
|
42
src/libs/sqlite/sqlite.qbs
Normal file
42
src/libs/sqlite/sqlite.qbs
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
import qbs 1.0
|
||||||
|
|
||||||
|
QtcLibrary {
|
||||||
|
name: "Sqlite"
|
||||||
|
|
||||||
|
cpp.includePaths: base.concat(["../3rdparty/sqlite", "."])
|
||||||
|
cpp.defines: base.concat([
|
||||||
|
"BUILD_SQLITE_LIBRARY",
|
||||||
|
"SQLITE_THREADSAFE=2",
|
||||||
|
"SQLITE_ENABLE_FTS4",
|
||||||
|
"SQLITE_ENABLE_FTS3_PARENTHESIS",
|
||||||
|
"SQLITE_ENABLE_UNLOCK_NOTIFY",
|
||||||
|
"SQLITE_ENABLE_COLUMN_METADATA"
|
||||||
|
])
|
||||||
|
cpp.optimization: "fast"
|
||||||
|
cpp.dynamicLibraries: base.concat("dl")
|
||||||
|
|
||||||
|
|
||||||
|
Group {
|
||||||
|
name: "ThirdPartySqlite"
|
||||||
|
prefix: "../3rdparty/sqlite/"
|
||||||
|
files: [
|
||||||
|
"sqlite3.c",
|
||||||
|
"sqlite3.h",
|
||||||
|
"sqlite3ext.h",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
Group {
|
||||||
|
files: [
|
||||||
|
"*.h",
|
||||||
|
"*.cpp"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
Export {
|
||||||
|
cpp.includePaths: base.concat([
|
||||||
|
"../3rdparty/sqlite",
|
||||||
|
"."
|
||||||
|
])
|
||||||
|
}
|
||||||
|
}
|
3
src/libs/sqlite/sqlite_dependencies.pri
Normal file
3
src/libs/sqlite/sqlite_dependencies.pri
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
QTC_LIB_NAME = Sqlite
|
||||||
|
INCLUDEPATH *= $$IDE_SOURCE_TREE/src/libs/3rdparty/sqlite
|
||||||
|
INCLUDEPATH *= $$IDE_SOURCE_TREE/src/libs/sqlite
|
86
src/libs/sqlite/sqlitecolumn.cpp
Normal file
86
src/libs/sqlite/sqlitecolumn.cpp
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "sqlitecolumn.h"
|
||||||
|
|
||||||
|
SqliteColumn::SqliteColumn()
|
||||||
|
: type_(ColumnType::Numeric),
|
||||||
|
isPrimaryKey_(false)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void SqliteColumn::clear()
|
||||||
|
{
|
||||||
|
name_.clear();
|
||||||
|
type_ = ColumnType::Numeric;
|
||||||
|
isPrimaryKey_ = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SqliteColumn::setName(const Utf8String &newName)
|
||||||
|
{
|
||||||
|
name_ = newName;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Utf8String &SqliteColumn::name() const
|
||||||
|
{
|
||||||
|
return name_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SqliteColumn::setType(ColumnType newType)
|
||||||
|
{
|
||||||
|
type_ = newType;
|
||||||
|
}
|
||||||
|
|
||||||
|
ColumnType SqliteColumn::type() const
|
||||||
|
{
|
||||||
|
return type_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SqliteColumn::setIsPrimaryKey(bool isPrimaryKey)
|
||||||
|
{
|
||||||
|
isPrimaryKey_ = isPrimaryKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SqliteColumn::isPrimaryKey() const
|
||||||
|
{
|
||||||
|
return isPrimaryKey_;
|
||||||
|
}
|
||||||
|
|
||||||
|
Internal::ColumnDefinition SqliteColumn::columnDefintion() const
|
||||||
|
{
|
||||||
|
Internal::ColumnDefinition columnDefinition;
|
||||||
|
|
||||||
|
columnDefinition.setName(name_);
|
||||||
|
columnDefinition.setType(type_);
|
||||||
|
columnDefinition.setIsPrimaryKey(isPrimaryKey_);
|
||||||
|
|
||||||
|
return columnDefinition;
|
||||||
|
}
|
64
src/libs/sqlite/sqlitecolumn.h
Normal file
64
src/libs/sqlite/sqlitecolumn.h
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef SQLITECOLUMN_H
|
||||||
|
#define SQLITECOLUMN_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
#include "utf8string.h"
|
||||||
|
#include "columndefinition.h"
|
||||||
|
|
||||||
|
class SQLITE_EXPORT SqliteColumn : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
SqliteColumn();
|
||||||
|
|
||||||
|
void clear();
|
||||||
|
|
||||||
|
void setName(const Utf8String &newName);
|
||||||
|
const Utf8String &name() const;
|
||||||
|
|
||||||
|
void setType(ColumnType newType);
|
||||||
|
ColumnType type() const;
|
||||||
|
|
||||||
|
void setIsPrimaryKey(bool isPrimaryKey);
|
||||||
|
bool isPrimaryKey() const;
|
||||||
|
|
||||||
|
Internal::ColumnDefinition columnDefintion() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
Utf8String name_;
|
||||||
|
ColumnType type_;
|
||||||
|
bool isPrimaryKey_;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SQLITECOLUMN_H
|
146
src/libs/sqlite/sqlitedatabase.cpp
Normal file
146
src/libs/sqlite/sqlitedatabase.cpp
Normal file
@@ -0,0 +1,146 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "sqlitedatabase.h"
|
||||||
|
|
||||||
|
#include "sqlitetable.h"
|
||||||
|
|
||||||
|
SqliteDatabase::SqliteDatabase()
|
||||||
|
: readDatabaseConnection(QStringLiteral("ReadWorker")),
|
||||||
|
writeDatabaseConnection(QStringLiteral("WriterWorker")),
|
||||||
|
journalMode_(JournalMode::Wal)
|
||||||
|
{
|
||||||
|
connect(&readDatabaseConnection, &SqliteDatabaseConnectionProxy::connectionIsOpened, this, &SqliteDatabase::handleReadDatabaseConnectionIsOpened);
|
||||||
|
connect(&writeDatabaseConnection, &SqliteDatabaseConnectionProxy::connectionIsOpened, this, &SqliteDatabase::handleWriteDatabaseConnectionIsOpened);
|
||||||
|
connect(&readDatabaseConnection, &SqliteDatabaseConnectionProxy::connectionIsClosed, this, &SqliteDatabase::handleReadDatabaseConnectionIsClosed);
|
||||||
|
connect(&writeDatabaseConnection, &SqliteDatabaseConnectionProxy::connectionIsClosed, this, &SqliteDatabase::handleWriteDatabaseConnectionIsClosed);
|
||||||
|
}
|
||||||
|
|
||||||
|
SqliteDatabase::~SqliteDatabase()
|
||||||
|
{
|
||||||
|
qDeleteAll(sqliteTables);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SqliteDatabase::open()
|
||||||
|
{
|
||||||
|
writeDatabaseConnection.setDatabaseFilePath(databaseFilePath());
|
||||||
|
writeDatabaseConnection.setJournalMode(journalMode());
|
||||||
|
}
|
||||||
|
|
||||||
|
void SqliteDatabase::close()
|
||||||
|
{
|
||||||
|
writeDatabaseConnection.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SqliteDatabase::isOpen() const
|
||||||
|
{
|
||||||
|
return readDatabaseConnection.isOpen() && writeDatabaseConnection.isOpen();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SqliteDatabase::addTable(SqliteTable *newSqliteTable)
|
||||||
|
{
|
||||||
|
newSqliteTable->setSqliteDatabase(this);
|
||||||
|
sqliteTables.append(newSqliteTable);
|
||||||
|
}
|
||||||
|
|
||||||
|
const QVector<SqliteTable *> &SqliteDatabase::tables() const
|
||||||
|
{
|
||||||
|
return sqliteTables;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SqliteDatabase::setDatabaseFilePath(const QString &databaseFilePath)
|
||||||
|
{
|
||||||
|
databaseFilePath_ = databaseFilePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString &SqliteDatabase::databaseFilePath() const
|
||||||
|
{
|
||||||
|
return databaseFilePath_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SqliteDatabase::setJournalMode(JournalMode journalMode)
|
||||||
|
{
|
||||||
|
journalMode_ = journalMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
JournalMode SqliteDatabase::journalMode() const
|
||||||
|
{
|
||||||
|
return journalMode_;
|
||||||
|
}
|
||||||
|
|
||||||
|
QThread *SqliteDatabase::writeWorkerThread() const
|
||||||
|
{
|
||||||
|
return writeDatabaseConnection.connectionThread();
|
||||||
|
}
|
||||||
|
|
||||||
|
QThread *SqliteDatabase::readWorkerThread() const
|
||||||
|
{
|
||||||
|
return readDatabaseConnection.connectionThread();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SqliteDatabase::handleReadDatabaseConnectionIsOpened()
|
||||||
|
{
|
||||||
|
if (writeDatabaseConnection.isOpen() && readDatabaseConnection.isOpen()) {
|
||||||
|
initializeTables();
|
||||||
|
emit databaseIsOpened();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SqliteDatabase::handleWriteDatabaseConnectionIsOpened()
|
||||||
|
{
|
||||||
|
readDatabaseConnection.setDatabaseFilePath(databaseFilePath());
|
||||||
|
}
|
||||||
|
|
||||||
|
void SqliteDatabase::handleReadDatabaseConnectionIsClosed()
|
||||||
|
{
|
||||||
|
if (!writeDatabaseConnection.isOpen() && !readDatabaseConnection.isOpen()) {
|
||||||
|
shutdownTables();
|
||||||
|
emit databaseIsClosed();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SqliteDatabase::handleWriteDatabaseConnectionIsClosed()
|
||||||
|
{
|
||||||
|
readDatabaseConnection.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SqliteDatabase::initializeTables()
|
||||||
|
{
|
||||||
|
for (SqliteTable *table: tables())
|
||||||
|
table->initialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SqliteDatabase::shutdownTables()
|
||||||
|
{
|
||||||
|
for (SqliteTable *table: tables())
|
||||||
|
table->shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
87
src/libs/sqlite/sqlitedatabase.h
Normal file
87
src/libs/sqlite/sqlitedatabase.h
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef SQLITEDATABASE_H
|
||||||
|
#define SQLITEDATABASE_H
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
#include <QVector>
|
||||||
|
|
||||||
|
#include "sqliteglobal.h"
|
||||||
|
#include "sqlitedatabaseconnectionproxy.h"
|
||||||
|
|
||||||
|
class SqliteTable;
|
||||||
|
|
||||||
|
class SQLITE_EXPORT SqliteDatabase : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
SqliteDatabase();
|
||||||
|
~SqliteDatabase();
|
||||||
|
|
||||||
|
void open();
|
||||||
|
void close();
|
||||||
|
|
||||||
|
bool isOpen() const;
|
||||||
|
|
||||||
|
void addTable(SqliteTable *newSqliteTable);
|
||||||
|
const QVector<SqliteTable *> &tables() const;
|
||||||
|
|
||||||
|
void setDatabaseFilePath(const QString &databaseFilePath);
|
||||||
|
const QString &databaseFilePath() const;
|
||||||
|
|
||||||
|
void setJournalMode(JournalMode journalMode);
|
||||||
|
JournalMode journalMode() const;
|
||||||
|
|
||||||
|
QThread *writeWorkerThread() const;
|
||||||
|
QThread *readWorkerThread() const;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void databaseIsOpened();
|
||||||
|
void databaseIsClosed();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void handleReadDatabaseConnectionIsOpened();
|
||||||
|
void handleWriteDatabaseConnectionIsOpened();
|
||||||
|
void handleReadDatabaseConnectionIsClosed();
|
||||||
|
void handleWriteDatabaseConnectionIsClosed();
|
||||||
|
void initializeTables();
|
||||||
|
void shutdownTables();
|
||||||
|
|
||||||
|
private:
|
||||||
|
SqliteDatabaseConnectionProxy readDatabaseConnection;
|
||||||
|
SqliteDatabaseConnectionProxy writeDatabaseConnection;
|
||||||
|
QVector<SqliteTable*> sqliteTables;
|
||||||
|
QString databaseFilePath_;
|
||||||
|
JournalMode journalMode_;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SQLITEDATABASE_H
|
397
src/libs/sqlite/sqlitedatabasebackend.cpp
Normal file
397
src/libs/sqlite/sqlitedatabasebackend.cpp
Normal file
@@ -0,0 +1,397 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "sqlitedatabasebackend.h"
|
||||||
|
|
||||||
|
#include <QThread>
|
||||||
|
#include <QtDebug>
|
||||||
|
|
||||||
|
#include "sqlite3.h"
|
||||||
|
|
||||||
|
#include "okapi_bm25.h"
|
||||||
|
|
||||||
|
#include "sqliteexception.h"
|
||||||
|
#include "sqlitestatement.h"
|
||||||
|
#include "sqlitereadstatement.h"
|
||||||
|
#include "sqlitewritestatement.h"
|
||||||
|
#include "sqlitereadwritestatement.h"
|
||||||
|
|
||||||
|
#if defined(Q_OS_UNIX)
|
||||||
|
#define QTC_THREAD_LOCAL __thread
|
||||||
|
#elif defined(Q_OS_WIN)
|
||||||
|
#define QTC_THREAD_LOCAL __declspec(thread)
|
||||||
|
#else
|
||||||
|
#define static QTC_THREAD_LOCAL thread_local
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define SIZE_OF_BYTEARRAY_ARRAY(array) sizeof(array)/sizeof(QByteArray)
|
||||||
|
|
||||||
|
QTC_THREAD_LOCAL SqliteDatabaseBackend *sqliteDatabaseBackend = nullptr;
|
||||||
|
|
||||||
|
SqliteDatabaseBackend::SqliteDatabaseBackend()
|
||||||
|
: databaseHandle(nullptr),
|
||||||
|
cachedTextEncoding(Utf8)
|
||||||
|
{
|
||||||
|
sqliteDatabaseBackend = this;
|
||||||
|
}
|
||||||
|
|
||||||
|
SqliteDatabaseBackend::~SqliteDatabaseBackend()
|
||||||
|
{
|
||||||
|
closeWithoutException();
|
||||||
|
sqliteDatabaseBackend = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SqliteDatabaseBackend::setMmapSize(qint64 defaultSize, qint64 maximumSize)
|
||||||
|
{
|
||||||
|
int resultCode = sqlite3_config(SQLITE_CONFIG_MMAP_SIZE, defaultSize, maximumSize);
|
||||||
|
checkMmapSizeIsSet(resultCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SqliteDatabaseBackend::activateMultiThreading()
|
||||||
|
{
|
||||||
|
int resultCode = sqlite3_config(SQLITE_CONFIG_MULTITHREAD);
|
||||||
|
checkIfMultithreadingIsActivated(resultCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void sqliteLog(void*,int errorCode,const char *errorMessage)
|
||||||
|
{
|
||||||
|
qWarning() << sqlite3_errstr(errorCode) << errorMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SqliteDatabaseBackend::activateLogging()
|
||||||
|
{
|
||||||
|
int resultCode = sqlite3_config(SQLITE_CONFIG_LOG, sqliteLog, nullptr);
|
||||||
|
checkIfLoogingIsActivated(resultCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SqliteDatabaseBackend::initializeSqliteLibrary()
|
||||||
|
{
|
||||||
|
int resultCode = sqlite3_initialize();
|
||||||
|
checkInitializeSqliteLibraryWasSuccesful(resultCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SqliteDatabaseBackend::shutdownSqliteLibrary()
|
||||||
|
{
|
||||||
|
int resultCode = sqlite3_shutdown();
|
||||||
|
checkShutdownSqliteLibraryWasSuccesful(resultCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SqliteDatabaseBackend::checkpointFullWalLog()
|
||||||
|
{
|
||||||
|
int resultCode = sqlite3_wal_checkpoint_v2(sqliteDatabaseHandle(), nullptr, SQLITE_CHECKPOINT_FULL, nullptr, nullptr);
|
||||||
|
checkIfLogCouldBeCheckpointed(resultCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SqliteDatabaseBackend::open(const QString &databaseFilePath)
|
||||||
|
{
|
||||||
|
checkCanOpenDatabase(databaseFilePath);
|
||||||
|
|
||||||
|
QByteArray databaseUtf8Path = databaseFilePath.toUtf8();
|
||||||
|
int resultCode = sqlite3_open_v2(databaseUtf8Path.data(),
|
||||||
|
&databaseHandle,
|
||||||
|
SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
checkDatabaseCouldBeOpened(resultCode);
|
||||||
|
|
||||||
|
registerBusyHandler();
|
||||||
|
registerRankingFunction();
|
||||||
|
cacheTextEncoding();
|
||||||
|
}
|
||||||
|
|
||||||
|
sqlite3 *SqliteDatabaseBackend::sqliteDatabaseHandle()
|
||||||
|
{
|
||||||
|
checkDatabaseBackendIsNotNull();
|
||||||
|
checkDatabaseHandleIsNotNull();
|
||||||
|
return threadLocalInstance()->databaseHandle;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SqliteDatabaseBackend::setPragmaValue(const Utf8String &pragmaKey, const Utf8String &newPragmaValue)
|
||||||
|
{
|
||||||
|
SqliteReadWriteStatement::execute(Utf8StringLiteral("PRAGMA ") + pragmaKey + Utf8StringLiteral("='") + newPragmaValue + Utf8StringLiteral("'"));
|
||||||
|
Utf8String pragmeValueInDatabase = SqliteReadWriteStatement::toValue<Utf8String>(Utf8StringLiteral("PRAGMA ") + pragmaKey);
|
||||||
|
|
||||||
|
checkPragmaValue(pragmeValueInDatabase, newPragmaValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
Utf8String SqliteDatabaseBackend::pragmaValue(const Utf8String &pragma) const
|
||||||
|
{
|
||||||
|
return SqliteReadWriteStatement::toValue<Utf8String>(Utf8StringLiteral("PRAGMA ") + pragma);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SqliteDatabaseBackend::setJournalMode(JournalMode journalMode)
|
||||||
|
{
|
||||||
|
setPragmaValue(Utf8StringLiteral("journal_mode"), journalModeToPragma(journalMode));
|
||||||
|
}
|
||||||
|
|
||||||
|
JournalMode SqliteDatabaseBackend::journalMode() const
|
||||||
|
{
|
||||||
|
return pragmaToJournalMode(pragmaValue(Utf8StringLiteral("journal_mode")));
|
||||||
|
}
|
||||||
|
|
||||||
|
void SqliteDatabaseBackend::setTextEncoding(TextEncoding textEncoding)
|
||||||
|
{
|
||||||
|
setPragmaValue(Utf8StringLiteral("encoding"), textEncodingToPragma(textEncoding));
|
||||||
|
cacheTextEncoding();
|
||||||
|
}
|
||||||
|
|
||||||
|
TextEncoding SqliteDatabaseBackend::textEncoding()
|
||||||
|
{
|
||||||
|
return cachedTextEncoding;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Utf8StringVector SqliteDatabaseBackend::columnNames(const Utf8String &tableName)
|
||||||
|
{
|
||||||
|
SqliteReadStatement statement(Utf8StringLiteral("SELECT * FROM ") + tableName);
|
||||||
|
return statement.columnNames();
|
||||||
|
}
|
||||||
|
|
||||||
|
int SqliteDatabaseBackend::changesCount()
|
||||||
|
{
|
||||||
|
return sqlite3_changes(sqliteDatabaseHandle());
|
||||||
|
}
|
||||||
|
|
||||||
|
int SqliteDatabaseBackend::totalChangesCount()
|
||||||
|
{
|
||||||
|
return sqlite3_total_changes(sqliteDatabaseHandle());
|
||||||
|
}
|
||||||
|
|
||||||
|
void SqliteDatabaseBackend::close()
|
||||||
|
{
|
||||||
|
checkForOpenDatabaseWhichCanBeClosed();
|
||||||
|
|
||||||
|
int resultCode = sqlite3_close(databaseHandle);
|
||||||
|
|
||||||
|
checkDatabaseClosing(resultCode);
|
||||||
|
|
||||||
|
databaseHandle = nullptr;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
SqliteDatabaseBackend *SqliteDatabaseBackend::threadLocalInstance()
|
||||||
|
{
|
||||||
|
checkDatabaseBackendIsNotNull();
|
||||||
|
return sqliteDatabaseBackend;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SqliteDatabaseBackend::databaseIsOpen() const
|
||||||
|
{
|
||||||
|
return databaseHandle != nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SqliteDatabaseBackend::closeWithoutException()
|
||||||
|
{
|
||||||
|
if (databaseHandle) {
|
||||||
|
int resultCode = sqlite3_close_v2(databaseHandle);
|
||||||
|
databaseHandle = nullptr;
|
||||||
|
if (resultCode != SQLITE_OK)
|
||||||
|
qWarning() << "SqliteDatabaseBackend::closeWithoutException: Unexpected error at closing the database!";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SqliteDatabaseBackend::registerBusyHandler()
|
||||||
|
{
|
||||||
|
sqlite3_busy_handler(sqliteDatabaseHandle(), &busyHandlerCallback, nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SqliteDatabaseBackend::registerRankingFunction()
|
||||||
|
{
|
||||||
|
sqlite3_create_function_v2(sqliteDatabaseHandle(), "okapi_bm25", -1, SQLITE_ANY, 0, okapi_bm25, 0, 0, 0);
|
||||||
|
sqlite3_create_function_v2(sqliteDatabaseHandle(), "okapi_bm25f", -1, SQLITE_UTF8, 0, okapi_bm25f, 0, 0, 0);
|
||||||
|
sqlite3_create_function_v2(sqliteDatabaseHandle(), "okapi_bm25f_kb", -1, SQLITE_UTF8, 0, okapi_bm25f_kb, 0, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int SqliteDatabaseBackend::busyHandlerCallback(void *, int counter)
|
||||||
|
{
|
||||||
|
Q_UNUSED(counter);
|
||||||
|
#ifdef QT_DEBUG
|
||||||
|
//qWarning() << "Busy handler invoked" << counter << "times!";
|
||||||
|
#endif
|
||||||
|
QThread::msleep(10);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SqliteDatabaseBackend::cacheTextEncoding()
|
||||||
|
{
|
||||||
|
cachedTextEncoding = pragmaToTextEncoding(pragmaValue(Utf8StringLiteral("encoding")));
|
||||||
|
}
|
||||||
|
|
||||||
|
void SqliteDatabaseBackend::checkForOpenDatabaseWhichCanBeClosed()
|
||||||
|
{
|
||||||
|
if (databaseHandle == nullptr)
|
||||||
|
throwException("SqliteDatabaseBackend::close: database is not open so it can not be closed.");
|
||||||
|
}
|
||||||
|
|
||||||
|
void SqliteDatabaseBackend::checkDatabaseClosing(int resultCode)
|
||||||
|
{
|
||||||
|
switch (resultCode) {
|
||||||
|
case SQLITE_OK: return;
|
||||||
|
default: throwException("SqliteDatabaseBackend::close: unknown error happens at closing!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SqliteDatabaseBackend::checkCanOpenDatabase(const QString &databaseFilePath)
|
||||||
|
{
|
||||||
|
if (databaseFilePath.isEmpty())
|
||||||
|
throw SqliteException("SqliteDatabaseBackend::SqliteDatabaseBackend: database cannot be opened:", "database file path is empty!");
|
||||||
|
|
||||||
|
if (databaseIsOpen())
|
||||||
|
throw SqliteException("SqliteDatabaseBackend::SqliteDatabaseBackend: database cannot be opened:", "database is already open!");
|
||||||
|
}
|
||||||
|
|
||||||
|
void SqliteDatabaseBackend::checkDatabaseCouldBeOpened(int resultCode)
|
||||||
|
{
|
||||||
|
switch (resultCode) {
|
||||||
|
case SQLITE_OK:
|
||||||
|
return;
|
||||||
|
default:
|
||||||
|
closeWithoutException();
|
||||||
|
throw SqliteException("SqliteDatabaseBackend::SqliteDatabaseBackend: database cannot be opened:", sqlite3_errmsg(sqliteDatabaseHandle()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SqliteDatabaseBackend::checkPragmaValue(const Utf8String &databaseValue, const Utf8String &expectedValue)
|
||||||
|
{
|
||||||
|
if (databaseValue != expectedValue)
|
||||||
|
throwException("SqliteDatabaseBackend::setPragmaValue: pragma value is not set!");
|
||||||
|
}
|
||||||
|
|
||||||
|
void SqliteDatabaseBackend::checkDatabaseHandleIsNotNull()
|
||||||
|
{
|
||||||
|
if (sqliteDatabaseBackend->databaseHandle == nullptr)
|
||||||
|
throwException("SqliteDatabaseBackend: database is not open!");
|
||||||
|
}
|
||||||
|
|
||||||
|
void SqliteDatabaseBackend::checkDatabaseBackendIsNotNull()
|
||||||
|
{
|
||||||
|
if (sqliteDatabaseBackend == nullptr)
|
||||||
|
throwException("SqliteDatabaseBackend: database backend is not initialized!");
|
||||||
|
}
|
||||||
|
|
||||||
|
void SqliteDatabaseBackend::checkIfMultithreadingIsActivated(int resultCode)
|
||||||
|
{
|
||||||
|
if (resultCode != SQLITE_OK)
|
||||||
|
throwException("SqliteDatabaseBackend::activateMultiThreading: multithreading can't be activated!");
|
||||||
|
}
|
||||||
|
|
||||||
|
void SqliteDatabaseBackend::checkIfLoogingIsActivated(int resultCode)
|
||||||
|
{
|
||||||
|
if (resultCode != SQLITE_OK)
|
||||||
|
throwException("SqliteDatabaseBackend::activateLogging: logging can't be activated!");
|
||||||
|
}
|
||||||
|
|
||||||
|
void SqliteDatabaseBackend::checkMmapSizeIsSet(int resultCode)
|
||||||
|
{
|
||||||
|
if (resultCode != SQLITE_OK)
|
||||||
|
throwException("SqliteDatabaseBackend::checkMmapSizeIsSet: mmap size can't be changed!");
|
||||||
|
}
|
||||||
|
|
||||||
|
void SqliteDatabaseBackend::checkInitializeSqliteLibraryWasSuccesful(int resultCode)
|
||||||
|
{
|
||||||
|
if (resultCode != SQLITE_OK)
|
||||||
|
throwException("SqliteDatabaseBackend::initializeSqliteLibrary: SqliteLibrary cannot initialized!");
|
||||||
|
}
|
||||||
|
|
||||||
|
void SqliteDatabaseBackend::checkShutdownSqliteLibraryWasSuccesful(int resultCode)
|
||||||
|
{
|
||||||
|
if (resultCode != SQLITE_OK)
|
||||||
|
throwException("SqliteDatabaseBackend::shutdownSqliteLibrary: SqliteLibrary cannot be shutdowned!");
|
||||||
|
}
|
||||||
|
|
||||||
|
void SqliteDatabaseBackend::checkIfLogCouldBeCheckpointed(int resultCode)
|
||||||
|
{
|
||||||
|
if (resultCode != SQLITE_OK)
|
||||||
|
throwException("SqliteDatabaseBackend::checkpointFullWalLog: WAL log could not be checkpointed!");
|
||||||
|
}
|
||||||
|
|
||||||
|
int SqliteDatabaseBackend::indexOfPragma(const Utf8String pragma, const Utf8String pragmas[], size_t pragmaCount)
|
||||||
|
{
|
||||||
|
for (unsigned int index = 0; index < pragmaCount; index++) {
|
||||||
|
if (pragma == pragmas[index])
|
||||||
|
return int(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static const Utf8String journalModeStrings[] = {
|
||||||
|
Utf8StringLiteral("delete"),
|
||||||
|
Utf8StringLiteral("truncate"),
|
||||||
|
Utf8StringLiteral("persist"),
|
||||||
|
Utf8StringLiteral("memory"),
|
||||||
|
Utf8StringLiteral("wal")
|
||||||
|
};
|
||||||
|
|
||||||
|
const Utf8String &SqliteDatabaseBackend::journalModeToPragma(JournalMode journalMode)
|
||||||
|
{
|
||||||
|
return journalModeStrings[int(journalMode)];
|
||||||
|
}
|
||||||
|
|
||||||
|
JournalMode SqliteDatabaseBackend::pragmaToJournalMode(const Utf8String &pragma)
|
||||||
|
{
|
||||||
|
int index = indexOfPragma(pragma, journalModeStrings, SIZE_OF_BYTEARRAY_ARRAY(journalModeStrings));
|
||||||
|
|
||||||
|
if (index < 0)
|
||||||
|
throwException("SqliteDatabaseBackend::pragmaToJournalMode: pragma can't be transformed in a journal mode enumeration!");
|
||||||
|
|
||||||
|
return static_cast<JournalMode>(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const Utf8String textEncodingStrings[] = {
|
||||||
|
Utf8StringLiteral("UTF-8"),
|
||||||
|
Utf8StringLiteral("UTF-16le"),
|
||||||
|
Utf8StringLiteral("UTF-16be")
|
||||||
|
};
|
||||||
|
|
||||||
|
const Utf8String &SqliteDatabaseBackend::textEncodingToPragma(TextEncoding textEncoding)
|
||||||
|
{
|
||||||
|
return textEncodingStrings[textEncoding];
|
||||||
|
}
|
||||||
|
|
||||||
|
TextEncoding SqliteDatabaseBackend::pragmaToTextEncoding(const Utf8String &pragma)
|
||||||
|
{
|
||||||
|
int index = indexOfPragma(pragma, textEncodingStrings, SIZE_OF_BYTEARRAY_ARRAY(textEncodingStrings));
|
||||||
|
|
||||||
|
if (index < 0)
|
||||||
|
throwException("SqliteDatabaseBackend::pragmaToTextEncoding: pragma can't be transformed in a text encoding enumeration!");
|
||||||
|
|
||||||
|
return static_cast<TextEncoding>(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SqliteDatabaseBackend::throwException(const char *whatHasHappens)
|
||||||
|
{
|
||||||
|
if (sqliteDatabaseBackend && sqliteDatabaseBackend->databaseHandle)
|
||||||
|
throw SqliteException(whatHasHappens, sqlite3_errmsg(sqliteDatabaseBackend->databaseHandle));
|
||||||
|
else
|
||||||
|
throw SqliteException(whatHasHappens);
|
||||||
|
}
|
116
src/libs/sqlite/sqlitedatabasebackend.h
Normal file
116
src/libs/sqlite/sqlitedatabasebackend.h
Normal file
@@ -0,0 +1,116 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef SQLITEDATABASEBACKEND_H
|
||||||
|
#define SQLITEDATABASEBACKEND_H
|
||||||
|
|
||||||
|
#include <QStringList>
|
||||||
|
|
||||||
|
#include "sqliteglobal.h"
|
||||||
|
|
||||||
|
#include "utf8stringvector.h"
|
||||||
|
|
||||||
|
struct sqlite3;
|
||||||
|
|
||||||
|
class SQLITE_EXPORT SqliteDatabaseBackend
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
SqliteDatabaseBackend();
|
||||||
|
~SqliteDatabaseBackend();
|
||||||
|
|
||||||
|
static void setMmapSize(qint64 defaultSize, qint64 maximumSize);
|
||||||
|
static void activateMultiThreading();
|
||||||
|
static void activateLogging();
|
||||||
|
static void initializeSqliteLibrary();
|
||||||
|
static void shutdownSqliteLibrary();
|
||||||
|
static void checkpointFullWalLog();
|
||||||
|
|
||||||
|
void open(const QString &databaseFilePath);
|
||||||
|
void close();
|
||||||
|
void closeWithoutException();
|
||||||
|
|
||||||
|
static SqliteDatabaseBackend *threadLocalInstance();
|
||||||
|
static sqlite3* sqliteDatabaseHandle();
|
||||||
|
|
||||||
|
void setJournalMode(JournalMode journalMode);
|
||||||
|
JournalMode journalMode() const;
|
||||||
|
|
||||||
|
void setTextEncoding(TextEncoding textEncoding);
|
||||||
|
TextEncoding textEncoding();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static Utf8StringVector columnNames(const Utf8String &tableName);
|
||||||
|
|
||||||
|
static int changesCount();
|
||||||
|
static int totalChangesCount();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool databaseIsOpen() const;
|
||||||
|
|
||||||
|
void setPragmaValue(const Utf8String &pragma, const Utf8String &value);
|
||||||
|
Utf8String pragmaValue(const Utf8String &pragma) const;
|
||||||
|
|
||||||
|
void registerBusyHandler();
|
||||||
|
void registerRankingFunction();
|
||||||
|
static int busyHandlerCallback(void*, int counter);
|
||||||
|
|
||||||
|
void cacheTextEncoding();
|
||||||
|
|
||||||
|
void checkForOpenDatabaseWhichCanBeClosed();
|
||||||
|
void checkDatabaseClosing(int resultCode);
|
||||||
|
void checkCanOpenDatabase(const QString &databaseFilePath);
|
||||||
|
void checkDatabaseCouldBeOpened(int resultCode);
|
||||||
|
void checkPragmaValue(const Utf8String &databaseValue, const Utf8String &expectedValue);
|
||||||
|
static void checkDatabaseHandleIsNotNull();
|
||||||
|
static void checkDatabaseBackendIsNotNull();
|
||||||
|
static void checkIfMultithreadingIsActivated(int resultCode);
|
||||||
|
static void checkIfLoogingIsActivated(int resultCode);
|
||||||
|
static void checkMmapSizeIsSet(int resultCode);
|
||||||
|
static void checkInitializeSqliteLibraryWasSuccesful(int resultCode);
|
||||||
|
static void checkShutdownSqliteLibraryWasSuccesful(int resultCode);
|
||||||
|
static void checkIfLogCouldBeCheckpointed(int resultCode);
|
||||||
|
|
||||||
|
static int indexOfPragma(const Utf8String pragma, const Utf8String pragmas[], size_t pragmaCount);
|
||||||
|
static const Utf8String &journalModeToPragma(JournalMode journalMode);
|
||||||
|
static JournalMode pragmaToJournalMode(const Utf8String &pragma);
|
||||||
|
static const Utf8String &textEncodingToPragma(TextEncoding textEncoding);
|
||||||
|
static TextEncoding pragmaToTextEncoding(const Utf8String &pragma);
|
||||||
|
|
||||||
|
Q_NORETURN static void throwException(const char *whatHasHappens);
|
||||||
|
|
||||||
|
private:
|
||||||
|
sqlite3 *databaseHandle;
|
||||||
|
TextEncoding cachedTextEncoding;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SQLITEDATABASEBACKEND_H
|
100
src/libs/sqlite/sqlitedatabaseconnection.cpp
Normal file
100
src/libs/sqlite/sqlitedatabaseconnection.cpp
Normal file
@@ -0,0 +1,100 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "sqlitedatabaseconnection.h"
|
||||||
|
|
||||||
|
#include <sqlite3.h>
|
||||||
|
|
||||||
|
#include <QtDebug>
|
||||||
|
|
||||||
|
#ifdef Q_OS_LINUX
|
||||||
|
#include <sys/resource.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <sys/syscall.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "sqliteexception.h"
|
||||||
|
#include "sqliteglobal.h"
|
||||||
|
|
||||||
|
SqliteDatabaseConnection::SqliteDatabaseConnection(QObject *parent) :
|
||||||
|
QObject(parent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
SqliteDatabaseConnection::~SqliteDatabaseConnection()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
sqlite3 *SqliteDatabaseConnection::currentSqliteDatabase()
|
||||||
|
{
|
||||||
|
return SqliteDatabaseBackend::sqliteDatabaseHandle();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SqliteDatabaseConnection::setDatabaseFilePath(const QString &databaseFilePath)
|
||||||
|
{
|
||||||
|
|
||||||
|
prioritizeThreadDown();
|
||||||
|
|
||||||
|
try {
|
||||||
|
databaseBackend.open(databaseFilePath);
|
||||||
|
|
||||||
|
emit databaseConnectionIsOpened();
|
||||||
|
} catch (SqliteException &exception) {
|
||||||
|
exception.printWarning();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SqliteDatabaseConnection::setJournalMode(JournalMode journalMode)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
databaseBackend.setJournalMode(journalMode);
|
||||||
|
} catch (SqliteException &exception) {
|
||||||
|
exception.printWarning();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SqliteDatabaseConnection::close()
|
||||||
|
{
|
||||||
|
databaseBackend.closeWithoutException();
|
||||||
|
|
||||||
|
emit databaseConnectionIsClosed();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SqliteDatabaseConnection::prioritizeThreadDown()
|
||||||
|
{
|
||||||
|
#ifdef Q_OS_LINUX
|
||||||
|
pid_t processId = syscall(SYS_gettid);
|
||||||
|
int returnCode = setpriority(PRIO_PROCESS, processId, 10);
|
||||||
|
if (returnCode == -1)
|
||||||
|
qWarning() << "cannot renice" << strerror(errno);
|
||||||
|
#endif
|
||||||
|
}
|
65
src/libs/sqlite/sqlitedatabaseconnection.h
Normal file
65
src/libs/sqlite/sqlitedatabaseconnection.h
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef SQLITEDATABASECONNECTIONCONTROLLER_H
|
||||||
|
#define SQLITEDATABASECONNECTIONCONTROLLER_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
|
||||||
|
#include "sqlitedatabasebackend.h"
|
||||||
|
|
||||||
|
struct sqlite3;
|
||||||
|
|
||||||
|
class SQLITE_EXPORT SqliteDatabaseConnection final : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit SqliteDatabaseConnection(QObject *parent = 0);
|
||||||
|
~SqliteDatabaseConnection();
|
||||||
|
|
||||||
|
static sqlite3 *currentSqliteDatabase();
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void setDatabaseFilePath(const QString &databaseName);
|
||||||
|
void setJournalMode(JournalMode journalMode);
|
||||||
|
void close();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void prioritizeThreadDown();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void databaseConnectionIsOpened();
|
||||||
|
void databaseConnectionIsClosed();
|
||||||
|
|
||||||
|
private:
|
||||||
|
SqliteDatabaseBackend databaseBackend;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SQLITEDATABASECONNECTIONCONTROLLER_H
|
97
src/libs/sqlite/sqlitedatabaseconnectionproxy.cpp
Normal file
97
src/libs/sqlite/sqlitedatabaseconnectionproxy.cpp
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "sqlitedatabaseconnectionproxy.h"
|
||||||
|
|
||||||
|
#include "sqlitedatabaseconnection.h"
|
||||||
|
#include "sqliteworkerthread.h"
|
||||||
|
|
||||||
|
#include <QCoreApplication>
|
||||||
|
|
||||||
|
|
||||||
|
SqliteDatabaseConnectionProxy::SqliteDatabaseConnectionProxy(const QString &threadName) :
|
||||||
|
QObject(),
|
||||||
|
databaseConnectionIsOpen(false)
|
||||||
|
{
|
||||||
|
|
||||||
|
databaseConnectionThread = new SqliteWorkerThread;
|
||||||
|
databaseConnectionThread->setObjectName(threadName);
|
||||||
|
|
||||||
|
databaseConnectionThread->start(QThread::LowPriority);
|
||||||
|
|
||||||
|
SqliteDatabaseConnection *connection = databaseConnectionThread->databaseConnection();
|
||||||
|
|
||||||
|
|
||||||
|
connect(this, &SqliteDatabaseConnectionProxy::setDatabaseFilePath, connection, &SqliteDatabaseConnection::setDatabaseFilePath);
|
||||||
|
connect(this, &SqliteDatabaseConnectionProxy::setJournalMode, connection, &SqliteDatabaseConnection::setJournalMode);
|
||||||
|
connect(this, &SqliteDatabaseConnectionProxy::close, connection, &SqliteDatabaseConnection::close);
|
||||||
|
|
||||||
|
connect(connection, &SqliteDatabaseConnection::databaseConnectionIsOpened, this, &SqliteDatabaseConnectionProxy::handleDatabaseConnectionIsOpened);
|
||||||
|
connect(connection, &SqliteDatabaseConnection::databaseConnectionIsClosed, this, &SqliteDatabaseConnectionProxy::handleDatabaseConnectionIsClosed);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
SqliteDatabaseConnectionProxy::~SqliteDatabaseConnectionProxy()
|
||||||
|
{
|
||||||
|
if (databaseConnectionThread) {
|
||||||
|
databaseConnectionThread->quit();
|
||||||
|
databaseConnectionThread->wait();
|
||||||
|
databaseConnectionThread->deleteLater();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QThread *SqliteDatabaseConnectionProxy::connectionThread() const
|
||||||
|
{
|
||||||
|
return databaseConnectionThread;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SqliteDatabaseConnectionProxy::isOpen() const
|
||||||
|
{
|
||||||
|
return databaseConnectionIsOpen;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SqliteDatabaseConnectionProxy::registerTypes()
|
||||||
|
{
|
||||||
|
qRegisterMetaType<JournalMode>("JournalMode");
|
||||||
|
}
|
||||||
|
|
||||||
|
void SqliteDatabaseConnectionProxy::handleDatabaseConnectionIsOpened()
|
||||||
|
{
|
||||||
|
databaseConnectionIsOpen = true;
|
||||||
|
|
||||||
|
emit connectionIsOpened();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SqliteDatabaseConnectionProxy::handleDatabaseConnectionIsClosed()
|
||||||
|
{
|
||||||
|
databaseConnectionIsOpen = false;
|
||||||
|
|
||||||
|
emit connectionIsClosed();
|
||||||
|
}
|
71
src/libs/sqlite/sqlitedatabaseconnectionproxy.h
Normal file
71
src/libs/sqlite/sqlitedatabaseconnectionproxy.h
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef SQLITEDATABASECONNECTION_H
|
||||||
|
#define SQLITEDATABASECONNECTION_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QPointer>
|
||||||
|
|
||||||
|
#include <sqliteglobal.h>
|
||||||
|
|
||||||
|
struct sqlite3;
|
||||||
|
class SqliteWorkerThread;
|
||||||
|
|
||||||
|
class SQLITE_EXPORT SqliteDatabaseConnectionProxy final : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit SqliteDatabaseConnectionProxy(const QString &threadName);
|
||||||
|
~SqliteDatabaseConnectionProxy();
|
||||||
|
|
||||||
|
QThread *connectionThread() const;
|
||||||
|
|
||||||
|
bool isOpen() const;
|
||||||
|
|
||||||
|
static void registerTypes();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void setDatabaseFilePath(const QString &databaseFilePath);
|
||||||
|
void setJournalMode(JournalMode journal);
|
||||||
|
void connectionIsOpened();
|
||||||
|
void connectionIsClosed();
|
||||||
|
void close();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void handleDatabaseConnectionIsOpened();
|
||||||
|
void handleDatabaseConnectionIsClosed();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QPointer<SqliteWorkerThread> databaseConnectionThread;
|
||||||
|
bool databaseConnectionIsOpen;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SQLITEDATABASECONNECTION_H
|
48
src/libs/sqlite/sqliteexception.cpp
Normal file
48
src/libs/sqlite/sqliteexception.cpp
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "sqliteexception.h"
|
||||||
|
|
||||||
|
#include <QtDebug>
|
||||||
|
|
||||||
|
SqliteException::SqliteException(const char *whatErrorHasHappen, const char *sqliteErrorMessage)
|
||||||
|
: whatErrorHasHappen(whatErrorHasHappen),
|
||||||
|
sqliteErrorMessage_(sqliteErrorMessage)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void SqliteException::printWarning() const
|
||||||
|
{
|
||||||
|
if (!sqliteErrorMessage_.isEmpty())
|
||||||
|
qWarning() << whatErrorHasHappen << sqliteErrorMessage_;
|
||||||
|
else
|
||||||
|
qWarning() << whatErrorHasHappen;
|
||||||
|
}
|
||||||
|
|
50
src/libs/sqlite/sqliteexception.h
Normal file
50
src/libs/sqlite/sqliteexception.h
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef SQLITEEXCEPTION_H
|
||||||
|
#define SQLITEEXCEPTION_H
|
||||||
|
|
||||||
|
#include <QByteArray>
|
||||||
|
|
||||||
|
#include "sqliteglobal.h"
|
||||||
|
|
||||||
|
class SQLITE_EXPORT SqliteException
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SqliteException(const char *whatErrorHasHappen, const char *sqliteErrorMessage = 0);
|
||||||
|
|
||||||
|
void printWarning() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
const char *whatErrorHasHappen;
|
||||||
|
QByteArray sqliteErrorMessage_;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SQLITEEXCEPTION_H
|
44
src/libs/sqlite/sqliteglobal.cpp
Normal file
44
src/libs/sqlite/sqliteglobal.cpp
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "sqliteglobal.h"
|
||||||
|
|
||||||
|
#include "createtablecommand.h"
|
||||||
|
|
||||||
|
namespace Sqlite {
|
||||||
|
|
||||||
|
void registerTypes()
|
||||||
|
{
|
||||||
|
Internal::CreateTableCommand::registerType();
|
||||||
|
|
||||||
|
qRegisterMetaType<JournalMode>("JournalMode");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
96
src/libs/sqlite/sqliteglobal.h
Normal file
96
src/libs/sqlite/sqliteglobal.h
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef SQLITEGLOBAL_H
|
||||||
|
#define SQLITEGLOBAL_H
|
||||||
|
|
||||||
|
#include <QtGlobal>
|
||||||
|
|
||||||
|
#if defined(BUILD_SQLITE_LIBRARY)
|
||||||
|
# define SQLITE_EXPORT Q_DECL_EXPORT
|
||||||
|
#elif defined(BUILD_SQLITE_STATIC_LIBRARY)
|
||||||
|
# define SQLITE_EXPORT
|
||||||
|
#else
|
||||||
|
# define SQLITE_EXPORT Q_DECL_IMPORT
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
namespace Sqlite {
|
||||||
|
SQLITE_EXPORT void registerTypes();
|
||||||
|
}
|
||||||
|
|
||||||
|
enum class ColumnType {
|
||||||
|
Numeric,
|
||||||
|
Integer,
|
||||||
|
Real,
|
||||||
|
Text,
|
||||||
|
None
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class ColumnConstraint {
|
||||||
|
PrimaryKey
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class JournalMode {
|
||||||
|
Delete,
|
||||||
|
Truncate,
|
||||||
|
Persist,
|
||||||
|
Memory,
|
||||||
|
Wal
|
||||||
|
};
|
||||||
|
|
||||||
|
enum TextEncoding {
|
||||||
|
Utf8,
|
||||||
|
Utf16le,
|
||||||
|
Utf16be,
|
||||||
|
#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
|
||||||
|
Utf16 = Utf16le
|
||||||
|
#else
|
||||||
|
Utf16 = Utf16be
|
||||||
|
#endif
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
template <typename T> class QVector;
|
||||||
|
template <typename T> class QSet;
|
||||||
|
template <class Key, class T> class QHash;
|
||||||
|
template <class Key, class T> class QMap;
|
||||||
|
class QVariant;
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
class Utf8String;
|
||||||
|
class Utf8StringVector;
|
||||||
|
|
||||||
|
typedef QMap<Utf8String, QVariant> RowDictionary;
|
||||||
|
typedef QVector<RowDictionary> RowDictionaries;
|
||||||
|
|
||||||
|
|
||||||
|
#endif // SQLITEGLOBAL_H
|
45
src/libs/sqlite/sqlitereadstatement.cpp
Normal file
45
src/libs/sqlite/sqlitereadstatement.cpp
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "sqlitereadstatement.h"
|
||||||
|
|
||||||
|
#include "sqlite3.h"
|
||||||
|
|
||||||
|
SqliteReadStatement::SqliteReadStatement(const Utf8String &sqlStatementUtf8)
|
||||||
|
: SqliteStatement(sqlStatementUtf8)
|
||||||
|
{
|
||||||
|
checkIsReadOnlyStatement();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SqliteReadStatement::checkIsReadOnlyStatement()
|
||||||
|
{
|
||||||
|
if (!isReadOnlyStatement())
|
||||||
|
throwException("SqliteStatement::SqliteReadStatement: is not read only statement!");
|
||||||
|
}
|
59
src/libs/sqlite/sqlitereadstatement.h
Normal file
59
src/libs/sqlite/sqlitereadstatement.h
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef SQLITEREADSTATEMENT_H
|
||||||
|
#define SQLITEREADSTATEMENT_H
|
||||||
|
|
||||||
|
#include "sqlitestatement.h"
|
||||||
|
|
||||||
|
class SQLITE_EXPORT SqliteReadStatement final : private SqliteStatement
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit SqliteReadStatement(const Utf8String &sqlStatementUtf8);
|
||||||
|
|
||||||
|
using SqliteStatement::next;
|
||||||
|
using SqliteStatement::reset;
|
||||||
|
using SqliteStatement::value;
|
||||||
|
using SqliteStatement::values;
|
||||||
|
using SqliteStatement::rowColumnValueMap;
|
||||||
|
using SqliteStatement::twoColumnValueMap;
|
||||||
|
using SqliteStatement::columnCount;
|
||||||
|
using SqliteStatement::columnNames;
|
||||||
|
using SqliteStatement::bind;
|
||||||
|
using SqliteStatement::bindingIndexForName;
|
||||||
|
using SqliteStatement::setBindingColumnNames;
|
||||||
|
using SqliteStatement::bindingColumnNames;
|
||||||
|
using SqliteStatement::toValue;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void checkIsReadOnlyStatement();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SQLITEREADSTATEMENT_H
|
38
src/libs/sqlite/sqlitereadwritestatement.cpp
Normal file
38
src/libs/sqlite/sqlitereadwritestatement.cpp
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "sqlitereadwritestatement.h"
|
||||||
|
|
||||||
|
|
||||||
|
SqliteReadWriteStatement::SqliteReadWriteStatement(const Utf8String &sqlStatementUft8)
|
||||||
|
: SqliteStatement(sqlStatementUft8)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
58
src/libs/sqlite/sqlitereadwritestatement.h
Normal file
58
src/libs/sqlite/sqlitereadwritestatement.h
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef SQLITEREADWRITESTATEMENT_H
|
||||||
|
#define SQLITEREADWRITESTATEMENT_H
|
||||||
|
|
||||||
|
#include "sqlitestatement.h"
|
||||||
|
|
||||||
|
class SQLITE_EXPORT SqliteReadWriteStatement final : private SqliteStatement
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit SqliteReadWriteStatement(const Utf8String &sqlStatementUft8);
|
||||||
|
|
||||||
|
using SqliteStatement::next;
|
||||||
|
using SqliteStatement::step;
|
||||||
|
using SqliteStatement::reset;
|
||||||
|
using SqliteStatement::bind;
|
||||||
|
using SqliteStatement::bindingIndexForName;
|
||||||
|
using SqliteStatement::setBindingColumnNames;
|
||||||
|
using SqliteStatement::bindingColumnNames;
|
||||||
|
using SqliteStatement::write;
|
||||||
|
using SqliteStatement::value;
|
||||||
|
using SqliteStatement::values;
|
||||||
|
using SqliteStatement::rowColumnValueMap;
|
||||||
|
using SqliteStatement::columnCount;
|
||||||
|
using SqliteStatement::columnNames;
|
||||||
|
using SqliteStatement::toValue;
|
||||||
|
using SqliteStatement::execute;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SQLITEREADWRITESTATEMENT_H
|
676
src/libs/sqlite/sqlitestatement.cpp
Normal file
676
src/libs/sqlite/sqlitestatement.cpp
Normal file
@@ -0,0 +1,676 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "sqlitestatement.h"
|
||||||
|
|
||||||
|
#include <QMutex>
|
||||||
|
#include <QWaitCondition>
|
||||||
|
#include <QVariant>
|
||||||
|
#include <QtGlobal>
|
||||||
|
|
||||||
|
#include "sqlite3.h"
|
||||||
|
|
||||||
|
#include "sqlitedatabasebackend.h"
|
||||||
|
#include "sqliteexception.h"
|
||||||
|
|
||||||
|
#if defined(__GNUC__)
|
||||||
|
# pragma GCC diagnostic ignored "-Wignored-qualifiers"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
SqliteStatement::SqliteStatement(const Utf8String &sqlStatementUtf8)
|
||||||
|
: compiledStatement(nullptr, deleteCompiledStatement),
|
||||||
|
bindingParameterCount(0),
|
||||||
|
columnCount_(0),
|
||||||
|
isReadyToFetchValues(false)
|
||||||
|
{
|
||||||
|
prepare(sqlStatementUtf8);
|
||||||
|
setBindingParameterCount();
|
||||||
|
setBindingColumnNamesFromStatement();
|
||||||
|
setColumnCount();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SqliteStatement::deleteCompiledStatement(sqlite3_stmt *compiledStatement)
|
||||||
|
{
|
||||||
|
if (compiledStatement)
|
||||||
|
sqlite3_finalize(compiledStatement);
|
||||||
|
}
|
||||||
|
|
||||||
|
class UnlockNotification {
|
||||||
|
|
||||||
|
public:
|
||||||
|
UnlockNotification() : fired(false) {};
|
||||||
|
|
||||||
|
static void unlockNotifyCallBack(void **arguments, int argumentCount)
|
||||||
|
{
|
||||||
|
for (int index = 0; index < argumentCount; index++) {
|
||||||
|
UnlockNotification *unlockNotification = static_cast<UnlockNotification *>(arguments[index]);
|
||||||
|
unlockNotification->wakeupWaitCondition();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void wakeupWaitCondition()
|
||||||
|
{
|
||||||
|
mutex.lock();
|
||||||
|
fired = 1;
|
||||||
|
waitCondition.wakeAll();
|
||||||
|
mutex.unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
void wait()
|
||||||
|
{
|
||||||
|
mutex.lock();
|
||||||
|
|
||||||
|
if (!fired) {
|
||||||
|
waitCondition.wait(&mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
mutex.unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool fired;
|
||||||
|
QWaitCondition waitCondition;
|
||||||
|
QMutex mutex;
|
||||||
|
};
|
||||||
|
|
||||||
|
void SqliteStatement::waitForUnlockNotify() const
|
||||||
|
{
|
||||||
|
UnlockNotification unlockNotification;
|
||||||
|
int resultCode = sqlite3_unlock_notify(sqliteDatabaseHandle(), UnlockNotification::unlockNotifyCallBack, &unlockNotification);
|
||||||
|
|
||||||
|
if (resultCode == SQLITE_OK)
|
||||||
|
unlockNotification.wait();
|
||||||
|
else
|
||||||
|
throwException("SqliteStatement::waitForUnlockNotify: database is in a dead lock!");
|
||||||
|
}
|
||||||
|
|
||||||
|
void SqliteStatement::reset() const
|
||||||
|
{
|
||||||
|
int resultCode = sqlite3_reset(compiledStatement.get());
|
||||||
|
if (resultCode != SQLITE_OK)
|
||||||
|
throwException("SqliteStatement::reset: can't reset statement!");
|
||||||
|
|
||||||
|
isReadyToFetchValues = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SqliteStatement::next() const
|
||||||
|
{
|
||||||
|
int resultCode;
|
||||||
|
|
||||||
|
do {
|
||||||
|
resultCode = sqlite3_step(compiledStatement.get());
|
||||||
|
if (resultCode == SQLITE_LOCKED) {
|
||||||
|
waitForUnlockNotify();
|
||||||
|
sqlite3_reset(compiledStatement.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
} while (resultCode == SQLITE_LOCKED);
|
||||||
|
|
||||||
|
setIfIsReadyToFetchValues(resultCode);
|
||||||
|
|
||||||
|
return checkForStepError(resultCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SqliteStatement::step() const
|
||||||
|
{
|
||||||
|
next();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SqliteStatement::write(const RowDictionary &rowDictionary)
|
||||||
|
{
|
||||||
|
bind(rowDictionary);
|
||||||
|
step();
|
||||||
|
reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SqliteStatement::writeUnchecked(const RowDictionary &rowDictionary)
|
||||||
|
{
|
||||||
|
bindUnchecked(rowDictionary);
|
||||||
|
step();
|
||||||
|
reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
int SqliteStatement::columnCount() const
|
||||||
|
{
|
||||||
|
return columnCount_;
|
||||||
|
}
|
||||||
|
|
||||||
|
Utf8StringVector SqliteStatement::columnNames() const
|
||||||
|
{
|
||||||
|
Utf8StringVector columnNames;
|
||||||
|
int columnCount = SqliteStatement::columnCount();
|
||||||
|
columnNames.reserve(columnCount);
|
||||||
|
for (int columnIndex = 0; columnIndex < columnCount; columnIndex++)
|
||||||
|
columnNames.append(Utf8String(sqlite3_column_origin_name(compiledStatement.get(), columnIndex), -1));
|
||||||
|
|
||||||
|
return columnNames;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SqliteStatement::bind(int index, int value)
|
||||||
|
{
|
||||||
|
int resultCode = sqlite3_bind_int(compiledStatement.get(), index, value);
|
||||||
|
if (resultCode != SQLITE_OK)
|
||||||
|
throwException("SqliteStatement::bind: cant' bind 32 bit integer!");
|
||||||
|
}
|
||||||
|
|
||||||
|
void SqliteStatement::bind(int index, qint64 value)
|
||||||
|
{
|
||||||
|
int resultCode = sqlite3_bind_int64(compiledStatement.get(), index, value);
|
||||||
|
if (resultCode != SQLITE_OK)
|
||||||
|
throwException("SqliteStatement::bind: cant' bind 64 bit integer!");
|
||||||
|
}
|
||||||
|
|
||||||
|
void SqliteStatement::bind(int index, double value)
|
||||||
|
{
|
||||||
|
int resultCode = sqlite3_bind_double(compiledStatement.get(), index, value);
|
||||||
|
if (resultCode != SQLITE_OK)
|
||||||
|
throwException("SqliteStatement::bind: cant' bind double!");
|
||||||
|
}
|
||||||
|
|
||||||
|
void SqliteStatement::bind(int index, const QString &text)
|
||||||
|
{
|
||||||
|
int resultCode;
|
||||||
|
if (databaseTextEncoding() == Utf8) {
|
||||||
|
QByteArray textUtf8 = text.toUtf8();
|
||||||
|
resultCode = sqlite3_bind_text(compiledStatement.get(), index, textUtf8.constData(), textUtf8.size(), SQLITE_TRANSIENT);
|
||||||
|
} else {
|
||||||
|
resultCode = sqlite3_bind_text16(compiledStatement.get(), index, text.constData(), text.size() * 2, SQLITE_TRANSIENT);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (resultCode != SQLITE_OK)
|
||||||
|
throwException("SqliteStatement::bind: cant' not bind text!");
|
||||||
|
}
|
||||||
|
|
||||||
|
void SqliteStatement::bind(int index, const QByteArray &blob)
|
||||||
|
{
|
||||||
|
sqlite3_bind_blob(compiledStatement.get(), index, blob.constData(), blob.size(), SQLITE_TRANSIENT);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SqliteStatement::bind(int index, const QVariant &value)
|
||||||
|
{
|
||||||
|
checkBindingIndex(index);
|
||||||
|
|
||||||
|
switch (value.type()) {
|
||||||
|
case QVariant::Bool:
|
||||||
|
case QVariant::Int:
|
||||||
|
bind(index, value.toInt());
|
||||||
|
break;
|
||||||
|
case QVariant::UInt:
|
||||||
|
case QVariant::LongLong:
|
||||||
|
case QVariant::ULongLong:
|
||||||
|
bind(index, value.toLongLong());
|
||||||
|
break;
|
||||||
|
case QVariant::Double:
|
||||||
|
bind(index, value.toDouble());
|
||||||
|
break;
|
||||||
|
case QVariant::String:
|
||||||
|
bind(index, value.toString());
|
||||||
|
break;
|
||||||
|
case QVariant::ByteArray:
|
||||||
|
bind(index, value.toByteArray());
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
sqlite3_bind_null(compiledStatement.get(), index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename Type>
|
||||||
|
void SqliteStatement::bind(const Utf8String &name, const Type &value)
|
||||||
|
{
|
||||||
|
int index = bindingIndexForName(name);
|
||||||
|
checkBindingName(index);
|
||||||
|
bind(index, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
template SQLITE_EXPORT void SqliteStatement::bind(const Utf8String &name, const int &value);
|
||||||
|
template SQLITE_EXPORT void SqliteStatement::bind(const Utf8String &name, const qint64 &value);
|
||||||
|
template SQLITE_EXPORT void SqliteStatement::bind(const Utf8String &name, const double &value);
|
||||||
|
template SQLITE_EXPORT void SqliteStatement::bind(const Utf8String &name, const QString &text);
|
||||||
|
template SQLITE_EXPORT void SqliteStatement::bind(const Utf8String &name, const QByteArray &blob);
|
||||||
|
template SQLITE_EXPORT void SqliteStatement::bind(const Utf8String &name, const QVariant &value);
|
||||||
|
|
||||||
|
int SqliteStatement::bindingIndexForName(const Utf8String &name)
|
||||||
|
{
|
||||||
|
return sqlite3_bind_parameter_index(compiledStatement.get(), name.constData());
|
||||||
|
}
|
||||||
|
|
||||||
|
void SqliteStatement::bind(const RowDictionary &rowDictionary)
|
||||||
|
{
|
||||||
|
checkBindingValueMapIsEmpty(rowDictionary);
|
||||||
|
|
||||||
|
int columnIndex = 1;
|
||||||
|
foreach (const Utf8String &columnName, bindingColumnNames_) {
|
||||||
|
checkParameterCanBeBound(rowDictionary, columnName);
|
||||||
|
QVariant value = rowDictionary.value(columnName);
|
||||||
|
bind(columnIndex, value);
|
||||||
|
columnIndex += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SqliteStatement::bindUnchecked(const RowDictionary &rowDictionary)
|
||||||
|
{
|
||||||
|
checkBindingValueMapIsEmpty(rowDictionary);
|
||||||
|
|
||||||
|
int columnIndex = 1;
|
||||||
|
foreach (const Utf8String &columnName, bindingColumnNames_) {
|
||||||
|
if (rowDictionary.contains(columnName)) {
|
||||||
|
QVariant value = rowDictionary.value(columnName);
|
||||||
|
bind(columnIndex, value);
|
||||||
|
}
|
||||||
|
columnIndex += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SqliteStatement::setBindingColumnNames(const Utf8StringVector &bindingColumnNames)
|
||||||
|
{
|
||||||
|
bindingColumnNames_ = bindingColumnNames;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Utf8StringVector &SqliteStatement::bindingColumnNames() const
|
||||||
|
{
|
||||||
|
return bindingColumnNames_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SqliteStatement::execute(const Utf8String &sqlStatementUtf8)
|
||||||
|
{
|
||||||
|
SqliteStatement statement(sqlStatementUtf8);
|
||||||
|
statement.step();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SqliteStatement::prepare(const Utf8String &sqlStatementUtf8)
|
||||||
|
{
|
||||||
|
int resultCode;
|
||||||
|
|
||||||
|
do {
|
||||||
|
sqlite3_stmt *sqliteStatement = nullptr;
|
||||||
|
resultCode = sqlite3_prepare_v2(sqliteDatabaseHandle(), sqlStatementUtf8.constData(), sqlStatementUtf8.byteSize(), &sqliteStatement, nullptr);
|
||||||
|
compiledStatement.reset(sqliteStatement);
|
||||||
|
|
||||||
|
if (resultCode == SQLITE_LOCKED)
|
||||||
|
waitForUnlockNotify();
|
||||||
|
|
||||||
|
} while (resultCode == SQLITE_LOCKED);
|
||||||
|
|
||||||
|
checkForPrepareError(resultCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
sqlite3 *SqliteStatement::sqliteDatabaseHandle()
|
||||||
|
{
|
||||||
|
return SqliteDatabaseBackend::sqliteDatabaseHandle();
|
||||||
|
}
|
||||||
|
|
||||||
|
TextEncoding SqliteStatement::databaseTextEncoding()
|
||||||
|
{
|
||||||
|
if (SqliteDatabaseBackend::threadLocalInstance())
|
||||||
|
return SqliteDatabaseBackend::threadLocalInstance()->textEncoding();
|
||||||
|
|
||||||
|
throwException("SqliteStatement::databaseTextEncoding: database backend instance is null!");
|
||||||
|
|
||||||
|
Q_UNREACHABLE();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SqliteStatement::checkForStepError(int resultCode) const
|
||||||
|
{
|
||||||
|
switch (resultCode) {
|
||||||
|
case SQLITE_ROW: return true;
|
||||||
|
case SQLITE_DONE: return false;
|
||||||
|
case SQLITE_BUSY: throwException("SqliteStatement::stepStatement: database engine was unable to acquire the database locks!");
|
||||||
|
case SQLITE_ERROR : throwException("SqliteStatement::stepStatement: run-time error (such as a constraint violation) has occurred!");
|
||||||
|
case SQLITE_MISUSE: throwException("SqliteStatement::stepStatement: was called inappropriately!");
|
||||||
|
case SQLITE_CONSTRAINT: throwException("SqliteStatement::stepStatement: contraint prevent insert or update!");
|
||||||
|
}
|
||||||
|
|
||||||
|
throwException("SqliteStatement::stepStatement: unknown error has happen!");
|
||||||
|
|
||||||
|
Q_UNREACHABLE();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SqliteStatement::checkForPrepareError(int resultCode) const
|
||||||
|
{
|
||||||
|
switch (resultCode) {
|
||||||
|
case SQLITE_OK: return;
|
||||||
|
case SQLITE_BUSY: throwException("SqliteStatement::prepareStatement: database engine was unable to acquire the database locks!");
|
||||||
|
case SQLITE_ERROR : throwException("SqliteStatement::prepareStatement: run-time error (such as a constraint violation) has occurred!");
|
||||||
|
case SQLITE_MISUSE: throwException("SqliteStatement::prepareStatement: was called inappropriately!");
|
||||||
|
}
|
||||||
|
|
||||||
|
throwException("SqliteStatement::prepareStatement: unknown error has happen!");
|
||||||
|
}
|
||||||
|
|
||||||
|
void SqliteStatement::setIfIsReadyToFetchValues(int resultCode) const
|
||||||
|
{
|
||||||
|
if (resultCode == SQLITE_ROW)
|
||||||
|
isReadyToFetchValues = true;
|
||||||
|
else
|
||||||
|
isReadyToFetchValues = false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void SqliteStatement::checkIfIsReadyToFetchValues() const
|
||||||
|
{
|
||||||
|
if (!isReadyToFetchValues)
|
||||||
|
throwException("SqliteStatement::value: there are no values to fetch!");
|
||||||
|
}
|
||||||
|
|
||||||
|
void SqliteStatement::checkColumnsAreValid(const QVector<int> &columns) const
|
||||||
|
{
|
||||||
|
foreach (int column, columns) {
|
||||||
|
if (column < 0 || column >= columnCount_)
|
||||||
|
throwException("SqliteStatement::values: column index out of bound!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SqliteStatement::checkColumnIsValid(int column) const
|
||||||
|
{
|
||||||
|
if (column < 0 || column >= columnCount_)
|
||||||
|
throwException("SqliteStatement::values: column index out of bound!");
|
||||||
|
}
|
||||||
|
|
||||||
|
void SqliteStatement::checkBindingIndex(int index) const
|
||||||
|
{
|
||||||
|
if (index <= 0 || index > bindingParameterCount)
|
||||||
|
throwException("SqliteStatement::bind: binding index is out of bound!");
|
||||||
|
}
|
||||||
|
|
||||||
|
void SqliteStatement::checkBindingName(int index) const
|
||||||
|
{
|
||||||
|
if (index <= 0 || index > bindingParameterCount)
|
||||||
|
throwException("SqliteStatement::bind: binding name are not exists in this statement!");
|
||||||
|
}
|
||||||
|
|
||||||
|
void SqliteStatement::checkParameterCanBeBound(const RowDictionary &rowDictionary, const Utf8String &columnName)
|
||||||
|
{
|
||||||
|
if (!rowDictionary.contains(columnName))
|
||||||
|
throwException("SqliteStatement::bind: Not all parameters are bound!");
|
||||||
|
}
|
||||||
|
|
||||||
|
void SqliteStatement::setBindingParameterCount()
|
||||||
|
{
|
||||||
|
bindingParameterCount = sqlite3_bind_parameter_count(compiledStatement.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
Utf8String chopFirstLetter(const char *rawBindingName)
|
||||||
|
{
|
||||||
|
QByteArray bindingName(rawBindingName);
|
||||||
|
bindingName = bindingName.mid(1);
|
||||||
|
|
||||||
|
return Utf8String::fromByteArray(bindingName);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SqliteStatement::setBindingColumnNamesFromStatement()
|
||||||
|
{
|
||||||
|
for (int index = 1; index <= bindingParameterCount; index++) {
|
||||||
|
Utf8String bindingName = chopFirstLetter(sqlite3_bind_parameter_name(compiledStatement.get(), index));
|
||||||
|
bindingColumnNames_.append(bindingName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SqliteStatement::setColumnCount()
|
||||||
|
{
|
||||||
|
columnCount_ = sqlite3_column_count(compiledStatement.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
void SqliteStatement::checkBindingValueMapIsEmpty(const RowDictionary &rowDictionary) const
|
||||||
|
{
|
||||||
|
if (rowDictionary.isEmpty())
|
||||||
|
throwException("SqliteStatement::bind: can't bind empty row!");
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SqliteStatement::isReadOnlyStatement() const
|
||||||
|
{
|
||||||
|
return sqlite3_stmt_readonly(compiledStatement.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
void SqliteStatement::throwException(const char *whatHasHappened)
|
||||||
|
{
|
||||||
|
throw SqliteException(whatHasHappened, sqlite3_errmsg(sqliteDatabaseHandle()));
|
||||||
|
}
|
||||||
|
|
||||||
|
QString SqliteStatement::columnName(int column) const
|
||||||
|
{
|
||||||
|
return QString::fromUtf8(sqlite3_column_name(compiledStatement.get(), column));
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool columnIsBlob(sqlite3_stmt *sqlStatment, int column)
|
||||||
|
{
|
||||||
|
return sqlite3_column_type(sqlStatment, column) == SQLITE_BLOB;
|
||||||
|
}
|
||||||
|
|
||||||
|
static QByteArray byteArrayForColumn(sqlite3_stmt *sqlStatment, int column)
|
||||||
|
{
|
||||||
|
if (columnIsBlob(sqlStatment, column)) {
|
||||||
|
const char *blob = static_cast<const char*>(sqlite3_column_blob(sqlStatment, column));
|
||||||
|
int size = sqlite3_column_bytes(sqlStatment, column);
|
||||||
|
|
||||||
|
return QByteArray(blob, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
return QByteArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
static QString textForColumn(sqlite3_stmt *sqlStatment, int column)
|
||||||
|
{
|
||||||
|
const QChar *text = static_cast<const QChar*>(sqlite3_column_text16(sqlStatment, column));
|
||||||
|
int size = sqlite3_column_bytes16(sqlStatment, column) / 2;
|
||||||
|
|
||||||
|
return QString(text, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Utf8String utf8TextForColumn(sqlite3_stmt *sqlStatment, int column)
|
||||||
|
{
|
||||||
|
const char *text = reinterpret_cast<const char*>(sqlite3_column_text(sqlStatment, column));
|
||||||
|
int size = sqlite3_column_bytes(sqlStatment, column);
|
||||||
|
|
||||||
|
return Utf8String(text, size);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static Utf8String convertedToUtf8StringForColumn(sqlite3_stmt *sqlStatment, int column)
|
||||||
|
{
|
||||||
|
int dataType = sqlite3_column_type(sqlStatment, column);
|
||||||
|
switch (dataType) {
|
||||||
|
case SQLITE_INTEGER: return Utf8String::fromByteArray(QByteArray::number(sqlite3_column_int64(sqlStatment, column)));
|
||||||
|
case SQLITE_FLOAT: return Utf8String::fromByteArray(QByteArray::number(sqlite3_column_double(sqlStatment, column)));
|
||||||
|
case SQLITE_BLOB: return Utf8String();
|
||||||
|
case SQLITE3_TEXT: return utf8TextForColumn(sqlStatment, column);
|
||||||
|
case SQLITE_NULL: return Utf8String();
|
||||||
|
}
|
||||||
|
|
||||||
|
Q_UNREACHABLE();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static QVariant variantForColumn(sqlite3_stmt *sqlStatment, int column)
|
||||||
|
{
|
||||||
|
int dataType = sqlite3_column_type(sqlStatment, column);
|
||||||
|
switch (dataType) {
|
||||||
|
case SQLITE_INTEGER: return QVariant::fromValue(sqlite3_column_int64(sqlStatment, column));
|
||||||
|
case SQLITE_FLOAT: return QVariant::fromValue(sqlite3_column_double(sqlStatment, column));
|
||||||
|
case SQLITE_BLOB: return QVariant::fromValue(byteArrayForColumn(sqlStatment, column));
|
||||||
|
case SQLITE3_TEXT: return QVariant::fromValue(textForColumn(sqlStatment, column));
|
||||||
|
case SQLITE_NULL: return QVariant();
|
||||||
|
}
|
||||||
|
|
||||||
|
Q_UNREACHABLE();
|
||||||
|
}
|
||||||
|
|
||||||
|
template<>
|
||||||
|
int SqliteStatement::value<int>(int column) const
|
||||||
|
{
|
||||||
|
checkIfIsReadyToFetchValues();
|
||||||
|
checkColumnIsValid(column);
|
||||||
|
return sqlite3_column_int(compiledStatement.get(), column);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<>
|
||||||
|
qint64 SqliteStatement::value<qint64>(int column) const
|
||||||
|
{
|
||||||
|
checkIfIsReadyToFetchValues();
|
||||||
|
checkColumnIsValid(column);
|
||||||
|
return sqlite3_column_int64(compiledStatement.get(), column);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<>
|
||||||
|
double SqliteStatement::value<double>(int column) const
|
||||||
|
{
|
||||||
|
checkIfIsReadyToFetchValues();
|
||||||
|
checkColumnIsValid(column);
|
||||||
|
return sqlite3_column_double(compiledStatement.get(), column);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<>
|
||||||
|
QByteArray SqliteStatement::value<QByteArray>(int column) const
|
||||||
|
{
|
||||||
|
checkIfIsReadyToFetchValues();
|
||||||
|
checkColumnIsValid(column);
|
||||||
|
return byteArrayForColumn(compiledStatement.get(), column);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<>
|
||||||
|
Utf8String SqliteStatement::value<Utf8String>(int column) const
|
||||||
|
{
|
||||||
|
checkIfIsReadyToFetchValues();
|
||||||
|
checkColumnIsValid(column);
|
||||||
|
return convertedToUtf8StringForColumn(compiledStatement.get(), column);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<>
|
||||||
|
QString SqliteStatement::value<QString>(int column) const
|
||||||
|
{
|
||||||
|
checkIfIsReadyToFetchValues();
|
||||||
|
checkColumnIsValid(column);
|
||||||
|
return textForColumn(compiledStatement.get(), column);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<>
|
||||||
|
QVariant SqliteStatement::value<QVariant>(int column) const
|
||||||
|
{
|
||||||
|
checkIfIsReadyToFetchValues();
|
||||||
|
checkColumnIsValid(column);
|
||||||
|
return variantForColumn(compiledStatement.get(), column);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename ContainerType>
|
||||||
|
ContainerType SqliteStatement::columnValues(const QVector<int> &columnIndices) const
|
||||||
|
{
|
||||||
|
typedef typename ContainerType::value_type ElementType;
|
||||||
|
ContainerType valueContainer;
|
||||||
|
valueContainer.reserve(columnIndices.count());
|
||||||
|
for (int columnIndex : columnIndices)
|
||||||
|
valueContainer += value<ElementType>(columnIndex);
|
||||||
|
|
||||||
|
return valueContainer;
|
||||||
|
}
|
||||||
|
|
||||||
|
QMap<QString, QVariant> SqliteStatement::rowColumnValueMap() const
|
||||||
|
{
|
||||||
|
QMap<QString, QVariant> values;
|
||||||
|
|
||||||
|
reset();
|
||||||
|
|
||||||
|
if (next()) {
|
||||||
|
for (int column = 0; column < columnCount(); column++)
|
||||||
|
values.insert(columnName(column), variantForColumn(compiledStatement.get(), column));
|
||||||
|
}
|
||||||
|
|
||||||
|
return values;
|
||||||
|
}
|
||||||
|
|
||||||
|
QMap<QString, QVariant> SqliteStatement::twoColumnValueMap() const
|
||||||
|
{
|
||||||
|
QMap<QString, QVariant> values;
|
||||||
|
|
||||||
|
reset();
|
||||||
|
|
||||||
|
while (next())
|
||||||
|
values.insert(textForColumn(compiledStatement.get(), 0), variantForColumn(compiledStatement.get(), 1));
|
||||||
|
|
||||||
|
return values;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename ContainerType>
|
||||||
|
ContainerType SqliteStatement::values(const QVector<int> &columns, int size) const
|
||||||
|
{
|
||||||
|
checkColumnsAreValid(columns);
|
||||||
|
|
||||||
|
ContainerType resultValues;
|
||||||
|
resultValues.reserve(size);
|
||||||
|
|
||||||
|
reset();
|
||||||
|
|
||||||
|
while (next()) {
|
||||||
|
resultValues += columnValues<ContainerType>(columns);
|
||||||
|
}
|
||||||
|
|
||||||
|
return resultValues;
|
||||||
|
}
|
||||||
|
|
||||||
|
template SQLITE_EXPORT QVector<QVariant> SqliteStatement::values<QVector<QVariant>>(const QVector<int> &columnIndices, int size) const;
|
||||||
|
template SQLITE_EXPORT QVector<Utf8String> SqliteStatement::values<QVector<Utf8String>>(const QVector<int> &columnIndices, int size) const;
|
||||||
|
|
||||||
|
template <typename ContainerType>
|
||||||
|
ContainerType SqliteStatement::values(int column) const
|
||||||
|
{
|
||||||
|
typedef typename ContainerType::value_type ElementType;
|
||||||
|
ContainerType resultValues;
|
||||||
|
|
||||||
|
reset();
|
||||||
|
|
||||||
|
while (next()) {
|
||||||
|
resultValues += value<ElementType>(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
return resultValues;
|
||||||
|
}
|
||||||
|
|
||||||
|
template SQLITE_EXPORT QVector<qint64> SqliteStatement::values<QVector<qint64>>(int column) const;
|
||||||
|
template SQLITE_EXPORT QVector<double> SqliteStatement::values<QVector<double>>(int column) const;
|
||||||
|
template SQLITE_EXPORT QVector<QByteArray> SqliteStatement::values<QVector<QByteArray>>(int column) const;
|
||||||
|
template SQLITE_EXPORT Utf8StringVector SqliteStatement::values<Utf8StringVector>(int column) const;
|
||||||
|
template SQLITE_EXPORT QVector<QString> SqliteStatement::values<QVector<QString>>(int column) const;
|
||||||
|
|
||||||
|
template <typename Type>
|
||||||
|
Type SqliteStatement::toValue(const Utf8String &sqlStatementUtf8)
|
||||||
|
{
|
||||||
|
SqliteStatement statement(sqlStatementUtf8);
|
||||||
|
|
||||||
|
statement.next();
|
||||||
|
|
||||||
|
return statement.value<Type>(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
template SQLITE_EXPORT int SqliteStatement::toValue<int>(const Utf8String &sqlStatementUtf8);
|
||||||
|
template SQLITE_EXPORT qint64 SqliteStatement::toValue<qint64>(const Utf8String &sqlStatementUtf8);
|
||||||
|
template SQLITE_EXPORT double SqliteStatement::toValue<double>(const Utf8String &sqlStatementUtf8);
|
||||||
|
template SQLITE_EXPORT QString SqliteStatement::toValue<QString>(const Utf8String &sqlStatementUtf8);
|
||||||
|
template SQLITE_EXPORT QByteArray SqliteStatement::toValue<QByteArray>(const Utf8String &sqlStatementUtf8);
|
||||||
|
template SQLITE_EXPORT Utf8String SqliteStatement::toValue<Utf8String>(const Utf8String &sqlStatementUtf8);
|
||||||
|
template SQLITE_EXPORT QVariant SqliteStatement::toValue<QVariant>(const Utf8String &sqlStatementUtf8);
|
||||||
|
|
138
src/libs/sqlite/sqlitestatement.h
Normal file
138
src/libs/sqlite/sqlitestatement.h
Normal file
@@ -0,0 +1,138 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 The Qt Company Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and Digia. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/licensing. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, Digia gives you certain additional
|
||||||
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef SQLITESTATEMENT_H
|
||||||
|
#define SQLITESTATEMENT_H
|
||||||
|
|
||||||
|
#include <type_traits>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
#include <QVariant>
|
||||||
|
#include <QVector>
|
||||||
|
|
||||||
|
#include "sqliteglobal.h"
|
||||||
|
|
||||||
|
struct sqlite3_stmt;
|
||||||
|
struct sqlite3;
|
||||||
|
|
||||||
|
#include "sqliteexception.h"
|
||||||
|
#include "utf8stringvector.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class SQLITE_EXPORT SqliteStatement
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
explicit SqliteStatement(const Utf8String &sqlStatementUtf8);
|
||||||
|
|
||||||
|
static void deleteCompiledStatement(sqlite3_stmt *compiledStatement);
|
||||||
|
|
||||||
|
bool next() const;
|
||||||
|
void step() const;
|
||||||
|
void reset() const;
|
||||||
|
|
||||||
|
template<typename Type>
|
||||||
|
Type value(int column) const;
|
||||||
|
int columnCount() const;
|
||||||
|
Utf8StringVector columnNames() const;
|
||||||
|
|
||||||
|
void bind(int index, int value);
|
||||||
|
void bind(int index, qint64 value);
|
||||||
|
void bind(int index, double value);
|
||||||
|
void bind(int index, const QString &text);
|
||||||
|
void bind(int index, const QByteArray &blob);
|
||||||
|
void bind(int index, const QVariant &value);
|
||||||
|
|
||||||
|
template <typename Type>
|
||||||
|
void bind(const Utf8String &name, const Type &value);
|
||||||
|
|
||||||
|
int bindingIndexForName(const Utf8String &name);
|
||||||
|
|
||||||
|
void bind(const RowDictionary &rowDictionary);
|
||||||
|
void bindUnchecked(const RowDictionary &rowDictionary);
|
||||||
|
|
||||||
|
void setBindingColumnNames(const Utf8StringVector &bindingColumnNames);
|
||||||
|
const Utf8StringVector &bindingColumnNames() const;
|
||||||
|
|
||||||
|
template <typename ContainerType>
|
||||||
|
ContainerType values(const QVector<int> &columns, int size = 0) const;
|
||||||
|
|
||||||
|
template <typename ContainerType>
|
||||||
|
ContainerType values(int column = 0) const;
|
||||||
|
|
||||||
|
QMap<QString, QVariant> rowColumnValueMap() const;
|
||||||
|
QMap<QString, QVariant> twoColumnValueMap() const;
|
||||||
|
|
||||||
|
static void execute(const Utf8String &sqlStatementUtf8);
|
||||||
|
|
||||||
|
template <typename Type>
|
||||||
|
static Type toValue(const Utf8String &sqlStatementUtf8);
|
||||||
|
|
||||||
|
void prepare(const Utf8String &sqlStatementUtf8);
|
||||||
|
void waitForUnlockNotify() const;
|
||||||
|
|
||||||
|
void write(const RowDictionary &rowDictionary);
|
||||||
|
void writeUnchecked(const RowDictionary &rowDictionary);
|
||||||
|
|
||||||
|
static sqlite3 *sqliteDatabaseHandle();
|
||||||
|
static TextEncoding databaseTextEncoding();
|
||||||
|
|
||||||
|
|
||||||
|
bool checkForStepError(int resultCode) const;
|
||||||
|
void checkForPrepareError(int resultCode) const;
|
||||||
|
void setIfIsReadyToFetchValues(int resultCode) const;
|
||||||
|
void checkIfIsReadyToFetchValues() const;
|
||||||
|
void checkColumnsAreValid(const QVector<int> &columns) const;
|
||||||
|
void checkColumnIsValid(int column) const;
|
||||||
|
void checkBindingIndex(int index) const;
|
||||||
|
void checkBindingName(int index) const;
|
||||||
|
void checkParameterCanBeBound(const RowDictionary &rowDictionary, const Utf8String &columnName);
|
||||||
|
void setBindingParameterCount();
|
||||||
|
void setBindingColumnNamesFromStatement();
|
||||||
|
void setColumnCount();
|
||||||
|
void checkBindingValueMapIsEmpty(const RowDictionary &rowDictionary) const;
|
||||||
|
bool isReadOnlyStatement() const;
|
||||||
|
Q_NORETURN static void throwException(const char *whatHasHappened);
|
||||||
|
|
||||||
|
template <typename ContainerType>
|
||||||
|
ContainerType columnValues(const QVector<int> &columnIndices) const;
|
||||||
|
|
||||||
|
QString columnName(int column) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::unique_ptr<sqlite3_stmt, void (*)(sqlite3_stmt*)> compiledStatement;
|
||||||
|
Utf8StringVector bindingColumnNames_;
|
||||||
|
int bindingParameterCount;
|
||||||
|
int columnCount_;
|
||||||
|
mutable bool isReadyToFetchValues;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SQLITESTATEMENT_H
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user