diff options
| author | Joshua Peek <josh@joshpeek.com> | 2012-08-27 11:33:28 -0500 |
|---|---|---|
| committer | Joshua Peek <josh@joshpeek.com> | 2012-08-27 11:33:28 -0500 |
| commit | 458890b4b9d90f3c3f9d24ac5c61f97385b84e34 (patch) | |
| tree | 604383e04a2ed7077cc282ca8af31da1346fe5a7 | |
| parent | 89267f792d0dc125f0de324521be78cf9423d731 (diff) | |
Add C++ sample
| -rw-r--r-- | lib/linguist/samples.json | 136 | ||||
| -rw-r--r-- | samples/C++/gdsdbreader.h | 69 |
2 files changed, 166 insertions, 39 deletions
diff --git a/lib/linguist/samples.json b/lib/linguist/samples.json index 3bb831b..b39aa80 100644 --- a/lib/linguist/samples.json +++ b/lib/linguist/samples.json @@ -257,8 +257,8 @@ ".gemrc" ] }, - "tokens_total": 269224, - "languages_total": 273, + "tokens_total": 269398, + "languages_total": 274, "tokens": { "Apex": { "global": 70, @@ -5573,19 +5573,19 @@ "yajl_free_error": 1 }, "C++": { - "class": 31, + "class": 32, "Bar": 2, - "{": 294, + "{": 298, "protected": 4, "char": 34, "*name": 2, - ";": 831, - "public": 23, + ";": 848, + "public": 24, "void": 65, "hello": 2, - "(": 888, - ")": 891, - "}": 296, + "(": 894, + ")": 896, + "}": 300, "foo": 2, "cudaArray*": 1, "cu_array": 4, @@ -5599,7 +5599,7 @@ "cudaCreateChannelDesc": 1, "<float>": 1, "cudaMallocArray": 1, - "&": 84, + "&": 87, "width": 5, "height": 5, "cudaMemcpyToArray": 1, @@ -5615,7 +5615,7 @@ "cudaFilterModePoint": 1, "tex.normalized": 1, "false": 40, - "//": 227, + "//": 230, "do": 2, "not": 2, "normalize": 1, @@ -5630,7 +5630,7 @@ "/": 9, "blockDim.y": 2, "kernel": 2, - "<<": 5, + "<<": 16, "<": 27, "d_data": 1, "cudaUnbindTexture": 1, @@ -5646,12 +5646,12 @@ "y": 4, "blockIdx.y*blockDim.y": 1, "threadIdx.y": 1, - "if": 137, + "if": 138, "&&": 13, "c": 52, "tex2D": 1, "y*width": 1, - "#include": 77, + "#include": 79, "<QCoreApplication>": 1, "<QString>": 1, "<QVariantMap>": 2, @@ -5664,7 +5664,7 @@ "instance": 4, "env_instance": 3, "new": 2, - "return": 112, + "return": 114, "QObject": 2, "QCoreApplication": 1, "parse": 3, @@ -5672,7 +5672,7 @@ "**envp": 1, "**env": 1, "**": 2, - "QString": 19, + "QString": 20, "envvar": 2, "name": 3, "value": 5, @@ -5689,14 +5689,89 @@ "QVariantMap": 3, "asVariantMap": 2, "m_map": 2, - "#ifndef": 7, + "#ifndef": 8, "ENV_H": 3, - "#define": 7, + "#define": 9, "<QObject>": 1, "Q_OBJECT": 1, "*instance": 1, "private": 10, - "#endif": 18, + "#endif": 19, + "GDSDBREADER_H": 3, + "<QDir>": 1, + "GDS_DIR": 1, + "enum": 6, + "level": 1, + "LEVEL_ONE": 1, + "LEVEL_TWO": 1, + "LEVEL_THREE": 1, + "dbDataStructure": 2, + "label": 1, + "quint32": 3, + "depth": 1, + "userIndex": 1, + "QByteArray": 1, + "data": 2, + "This": 4, + "is": 33, + "COMPRESSED": 1, + "optimize": 1, + "ram": 1, + "and": 14, + "disk": 1, + "space": 2, + "decompressed": 1, + "quint64": 1, + "uniqueID": 1, + "QVector": 2, + "<dbDataStructure*>": 1, + "nextItems": 1, + "<quint32>": 1, + "nextItemsIndices": 1, + "dbDataStructure*": 1, + "father": 1, + "fatherIndex": 1, + "bool": 92, + "noFatherRoot": 1, + "Used": 1, + "to": 74, + "tell": 1, + "this": 4, + "node": 1, + "the": 178, + "root": 1, + "so": 1, + "hasn": 1, + "t": 8, + "in": 9, + "argument": 1, + "list": 2, + "of": 44, + "an": 2, + "operator": 9, + "overload.": 1, + "A": 1, + "friend": 7, + "stream": 4, + "myclass.label": 2, + "myclass.depth": 2, + "myclass.userIndex": 2, + "qCompress": 2, + "myclass.data": 4, + "myclass.uniqueID": 2, + "myclass.nextItemsIndices": 2, + "myclass.fatherIndex": 2, + "myclass.noFatherRoot": 2, + "myclass.fileName": 2, + "myclass.firstLineData": 4, + "myclass.linesNumbers": 2, + "QDataStream": 2, + "myclass": 1, + "//Don": 1, + "read": 1, + "it": 2, + "either": 1, + "qUncompress": 2, "<iostream>": 1, "using": 1, "namespace": 14, @@ -5806,7 +5881,6 @@ "EC_KEY_dup": 1, "b.pkey": 2, "b.fSet": 2, - "operator": 7, "EC_KEY_copy": 1, "hash": 20, "sizeof": 6, @@ -5815,11 +5889,9 @@ "vchSig.clear": 2, "vchSig.resize": 2, "Shrink": 1, - "to": 73, "fit": 1, "actual": 1, "size": 1, - "bool": 91, "SignCompact": 2, "uint256": 10, "vector": 14, @@ -5837,7 +5909,6 @@ "keyRec": 5, "1": 2, "GetPubKey": 5, - "this": 3, "break": 30, "BN_bn2bin": 2, "/8": 2, @@ -5873,11 +5944,9 @@ "str": 2, "CKeyID": 5, "uint160": 8, - "in": 8, "CScriptID": 3, "CPubKey": 11, "vchPubKey": 6, - "friend": 5, "vchPubKeyIn": 2, "a": 34, "a.vchPubKey": 3, @@ -5916,15 +5985,12 @@ "QT_VERSION_CHECK": 1, "#error": 2, "Something": 1, - "is": 30, "wrong": 1, "with": 3, - "the": 176, "setup.": 1, "Please": 1, "report": 2, "mailing": 1, - "list": 1, "argc": 2, "char**": 2, "argv": 2, @@ -5964,7 +6030,6 @@ "The": 8, "QsciCommand": 7, "represents": 1, - "an": 1, "internal": 10, "editor": 1, "command": 9, @@ -5981,20 +6046,16 @@ "are": 3, "provided": 1, "change": 1, - "and": 13, "remove": 1, "binding.": 1, "Each": 1, "has": 2, "user": 2, "friendly": 2, - "of": 43, "use": 1, "mapping": 1, "dialogs.": 1, "QSCINTILLA_EXPORT": 2, - "This": 3, - "enum": 5, "defines": 1, "different": 1, "commands": 1, @@ -6392,10 +6453,8 @@ "draw": 1, "text.": 3, "should": 1, - "it": 1, "necessary": 1, "reserve": 1, - "space": 1, "By": 1, "default": 3, "relative": 1, @@ -6572,7 +6631,6 @@ "IsLineFeed": 2, "fall": 2, "through": 2, - "t": 6, "u": 6, "v": 3, "xx": 1, @@ -27345,7 +27403,7 @@ "Arduino": 20, "AutoHotkey": 3, "C": 49038, - "C++": 9539, + "C++": 9713, "Ceylon": 50, "CoffeeScript": 2955, "Coq": 18259, @@ -27415,7 +27473,7 @@ "Arduino": 1, "AutoHotkey": 1, "C": 23, - "C++": 16, + "C++": 17, "Ceylon": 1, "CoffeeScript": 9, "Coq": 12, @@ -27479,5 +27537,5 @@ "XSLT": 1, "YAML": 1 }, - "md5": "0dd037f8ae8057afc1213dc441839d99" + "md5": "ca1d189ca79aa9c52370da78f2c2b4dd" }
\ No newline at end of file diff --git a/samples/C++/gdsdbreader.h b/samples/C++/gdsdbreader.h new file mode 100644 index 0000000..6646f6d --- /dev/null +++ b/samples/C++/gdsdbreader.h @@ -0,0 +1,69 @@ +#ifndef GDSDBREADER_H
+#define GDSDBREADER_H
+
+// This file contains core structures, classes and types for the entire gds app
+// WARNING: DO NOT MODIFY UNTIL IT'S STRICTLY NECESSARY
+
+#include <QDir>
+#include "diagramwidget/qgldiagramwidget.h"
+
+#define GDS_DIR "gdsdata"
+
+enum level {LEVEL_ONE, LEVEL_TWO, LEVEL_THREE};
+
+// The internal structure of the db to store information about each node (each level)
+// this will be serialized before being written to file
+class dbDataStructure
+{
+public:
+ QString label;
+ quint32 depth;
+ quint32 userIndex;
+ QByteArray data; // This is COMPRESSED data, optimize ram and disk space, is decompressed
+ // just when needed (to display the comments)
+
+ // The following ID is used to create second-third level files
+ quint64 uniqueID;
+ // All the next items linked to this one
+ QVector<dbDataStructure*> nextItems;
+ // Corresponding indices vector (used to store data)
+ QVector<quint32> nextItemsIndices;
+ // The father element (or NULL if it's root)
+ dbDataStructure* father;
+ // Corresponding indices vector (used to store data)
+ quint32 fatherIndex;
+ bool noFatherRoot; // Used to tell if this node is the root (so hasn't a father)
+
+ // These fields will be useful for levels 2 and 3
+ QString fileName; // Relative filename for the associated code file
+ QByteArray firstLineData; // Compressed first line data, this will be used with the line number to retrieve info
+ QVector<quint32> linesNumbers; // First and next lines (next are relative to the first) numbers
+
+ // -- Generic system data not to be stored on disk
+ void *glPointer; // GL pointer
+
+ // These operator overrides prevent the glPointer and other non-disk-necessary data serialization
+ friend QDataStream& operator<<(QDataStream& stream, const dbDataStructure& myclass)
+ // Notice: this function has to be "friend" because it cannot be a member function, member functions
+ // have an additional parameter "this" which isn't in the argument list of an operator overload. A friend
+ // function has full access to private data of the class without having the "this" argument
+ {
+ // Don't write glPointer and every pointer-dependent structure
+ return stream << myclass.label << myclass.depth << myclass.userIndex << qCompress(myclass.data)
+ << myclass.uniqueID << myclass.nextItemsIndices << myclass.fatherIndex << myclass.noFatherRoot
+ << myclass.fileName << qCompress(myclass.firstLineData) << myclass.linesNumbers;
+ }
+ friend QDataStream& operator>>(QDataStream& stream, dbDataStructure& myclass)
+ {
+ //Don't read it, either
+ stream >> myclass.label >> myclass.depth >> myclass.userIndex >> myclass.data
+ >> myclass.uniqueID >> myclass.nextItemsIndices >> myclass.fatherIndex >> myclass.noFatherRoot
+ >> myclass.fileName >> myclass.firstLineData >> myclass.linesNumbers;
+ myclass.data = qUncompress(myclass.data);
+ myclass.firstLineData = qUncompress(myclass.firstLineData);
+ return stream;
+ }
+
+};
+
+#endif // GDSDBREADER_H
|
