LCOV - code coverage report
Current view: top level - libreoffice/autodoc/source/exes/adc_uni - adc_cmd_parse.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 80 131 61.1 %
Date: 2012-12-27 Functions: 18 23 78.3 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <precomp.h>
      21             : #include "adc_cmd_parse.hxx"
      22             : 
      23             : 
      24             : // NOT FULLY DEFINED SERVICES
      25             : #include <cosv/tpl/tpltools.hxx>
      26             : #include <adc_cl.hxx>
      27             : #include "adc_cmds.hxx"
      28             : #include "cmd_run.hxx"
      29             : 
      30             : 
      31             : 
      32             : namespace autodoc
      33             : {
      34             : namespace command
      35             : {
      36             : 
      37             : namespace
      38             : {
      39             : 
      40           1 : const String C_FileEnding_idl("*.idl");
      41             : 
      42             : inline void
      43           0 : CHECK( bool b, const String & text )
      44             : {
      45           0 :     if (NOT b)
      46           0 :         throw X_CommandLine( text );
      47           0 : }
      48             : 
      49             : }   // anonymous namespace
      50             : 
      51             : 
      52             : 
      53             : //**************************     S_LanguageInfo     ***********************//
      54             : 
      55           2 : S_LanguageInfo::~S_LanguageInfo()
      56             : {
      57           2 : }
      58             : 
      59             : void
      60           1 : S_LanguageInfo::do_Init( opt_iter &          it,
      61             :                          opt_iter            itEnd )
      62             : {
      63           1 :     ++it;   // Cur is language.
      64           1 :     CHECKOPT(   it != itEnd AND
      65           1 :                 *it == C_arg_Idl,
      66             :               "language",
      67           2 :               C_opt_LangAll );
      68             : 
      69           1 :     if ( *it == C_arg_Idl ) {
      70           1 :         eLanguage = idl;
      71             :     }
      72             :     else {
      73             :          csv_assert(false);
      74             :     }
      75             : 
      76           1 :     switch (eLanguage)
      77             :     {
      78           1 :         case idl:   aExtensions.push_back( C_FileEnding_idl );
      79           1 :                     CommandLine::Get_().Set_IdlUsed();
      80           1 :                     break;
      81             :         default:    //  do nothing.
      82             :                     ;
      83             :     }
      84             : 
      85           1 :     ++it;   // Cur is next option.
      86           1 : }
      87             : 
      88             : void
      89           0 : S_LanguageInfo::InitExtensions( opt_iter &          it,
      90             :                                 opt_iter            itEnd )
      91             : {
      92           0 :     ++it;
      93           0 :     CHECKOPT( it != itEnd AND (*it).char_at(0) == '.',
      94             :               "extensions",
      95           0 :               C_opt_ExtensionsAll );
      96             : 
      97           0 :     StreamLock slCheck(150);
      98           0 :     slCheck() << C_opt_ExtensionsAll
      99           0 :               << " used without previous "
     100           0 :               << C_opt_LangAll;
     101             : 
     102             :     CHECK( eLanguage != none,
     103           0 :            slCheck().c_str() );
     104             : 
     105           0 :     do {
     106           0 :         aExtensions.push_back(*it);
     107           0 :         ++it;
     108           0 :     }   while (it != itEnd AND (*it).char_at(0) == '.');
     109           0 : }
     110             : 
     111             : 
     112             : 
     113             : //**************************     Parse     ***********************//
     114             : 
     115           1 : Parse::Parse()
     116             :     :   sRepositoryName(),
     117             :         aGlobalLanguage(),
     118             :         aProjects(),
     119           1 :         sDevelopersManual_RefFilePath()
     120             : {
     121           1 : }
     122             : 
     123           3 : Parse::~Parse()
     124             : {
     125           1 :     csv::erase_container_of_heap_ptrs(aProjects);
     126           2 : }
     127             : 
     128             : void
     129           1 : Parse::do_Init( opt_iter &          it,
     130             :                 opt_iter            itEnd )
     131             : {
     132           6 :     for ( ; it != itEnd;  )
     133             :     {
     134           4 :         if (*it == C_opt_Name)
     135           1 :             do_clName(it, itEnd);
     136           3 :         else if (*it == C_opt_LangAll)
     137           1 :             aGlobalLanguage.Init(it, itEnd);
     138           2 :         else if (*it == C_opt_ExtensionsAll)
     139           0 :             aGlobalLanguage.InitExtensions(it, itEnd);
     140           2 :         else if (*it == C_opt_DevmanFile)
     141           1 :             do_clDevManual(it, itEnd);
     142           1 :         else if (*it == C_opt_Project)
     143           0 :             do_clProject(it, itEnd);
     144           1 :         else if (    *it == C_opt_SourceTree
     145           0 :                   OR *it == C_opt_SourceDir
     146           0 :                   OR *it == C_opt_SourceFile )
     147           1 :             do_clDefaultProject(it, itEnd);
     148             :         else
     149           0 :             break;
     150             :     }   // for
     151           1 : }
     152             : 
     153             : void
     154           1 : Parse::do_clName( opt_iter &    it,
     155             :                   opt_iter      itEnd )
     156             : {
     157           1 :     ++it;
     158           2 :     CHECKOPT( it != itEnd AND (*it).char_at(0) != '-',
     159             :               "name",
     160           2 :               C_opt_Name );
     161           1 :     sRepositoryName = *it;
     162           1 :     ++it;
     163           1 : }
     164             : 
     165             : void
     166           1 : Parse::do_clDevManual( opt_iter &    it,
     167             :                        opt_iter      itEnd )
     168             : {
     169           1 :     ++it;
     170           2 :     CHECKOPT( it != itEnd AND (*it).char_at(0) != '-',
     171             :               "link file path",
     172           2 :               C_opt_DevmanFile );
     173           1 :     sDevelopersManual_RefFilePath = *it;
     174           1 :     ++it;
     175           1 : }
     176             : 
     177             : void
     178           0 : Parse::do_clProject( opt_iter &    it,
     179             :                      opt_iter      itEnd )
     180             : {
     181           0 :     if ( aProjects.size() == 1 )
     182             :     {
     183           0 :          if ( aProjects.front()->IsDefault() )
     184           0 :             throw X_CommandLine( "Both, named projects and a default project, cannot be used together." );
     185             :     }
     186             : 
     187           0 :     S_ProjectData * dpProject = new S_ProjectData(aGlobalLanguage);
     188           0 :     ++it;
     189           0 :     dpProject->Init(it, itEnd);
     190           0 :     aProjects.push_back(dpProject);
     191           0 : }
     192             : 
     193             : void
     194           1 : Parse::do_clDefaultProject( opt_iter &    it,
     195             :                             opt_iter      itEnd )
     196             : {
     197           1 :     if ( !aProjects.empty() )
     198             :     {
     199           0 :         throw X_CommandLine( "Both, named projects and a default project, cannot be used together." );
     200             :     }
     201             : 
     202             :     S_ProjectData * dpProject = new S_ProjectData( aGlobalLanguage,
     203           1 :                                                    S_ProjectData::default_prj );
     204           1 :     dpProject->Init(it, itEnd);
     205           1 :     aProjects.push_back(dpProject);
     206           1 : }
     207             : 
     208             : bool
     209           1 : Parse::do_Run() const
     210             : {
     211             :     run::Parser
     212           1 :         aParser(*this);
     213           1 :     return aParser.Perform();
     214             : }
     215             : 
     216             : int
     217           1 : Parse::inq_RunningRank() const
     218             : {
     219           1 :     return static_cast<int>(rank_Parse);
     220             : }
     221             : 
     222             : 
     223             : 
     224             : //**************************     S_Sources      ***********************//
     225             : 
     226             : void
     227           1 : S_Sources::do_Init( opt_iter &          it,
     228             :                     opt_iter            itEnd )
     229             : {
     230             :     StringVector *
     231           1 :         pList = 0;
     232             :     csv_assert((*it)[0] == '-');
     233             : 
     234           3 :     for ( ; it != itEnd; ++it)
     235             :     {
     236           2 :         if ((*it)[0] == '-')
     237             :         {
     238           1 :             if (*it == C_opt_SourceTree)
     239           1 :                 pList = &aTrees;
     240           0 :             else if (*it == C_opt_SourceDir)
     241           0 :                 pList = &aDirectories;
     242           0 :             else if (*it == C_opt_SourceFile)
     243           0 :                 pList = &aFiles;
     244             :             else
     245           1 :                 return;
     246             :         }
     247             :         else
     248           1 :             pList->push_back(*it);
     249             :     }   // end for
     250             : }
     251             : 
     252             : 
     253             : 
     254             : //**************************     S_ProjectData     ***********************//
     255             : 
     256             : 
     257           0 : S_ProjectData::S_ProjectData( const S_LanguageInfo & i_globalLanguage )
     258             :     :   sName(),
     259             :         aRootDirectory(),
     260             :         aLanguage(i_globalLanguage),
     261             :         aFiles(),
     262           0 :         bIsDefault(false)
     263             : {
     264           0 : }
     265             : 
     266           1 : S_ProjectData::S_ProjectData( const S_LanguageInfo & i_globalLanguage,
     267             :                               E_Default              )
     268             :     :   sName(),
     269             :         aRootDirectory("."),
     270             :         aLanguage(i_globalLanguage),
     271             :         aFiles(),
     272           1 :         bIsDefault(true)
     273             : {
     274           1 : }
     275             : 
     276           2 : S_ProjectData::~S_ProjectData()
     277             : {
     278           2 : }
     279             : 
     280             : void
     281           1 : S_ProjectData::do_Init( opt_iter &          it,
     282             :                         opt_iter            itEnd )
     283             : {
     284           1 :     if (NOT IsDefault())
     285             :     {
     286           0 :         CHECKOPT( it != itEnd AND (*it).char_at(0) != '-',
     287             :                   "name",
     288           0 :                   C_opt_Project );
     289           0 :         sName = *it;
     290           0 :         ++it;
     291             : 
     292           0 :         CHECKOPT( it != itEnd AND  (*it).char_at(0) != '-',
     293             :                   "root directory",
     294           0 :                   C_opt_Project );
     295           0 :         aRootDirectory.Set((*it).c_str(), true);
     296           0 :         ++it;
     297             :     }
     298             : 
     299           3 :     for ( ; it != itEnd; )
     300             :     {
     301           1 :         if (    *it == C_opt_SourceTree
     302           0 :              OR *it == C_opt_SourceDir
     303           0 :              OR *it == C_opt_SourceFile )
     304           1 :             aFiles.Init(it, itEnd);
     305             : //        else if (*it == C_opt_Lang)
     306             : //            aLanguage.Init(it, itEnd);
     307             : //        else if (*it == C_opt_Extensions)
     308             : //            aLanguage.InitExtensions(it, itEnd);
     309             :         else
     310           0 :             break;
     311             :     }   // for
     312           1 : }
     313             : 
     314             : }   // namespace command
     315           3 : }   // namespace autodoc
     316             : 
     317             : 
     318             : 
     319             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10