1*d291ea28SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*d291ea28SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*d291ea28SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*d291ea28SAndrew Rist * distributed with this work for additional information
6*d291ea28SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*d291ea28SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*d291ea28SAndrew Rist * "License"); you may not use this file except in compliance
9*d291ea28SAndrew Rist * with the License. You may obtain a copy of the License at
10*d291ea28SAndrew Rist *
11*d291ea28SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*d291ea28SAndrew Rist *
13*d291ea28SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*d291ea28SAndrew Rist * software distributed under the License is distributed on an
15*d291ea28SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*d291ea28SAndrew Rist * KIND, either express or implied. See the License for the
17*d291ea28SAndrew Rist * specific language governing permissions and limitations
18*d291ea28SAndrew Rist * under the License.
19*d291ea28SAndrew Rist *
20*d291ea28SAndrew Rist *************************************************************/
21cdf0e10cSrcweir
22cdf0e10cSrcweir #include <precomp.h>
23cdf0e10cSrcweir #include "cmd_sincedata.hxx"
24cdf0e10cSrcweir
25cdf0e10cSrcweir
26cdf0e10cSrcweir // NOT FULLY DEFINED SERVICES
27cdf0e10cSrcweir #include <cosv/file.hxx>
28cdf0e10cSrcweir #include <cosv/tpl/tpltools.hxx>
29cdf0e10cSrcweir #include "adc_cmds.hxx"
30cdf0e10cSrcweir
31cdf0e10cSrcweir
32cdf0e10cSrcweir
33cdf0e10cSrcweir namespace autodoc
34cdf0e10cSrcweir {
35cdf0e10cSrcweir namespace command
36cdf0e10cSrcweir {
37cdf0e10cSrcweir
SinceTagTransformationData()38cdf0e10cSrcweir SinceTagTransformationData::SinceTagTransformationData()
39cdf0e10cSrcweir : aTransformationTable()
40cdf0e10cSrcweir {
41cdf0e10cSrcweir }
42cdf0e10cSrcweir
~SinceTagTransformationData()43cdf0e10cSrcweir SinceTagTransformationData::~SinceTagTransformationData()
44cdf0e10cSrcweir {
45cdf0e10cSrcweir }
46cdf0e10cSrcweir
47cdf0e10cSrcweir bool
DoesTransform() const48cdf0e10cSrcweir SinceTagTransformationData::DoesTransform() const
49cdf0e10cSrcweir {
50cdf0e10cSrcweir return NOT aTransformationTable.empty();
51cdf0e10cSrcweir }
52cdf0e10cSrcweir
53cdf0e10cSrcweir const String &
DisplayOf(const String & i_versionNumber) const54cdf0e10cSrcweir SinceTagTransformationData::DisplayOf( const String & i_versionNumber ) const
55cdf0e10cSrcweir {
56cdf0e10cSrcweir if (DoesTransform())
57cdf0e10cSrcweir {
58cdf0e10cSrcweir StreamLock
59cdf0e10cSrcweir sl(200);
60cdf0e10cSrcweir sl() << i_versionNumber;
61cdf0e10cSrcweir sl().strip_frontback_whitespace();
62cdf0e10cSrcweir String
63cdf0e10cSrcweir sVersionNumber(sl().c_str());
64cdf0e10cSrcweir
65cdf0e10cSrcweir const String *
66cdf0e10cSrcweir ret = csv::find_in_map(aTransformationTable, sVersionNumber);
67cdf0e10cSrcweir return ret != 0
68cdf0e10cSrcweir ? *ret
69cdf0e10cSrcweir : String::Null_();
70cdf0e10cSrcweir }
71cdf0e10cSrcweir else
72cdf0e10cSrcweir {
73cdf0e10cSrcweir return i_versionNumber;
74cdf0e10cSrcweir }
75cdf0e10cSrcweir }
76cdf0e10cSrcweir
77cdf0e10cSrcweir void
do_Init(opt_iter & it,opt_iter itEnd)78cdf0e10cSrcweir SinceTagTransformationData::do_Init( opt_iter & it,
79cdf0e10cSrcweir opt_iter itEnd )
80cdf0e10cSrcweir {
81cdf0e10cSrcweir ++it; // Cur is since-file path.
82cdf0e10cSrcweir
83cdf0e10cSrcweir CHECKOPT( it != itEnd ,
84cdf0e10cSrcweir "file path",
85cdf0e10cSrcweir C_opt_SinceFile );
86cdf0e10cSrcweir
87cdf0e10cSrcweir csv::File aSinceFile(*it);
88cdf0e10cSrcweir csv::OpenCloseGuard aSinceFileGuard(aSinceFile);
89cdf0e10cSrcweir StreamStr sLine(200);
90cdf0e10cSrcweir
91cdf0e10cSrcweir if (aSinceFileGuard)
92cdf0e10cSrcweir {
93cdf0e10cSrcweir for ( sLine.operator_read_line(aSinceFile);
94cdf0e10cSrcweir NOT sLine.empty();
95cdf0e10cSrcweir sLine.operator_read_line(aSinceFile) )
96cdf0e10cSrcweir {
97cdf0e10cSrcweir
98cdf0e10cSrcweir if (*sLine.begin() != '"')
99cdf0e10cSrcweir continue;
100cdf0e10cSrcweir
101cdf0e10cSrcweir const char * pVersion = sLine.c_str() + 1;
102cdf0e10cSrcweir const char * pVersionEnd = strchr(pVersion, '"');
103cdf0e10cSrcweir if (pVersionEnd == 0)
104cdf0e10cSrcweir continue;
105cdf0e10cSrcweir const char * pDisplay = strchr(pVersionEnd+1, '"');
106cdf0e10cSrcweir if (pDisplay == 0)
107cdf0e10cSrcweir continue;
108cdf0e10cSrcweir ++pDisplay;
109cdf0e10cSrcweir const char * pDisplayEnd = strchr(pDisplay, '"');
110cdf0e10cSrcweir if (pDisplayEnd == 0)
111cdf0e10cSrcweir continue;
112cdf0e10cSrcweir
113cdf0e10cSrcweir aTransformationTable[ String(pVersion,pVersionEnd) ]
114cdf0e10cSrcweir = String(pDisplay,pDisplayEnd);
115cdf0e10cSrcweir sLine.clear();
116cdf0e10cSrcweir } // end for
117cdf0e10cSrcweir } // end if
118cdf0e10cSrcweir
119cdf0e10cSrcweir ++it; // Cur is next option.
120cdf0e10cSrcweir }
121cdf0e10cSrcweir
122cdf0e10cSrcweir } // namespace command
123cdf0e10cSrcweir } // namespace autodoc
124