• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

icsm-au / DynAdjust / 13494567994

24 Feb 2025 09:15AM UTC coverage: 81.168% (+2.0%) from 79.161%
13494567994

push

github

web-flow
Merge pull request #234 from icsm-au/1.2.8

Version 1.2.8 (fixes, ehnacements, improved datum management)

6131 of 8137 new or added lines in 90 files covered. (75.35%)

162 existing lines in 33 files now uncovered.

32214 of 39688 relevant lines covered (81.17%)

11775.25 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

95.8
/dynadjust/include/functions/dnastringfuncs.cpp
1
//============================================================================
2
// Name         : dnastringfuncs.cpp
3
// Author       : Roger Fraser
4
// Contributors :
5
// Version      : 1.00
6
// Copyright    : Copyright 2017 Geoscience Australia
7
//
8
//                Licensed under the Apache License, Version 2.0 (the "License");
9
//                you may not use this file except in compliance with the License.
10
//                You may obtain a copy of the License at
11
//               
12
//                http ://www.apache.org/licenses/LICENSE-2.0
13
//               
14
//                Unless required by applicable law or agreed to in writing, software
15
//                distributed under the License is distributed on an "AS IS" BASIS,
16
//                WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
//                See the License for the specific language governing permissions and
18
//                limitations under the License.
19
//
20
// Description  : Common String Functions
21
//============================================================================
22

23
#include <include/functions/dnastringfuncs.hpp>
24
#include <include/config/dnaversion-stream.hpp>
25
#include <include/functions/dnatemplatedatetimefuncs.hpp>
26

27
// Returns the number of fields with valid data
28
int GetFields(char *line, char delim, bool multiple_delim_as_one, const char *fmt, ...)
170✔
29
{
30
        va_list ap;
170✔
31
        size_t length = strlen(line);
170✔
32

33
        // 1. determine "expected" number of fields
34
        size_t field_count = strlen(fmt);
170✔
35
        size_t* field = new size_t[field_count+1];
170✔
36
        
37
        size_t i(0), j(0);
170✔
38

39
        // 2. Determine indices of the beginning of each field
40
        
41
        // first field commences at 0
42
        field[j++] = 0;
170✔
43
        
44
        // 3. Determine indices of remaining fields, but don't let j
45
        //    go beyond the number of 'wanted' fields (field_count)
46
        while (line[i] != '\n' && i < length && j <= field_count)
9,912✔
47
        //while (line[i] != '\n' && i < length)
48
        //while(line[i] != '\n' && line[i] != '\0')
49
        {
50
                // replace all delimiters with NULL
51
                if (line[i] == delim)
9,742✔
52
                {
53
                        if (multiple_delim_as_one && i < length-1)
1,103✔
54
                        {
55
                                if (line[i+1] == delim)
945✔
56
                                {
57
                                        i++;
504✔
58
                                        continue;
504✔
59
                                }
60
                        }
61
                        line[i] = '\0';
599✔
62
                        field[j++] = i+1;
599✔
63
                }
64
                i++;
9,238✔
65
        }
66

67
        // 4. terminate end of the wanted string with null
68
        line[i] = '\0';        
170✔
69
        i = 0;
170✔
70
        va_start(ap, fmt);
170✔
71

72
        int success(0);
170✔
73

74
        char* p;
170✔
75

76
        // 5. get the data
77
        while (i < j && *fmt != '\0') 
909✔
78
        {
79
                p = &line[field[i]];
739✔
80
                
81
                switch(*fmt) {
739✔
82
                case 'd':
252✔
83
                        if (strlen(p) == 0)
252✔
84
                                *(va_arg(ap, int *)) = INT_MIN;
×
85
                        else
86
                        {
87
                                success++;
252✔
88
                                *(va_arg(ap, int *)) = atoi(p);
252✔
89
                        }
90
                        break;
91
                case 'f':
443✔
92
                        if (strlen(p) == 0)
443✔
93
                                *(va_arg(ap, double *)) = MAX_DBL_VALUE;
4✔
94
                        else
95
                        {
96
                                success++;
439✔
97
                                *(va_arg(ap, double *)) = atof(p);
439✔
98
                        }
99
                        break;
100
                case 's':
44✔
101
                        if (strlen(p) != 0)
44✔
102
                                success++;
40✔
103
                        strcpy((va_arg(ap, char *)), p);
44✔
104
                        break;
44✔
105
                default :
×
106
                        delete[] field;
×
107
                        return 0;
108
                }
109
                i++;
739✔
110
                fmt++;
739✔
111
        }
112

113
        va_end(ap);
170✔
114
        delete[] field;
170✔
115

116
        // 6. Return number of fields with non-empty data
117
        return success;
118
}
119
        
120
// Prints a summary of the software, like the following:
121
//    +---------------------------------------------------------------------------
122
//    + Title:        adjust
123
//    + Description : Geodetic network adjustment software
124
//    + Version :     1.0.0, Release(64 - bit)
125
//    + Build :       May 14 2018, 10 : 30 : 07 (MSVC++ 14.13, VS2017)
126
//    + Copyright :   (C)2018 Geoscience Australia.
127
//                    This software is released under the Apache License.
128
//    + Contact :     geodesy@ga.gov.au
129
//    + ---------------------------------------------------------------------------
130
//
131
void fileproc_help_header(std::string* msg)
758✔
132
{
133
        std::stringstream str;
758✔
134

135
        str << "+---------------------------------------------------------------------------" << std::endl;
758✔
136
        
137
        str << "+ ";
758✔
138
        output_binaryname(str);
758✔
139
        str << " - ";
758✔
140
        output_theappname(str);
758✔
141
        str << ".";
758✔
142
        str << std::endl;
758✔
143

144
        str << "+ ";
758✔
145
        output_binarydescription(str);
758✔
146
        str << std::endl;
758✔
147
        
148
        str << "+ ";
758✔
149
        output_version(str);
758✔
150
        str << std::endl;
758✔
151
        
152
        str << "+ ";
758✔
153
        output_build(str);
758✔
154
        str << std::endl;
758✔
155
        
156
        *msg = str.str();
758✔
157
        
158
        *msg += "+ Copyright:    (C) ";
758✔
159
        *msg += __COPYRIGHT_YEAR__;
758✔
160
        *msg += " ";
758✔
161
        *msg += __COPYRIGHT_OWNER__;
758✔
162
        *msg += ".\n";
758✔
163
        *msg += "                ";
758✔
164
        *msg += __COPYRIGHT_MSG__;
758✔
165
        *msg += "\n";
758✔
166
        *msg += "+ Contact:      ";
758✔
167
        *msg += __CONTACT_EMAIL__;
758✔
168
        *msg += "\n";
758✔
169
        *msg += "+---------------------------------------------------------------------------\n\n";
758✔
170
}
758✔
171

172
        
173
void dynaml_header(std::ostream& os, const std::string& fileType, const std::string& referenceFrame, const std::string& epoch)
31✔
174
{
175
        os << "<?xml version=\"1.0\"?>" << std::endl;
31✔
176
        os << "<DnaXmlFormat type=\"" << fileType << 
31✔
177
                "\" referenceframe=\"" << referenceFrame <<
178
                "\" epoch=\"" << epoch <<
179
                "\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"DynaML.xsd\">" << std::endl;
31✔
180
        
181
        os << "<!-- ";
31✔
182
        output_createdby(os);
31✔
183
        os << " -->" << std::endl;
31✔
184
        os << "<!-- ";
31✔
185
        output_version(os);
31✔
186
        os << " -->" << std::endl;
31✔
187
        os << "<!-- ";
31✔
188
        output_build(os);
31✔
189
        os << " -->" << std::endl;
31✔
190
}
31✔
191
        
192

193
void dynaml_footer(std::ostream& os)
8✔
194
{
195
        os << "</DnaXmlFormat>" << std::endl;
8✔
196
}
8✔
197
        
198
        
199
void dynaml_comment(std::ostream& os, const std::string& comment)
94✔
200
{
201
        os << "<!-- " << comment << " -->" << std::endl;
94✔
202
}
94✔
203

204
std::string snx_softwarehardware_text()
5✔
205
{
206
        std::stringstream str, str2;
5✔
207
        
208
        // name
209
        output_globalname(str2);
5✔
210
        str << " SOFTWARE           " << std::left << std::setw(60) << str2.str() << std::endl;
5✔
211
        
212
        // version
213
        str2.str("");
15✔
214
        output_version(str2);
5✔
215
        str << " SOFTWARE           " << std::left << std::setw(60) << str2.str() << std::endl;
5✔
216
        
217
        // build
218
        str2.str("");
15✔
219
        output_build(str2);        
5✔
220
        str << " SOFTWARE           " << std::left << std::setw(60) << str2.str() << std::endl;
5✔
221
        
222
        // hardware
223
        str << " HARDWARE           " << std::left << std::setw(60) << __HARDWARE__ << std::endl;
5✔
224

225

226
        return str.str();
10✔
227
}
5✔
228
        
229

230
void dna_header(std::ostream& os, const std::string& fileVersion, const std::string& fileType, const std::string& reference_frame, const std::string& epoch_version, const size_t& count)
33✔
231
{
232
        std::stringstream str;
33✔
233
        str << "!#=DNA " << fileVersion << " " << fileType;
33✔
234

235
        boost::gregorian::date today(boost::gregorian::day_clock::local_day());
33✔
236
        
237
        // creation date
238
        str << std::setw(14) << std::right << stringFromDate<boost::gregorian::date>(today);
66✔
239
        // default reference frame
240
        str << std::setw(14) << std::right << reference_frame;
33✔
241
        // default epoch
242
        str << std::setw(14) << std::right << epoch_version;
33✔
243
        // count of records
244
        str << std::setw(10) << std::right << count;
33✔
245

246
        os << str.str() << std::endl;
33✔
247

248
        // Provide comments on the version of DynAdjust that is creating this file
249
        os << "* ";
33✔
250
        output_createdby(os);
33✔
251
        os << ". " << std::endl;
33✔
252
        os << "* ";
33✔
253
        output_version(os);
33✔
254
        os << ". " << std::endl;
33✔
255
        os << "* ";
33✔
256
        output_build(os);
33✔
257
        os << std::endl;
33✔
258
}
33✔
259
        
260

261
void dna_comment(std::ostream& os, const std::string& comment)
102✔
262
{
263
        os << "* " << comment << std::endl;
102✔
264
}
102✔
265

266
void dnaproj_header(std::ostream& os, const std::string& comment)
590✔
267
{
268
        // DynAdjust version
269
        os << "# " << comment << ". ";
590✔
270
        output_createdby(os);
590✔
271
        os << ". ";
590✔
272
        output_version(os);
590✔
273
        os << ". ";
590✔
274
        output_build(os);
590✔
275
}
590✔
276

NEW
277
void dnaproj_comment(std::ostream& os, const std::string& comment)
×
278
{
NEW
279
        os << "# " << comment << std::endl;
×
280
}
×
281

STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc