예제 #1
0
        /* Function: GetInfoOnLinksThatResolveToTopicID
         *
         * Returns aggregate information on all links that resolve to the passed topic ID.
         *
         * Parameters:
         *
         *		topicID - The topic ID to look up links for.
         *		fileIDs - The file IDs of all the links.  Will be null if none.
         *		classIDs - The class IDs of all the links.  Will be null if none.
         *
         */
        public void GetInfoOnLinksThatResolveToTopicID(int topicID, out IDObjects.NumberSet fileIDs, out IDObjects.NumberSet classIDs)
        {
            accessor.RequireAtLeast(Accessor.LockType.ReadOnly);

            fileIDs  = null;
            classIDs = null;

            using (SQLite.Query query = accessor.Connection.Query("SELECT FileID, ClassID FROM Links WHERE TargetTopicID=?", topicID))
            {
                while (query.Step())
                {
                    if (fileIDs == null)
                    {
                        fileIDs = new NumberSet();
                    }

                    fileIDs.Add(query.IntColumn(0));

                    int classID = query.IntColumn(1);

                    if (classID != 0)
                    {
                        if (classIDs == null)
                        {
                            classIDs = new NumberSet();
                        }

                        classIDs.Add(classID);
                    }
                }
            }
        }
예제 #2
0
        /* Function: Query
         * Creates and returns a <SQLite.Query> object for the passed statement and values.
         */
        public SQLite.Query Query(string statement, params Object[] values)
        {
            SQLite.Query query = new SQLite.Query();
            query.Prepare(handle, statement, values);

            return(query);
        }
예제 #3
0
 /* Function: GetVersion
  * Retrieves the database version.
  */
 protected Version GetVersion()
 {
     using (SQLite.Query query = connection.Query("SELECT Version FROM System"))
     {
         query.Step();
         return(new Version(query.StringColumn(0)));
     }
 }
예제 #4
0
 /* Function: Execute
  * Executes a SQL statement where no result is required.
  */
 public void Execute(string statement, params Object[] values)
 {
     using (SQLite.Query query = new SQLite.Query())
     {
         query.Prepare(handle, statement, values);
         while (query.Step() == true)
         {
         }
     }
 }
예제 #5
0
        /* Function: LoadSystemVariables
         *
         * Retrieves various system variables from the database.  This currently includes:
         *
         *		- <UsedTopicIDs>
         *		- <UsedLinkIDs>
         *		- <UsedClassIDs>
         *		- <UsedContextIDs>
         */
        protected void LoadSystemVariables()
        {
            using (SQLite.Query query = connection.Query("SELECT UsedTopicIDs, UsedLinkIDs, UsedClassIDs, UsedContextIDs from System"))
            {
                query.Step();

                usedTopicIDs   = IDObjects.NumberSet.FromString(query.NextStringColumn());
                usedLinkIDs    = IDObjects.NumberSet.FromString(query.NextStringColumn());
                usedClassIDs   = IDObjects.NumberSet.FromString(query.NextStringColumn());
                usedContextIDs = IDObjects.NumberSet.FromString(query.NextStringColumn());
            }
        }
예제 #6
0
        /* Function: LoadSystemVariables
         *
         * Retrieves various system variables from the database.  This currently includes:
         *
         *		- <UsedTopicIDs>
         *		- <UsedLinkIDs>
         *		- <UsedImageLinkIDs>
         *		- <UsedClassIDs>
         *		- <UsedContextIDs>
         */
        protected void LoadSystemVariables()
        {
            using (SQLite.Query query = connection.Query("SELECT UsedTopicIDs, UsedLinkIDs, UsedimageLinkIDs, UsedClassIDs, UsedContextIDs " +
                                                         "from System"))
            {
                query.Step();

                usedTopicIDs.SetTo(query.NextStringColumn());
                usedLinkIDs.SetTo(query.NextStringColumn());
                usedImageLinkIDs.SetTo(query.NextStringColumn());
                usedClassIDs.SetTo(query.NextStringColumn());
                usedContextIDs.SetTo(query.NextStringColumn());
            }
        }
예제 #7
0
        /* Function: GetFileIDsThatDefineClassID
         * Returns the file IDs that contain topics which define the class ID.
         */
        public NumberSet GetFileIDsThatDefineClassID(int classID)
        {
            accessor.RequireAtLeast(Accessor.LockType.ReadOnly);

            NumberSet fileIDs = new NumberSet();

            using (SQLite.Query query = accessor.Connection.Query("SELECT FileID FROM Topics WHERE ClassID=? AND DefinesClass=1", classID))
            {
                while (query.Step())
                {
                    fileIDs.Add(query.IntColumn(0));
                }
            }

            return(fileIDs);
        }
예제 #8
0
        /* Function: GetInfoOnClassParents
         * Looks up the parents of the passed class ID and returns their class IDs and all the file IDs that define them.
         */
        public void GetInfoOnClassParents(int classID, out NumberSet parentClassIDs, out NumberSet parentClassFileIDs)
        {
            accessor.RequireAtLeast(Accessor.LockType.ReadOnly);

            parentClassIDs     = new NumberSet();
            parentClassFileIDs = new NumberSet();

            using (SQLite.Query query = accessor.Connection.Query("SELECT TargetClassID FROM Links " +
                                                                  "WHERE ClassID=? AND Type=? AND TargetClassID != 0",
                                                                  classID, (int)Links.LinkType.ClassParent))
            {
                while (query.Step())
                {
                    parentClassIDs.Add(query.IntColumn(0));
                }
            }

            if (parentClassIDs.IsEmpty)
            {
                return;
            }

            IDObjects.NumberSet remainingParentClassIDs = parentClassIDs;

            do
            {
                IDObjects.NumberSet temp;
                string queryText = "SELECT FileID FROM Topics WHERE " + Accessor.ColumnIsInNumberSetExpression("ClassID", remainingParentClassIDs, out temp) + " AND DefinesClass=1";
                remainingParentClassIDs = temp;

                using (SQLite.Query query = accessor.Connection.Query(queryText))
                {
                    while (query.Step())
                    {
                        parentClassFileIDs.Add(query.IntColumn(0));
                    }
                }
            }while (remainingParentClassIDs != null);
        }
예제 #9
0
        /* Function: GetInfoOnClassParents
         * Looks up the parents of the passed class ID and returns their class IDs and all the file IDs that define them.
         */
        public void GetInfoOnClassParents(int classID, out NumberSet parentClassIDs, out NumberSet parentClassFileIDs)
        {
            accessor.RequireAtLeast(Accessor.LockType.ReadOnly);

            parentClassIDs     = new NumberSet();
            parentClassFileIDs = new NumberSet();

            using (SQLite.Query query = accessor.Connection.Query("SELECT TargetClassID FROM Links " +
                                                                  "WHERE ClassID=? AND Type=? AND TargetClassID != 0",
                                                                  classID, (int)Links.LinkType.ClassParent))
            {
                while (query.Step())
                {
                    parentClassIDs.Add(query.IntColumn(0));
                }
            }

            if (parentClassIDs.IsEmpty)
            {
                return;
            }

            StringBuilder queryText   = new StringBuilder("SELECT FileID FROM Topics WHERE (");
            List <object> queryParams = new List <object>();

            Accessor.AppendWhereClause_ColumnIsInNumberSet("ClassID", parentClassIDs, queryText, queryParams);

            queryText.Append(") AND DefinesClass=1");

            using (SQLite.Query query = accessor.Connection.Query(queryText.ToString(), queryParams.ToArray()))
            {
                while (query.Step())
                {
                    parentClassFileIDs.Add(query.IntColumn(0));
                }
            }
        }
예제 #10
0
        /* Function: GetInfoOnLinksToTopicsWithNDLinkInSummary
         *
         * What the hell?  Okay, check this out: First it finds the topics which have the passed Natural Docs link in their
         * summaries.  Then it returns aggregate information on all links that resolve to any of those topics.  This is needed
         * for keeping tooltips accurate with differential building.  It makes sense, trust me.
         *
         * Parameters:
         *
         *		link - The link to look up.  It must be a Natural Docs link.
         *		fileIDs - The file IDs of all the links that resolve to the topics that have the link in the summary.  Will be null if none.
         *		classIDs - The class IDs of all the links that resolve to the topics that have the link in the summary.  Will be null if none.
         *
         */
        public void GetInfoOnLinksToTopicsWithNDLinkInSummary(Link link, out IDObjects.NumberSet fileIDs, out IDObjects.NumberSet classIDs)
        {
                        #if DEBUG
            if (link.Type != LinkType.NaturalDocs)
            {
                throw new InvalidOperationException("GetInfoOnLinksToTopicsWithNDLinkInSummary() must be used with Natural Docs links.  It's right there in the title, derp.");
            }
                        #endif

            accessor.RequireAtLeast(Accessor.LockType.ReadOnly);

            fileIDs  = null;
            classIDs = null;

            IDObjects.NumberSet topicIDs = null;
            string likeText = "%<link type=\"naturaldocs\" originaltext=\"" + link.Text.EntityEncode() + "\"%";

            using (SQLite.Query query = accessor.Connection.Query("SELECT TopicID FROM Topics WHERE FileID=? AND Summary LIKE ?",
                                                                  link.FileID, likeText))
            {
                while (query.Step())
                {
                    if (topicIDs == null)
                    {
                        topicIDs = new NumberSet();
                    }

                    topicIDs.Add(query.IntColumn(0));
                }
            }

            if (topicIDs == null)
            {
                return;
            }

            IDObjects.NumberSet remainingTopicIDs = topicIDs;

            do
            {
                IDObjects.NumberSet temp;
                string queryText = "SELECT FileID, ClassID FROM Links WHERE " + Accessor.ColumnIsInNumberSetExpression("TargetTopicID", remainingTopicIDs, out temp);
                remainingTopicIDs = temp;

                using (SQLite.Query query = accessor.Connection.Query(queryText))
                {
                    while (query.Step())
                    {
                        if (fileIDs == null)
                        {
                            fileIDs = new NumberSet();
                        }

                        fileIDs.Add(query.IntColumn(0));

                        int classID = query.IntColumn(1);

                        if (classID != 0)
                        {
                            if (classIDs == null)
                            {
                                classIDs = new NumberSet();
                            }

                            classIDs.Add(classID);
                        }
                    }
                }
            }while (remainingTopicIDs != null);
        }
예제 #11
0
        /* Function: GetInfoOnLinksToTopicsWithImageLinkInSummary
         *
         * What the hell?  Okay, check this out: First it finds the topics which have the passed image link in their summaries.
         * Then it returns aggregate information on all links that resolve to any of those topics.  This is needed for keeping
         * tooltips accurate with differential building.  It makes sense, trust me.
         *
         * Parameters:
         *
         *		imageLink - The image link to look up.
         *		fileIDs - The file IDs of all the links that resolve to the topics that have the link in the summary.  Will be null if none.
         *		classIDs - The class IDs of all the links that resolve to the topics that have the link in the summary.  Will be null if none.
         *
         */
        public void GetInfoOnLinksToTopicsWithImageLinkInSummary(ImageLink imageLink, out IDObjects.NumberSet fileIDs, out IDObjects.NumberSet classIDs)
        {
            accessor.RequireAtLeast(Accessor.LockType.ReadOnly);

            fileIDs  = null;
            classIDs = null;


            // First find all the topics that have the image link in the summary.  We can restrict the search to the same file ID as the link
            // because links appearing in a different file would be seen as a different link.  Only inline image links can appear in the
            // summary so we don't need to orry about standalone ones.

            IDObjects.NumberSet topicIDs = null;
            string likeText = "%<image type=\"inline\" originaltext=\"" + imageLink.OriginalText.EntityEncode() + "\"%";

            using (SQLite.Query query = accessor.Connection.Query("SELECT TopicID FROM Topics WHERE FileID=? AND Summary LIKE ?",
                                                                  imageLink.FileID, likeText))
            {
                while (query.Step())
                {
                    if (topicIDs == null)
                    {
                        topicIDs = new NumberSet();
                    }

                    topicIDs.Add(query.IntColumn(0));
                }
            }

            if (topicIDs == null)
            {
                return;
            }


            // Now find all the links that resolve to these topics.  We only need their file and class IDs though.

            IDObjects.NumberSet remainingTopicIDs = topicIDs;

            do
            {
                IDObjects.NumberSet temp;
                string queryText = "SELECT FileID, ClassID FROM Links WHERE " + Accessor.ColumnIsInNumberSetExpression("TargetTopicID", remainingTopicIDs, out temp);
                remainingTopicIDs = temp;

                using (SQLite.Query query = accessor.Connection.Query(queryText))
                {
                    while (query.Step())
                    {
                        if (fileIDs == null)
                        {
                            fileIDs = new NumberSet();
                        }

                        fileIDs.Add(query.IntColumn(0));

                        int classID = query.IntColumn(1);

                        if (classID != 0)
                        {
                            if (classIDs == null)
                            {
                                classIDs = new NumberSet();
                            }

                            classIDs.Add(classID);
                        }
                    }
                }
            }while (remainingTopicIDs != null);
        }
예제 #12
0
        /* Function: GetInfoOnLinksToTopicsWithNDLinkInSummary
         *
         * What the hell?  Okay, check this out: First it finds the topics which have the passed Natural Docs link in their
         * summaries.  Then it returns aggregate information on all links that resolve to any of those topics.  This is needed
         * for keeping tooltips accurate with differential building.  It makes sense, trust me.
         *
         * Parameters:
         *
         *		link - The link to look up.  It must be a Natural Docs link.
         *		fileIDs - The file IDs of all the links that resolve to the topics that have the link in the summary.  Will be null if none.
         *		classIDs - The class IDs of all the links that resolve to the topics that have the link in the summary.  Will be null if none.
         *
         */
        public void GetInfoOnLinksToTopicsWithNDLinkInSummary(Link link, out IDObjects.NumberSet fileIDs, out IDObjects.NumberSet classIDs)
        {
                        #if DEBUG
            if (link.Type != LinkType.NaturalDocs)
            {
                throw new InvalidOperationException("GetInfoOnLinksToTopicsWithNDLinkInSummary() must be used with Natural Docs links.  It's right there in the title, derp.");
            }
                        #endif

            accessor.RequireAtLeast(Accessor.LockType.ReadOnly);

            fileIDs  = null;
            classIDs = null;

            IDObjects.NumberSet topicIDs = null;
            string likeText = "%<link type=\"naturaldocs\" originaltext=\"" + link.Text.EntityEncode() + "\"%";

            using (SQLite.Query query = accessor.Connection.Query("SELECT TopicID FROM Topics WHERE FileID=? AND Summary LIKE ?",
                                                                  link.FileID, likeText))
            {
                while (query.Step())
                {
                    if (topicIDs == null)
                    {
                        topicIDs = new NumberSet();
                    }

                    topicIDs.Add(query.IntColumn(0));
                }
            }

            if (topicIDs == null)
            {
                return;
            }

            StringBuilder queryText   = new StringBuilder("SELECT FileID, ClassID FROM Links WHERE ");
            List <object> queryParams = new List <object>();

            CodeDB.Accessor.AppendWhereClause_ColumnIsInNumberSet("TargetTopicID", topicIDs, queryText, queryParams);

            using (SQLite.Query query = accessor.Connection.Query(queryText.ToString(), queryParams.ToArray()))
            {
                while (query.Step())
                {
                    if (fileIDs == null)
                    {
                        fileIDs = new NumberSet();
                    }

                    fileIDs.Add(query.IntColumn(0));

                    int classID = query.IntColumn(1);

                    if (classID != 0)
                    {
                        if (classIDs == null)
                        {
                            classIDs = new NumberSet();
                        }

                        classIDs.Add(classID);
                    }
                }
            }
        }