Orb/Doxygen/src/indexlog.cpp
changeset 0 42188c7ea2d9
equal deleted inserted replaced
-1:000000000000 0:42188c7ea2d9
       
     1 /*
       
     2  * Copyright (C) 2008 by Sebastian Pipping.
       
     3  * Copyright (C) 2008 Dimitri van Heesch.
       
     4  *
       
     5  * Permission to use, copy, modify, and distribute this software and its
       
     6  * documentation under the terms of the GNU General Public License is hereby 
       
     7  * granted. No representations are made about the suitability of this software 
       
     8  * for any purpose. It is provided "as is" without express or implied warranty.
       
     9  * See the GNU General Public License for more details.
       
    10  *
       
    11  * Documents produced by Doxygen are derivative works derived from the
       
    12  * input used in their production; they are not affected by this license.
       
    13  *
       
    14  * Sebastian Pipping <sebastian@pipping.org>
       
    15  */
       
    16 
       
    17 #include "indexlog.h"
       
    18 #include "message.h"
       
    19 #include "config.h"
       
    20 
       
    21 #include <qstring.h>
       
    22 #include <qfile.h>
       
    23 
       
    24 
       
    25 IndexLog::IndexLog()
       
    26 {
       
    27 }
       
    28 
       
    29 IndexLog::~IndexLog()
       
    30 {
       
    31 }
       
    32 
       
    33 void IndexLog::initialize()
       
    34 {
       
    35   char const * const attributes[] =
       
    36   { "xmlns", 
       
    37     "http://doxygen.org/xmlns/indexlog/1/0/",
       
    38      NULL 
       
    39   };
       
    40   m_out.open("log", attributes);
       
    41 
       
    42   openMethodCall("initialize");
       
    43   closeMethodCall();
       
    44 }
       
    45 
       
    46 void IndexLog::finalize()
       
    47 {
       
    48   openMethodCall("finalize");
       
    49   closeMethodCall();
       
    50   m_out.close("log");
       
    51   QCString fileName = Config_getString("HTML_OUTPUT")+"/index.log.xml";
       
    52   QFile file(fileName);
       
    53   if (!file.open(IO_WriteOnly))
       
    54   {
       
    55     err("Could not open file %s for writing\n", fileName.data());
       
    56     exit(1);
       
    57   }
       
    58   m_out.dumpTo(file);
       
    59   file.flush();
       
    60   file.close();
       
    61 }
       
    62 
       
    63 void IndexLog::incContentsDepth()
       
    64 {
       
    65   openMethodCall("incContentsDepth");
       
    66   closeMethodCall();
       
    67 }
       
    68 
       
    69 void IndexLog::decContentsDepth()
       
    70 {
       
    71   openMethodCall("decContentsDepth");
       
    72   closeMethodCall();
       
    73 }
       
    74 
       
    75 void IndexLog::addContentsItem(bool isDir, char const * name,
       
    76                                   char const * ref, char const * file, 
       
    77                                   char const * anchor)
       
    78 {
       
    79   openMethodCall("addContentsItem");
       
    80   addBoolParameter("isDir", isDir);
       
    81   addStringParameter("name", name);
       
    82   addStringParameter("ref", ref);
       
    83   addStringParameter("file", file);
       
    84   addStringParameter("anchor", anchor);
       
    85   closeMethodCall();
       
    86 }
       
    87 
       
    88 void IndexLog::addIndexItem(char const * level1, char const * level2,
       
    89                                char const * contRef, char const * memRef, 
       
    90                                char const * anchor, const MemberDef * md)
       
    91 {
       
    92   openMethodCall("addIndexItem");
       
    93   addStringParameter("level1", level1);
       
    94   addStringParameter("level2", level2);
       
    95   addStringParameter("contRef", contRef);
       
    96   addStringParameter("memRef", memRef);
       
    97   addStringParameter("anchor", anchor);
       
    98   addMemberDefParameter("md", md);
       
    99   closeMethodCall();
       
   100 }
       
   101 
       
   102 void IndexLog::addIndexFile(char const * name)
       
   103 {
       
   104   openMethodCall("addIndexFile");
       
   105   addStringParameter("name", name);
       
   106   closeMethodCall();
       
   107 }
       
   108 
       
   109 void IndexLog::openMethodCall(char const * methodName)
       
   110 {
       
   111   m_out.setCompressionEnabled(true);
       
   112   m_out.open("call");
       
   113   m_out.openCloseContent("method", methodName);
       
   114 }
       
   115 
       
   116 void IndexLog::addPrimitiveParameter(char const * parameterName,
       
   117     char const * value)
       
   118 {
       
   119   m_out.open("param");
       
   120   m_out.openCloseContent("name", parameterName);
       
   121   if (value != NULL)
       
   122   {
       
   123     m_out.openCloseContent("value", value);
       
   124   }
       
   125   m_out.close("param");
       
   126 }
       
   127 
       
   128 void IndexLog::addBoolParameter(char const * parameterName, bool value)
       
   129 {
       
   130   addPrimitiveParameter(parameterName, value ? "true" : "false");
       
   131 }
       
   132 
       
   133 void IndexLog::addStringParameter(char const * parameterName,
       
   134                                      char const * value)
       
   135 {
       
   136   addPrimitiveParameter(parameterName, value);
       
   137 }
       
   138 
       
   139 void IndexLog::addMemberDefParameter(char const * parameterName,
       
   140                                         const MemberDef * /*value*/)
       
   141 {
       
   142   m_out.open("param");
       
   143   m_out.openCloseContent("name", parameterName);
       
   144   m_out.close("param");
       
   145 }
       
   146 
       
   147 void IndexLog::closeMethodCall()
       
   148 {
       
   149   m_out.setCompressionEnabled(false);
       
   150   m_out.close("call");
       
   151 }
       
   152