src/types.cc

changeset 606
3dd6f343ec06
parent 604
01bdac75994a
child 609
a8dc74a809c6
equal deleted inserted replaced
605:2983f7c7e7c9 606:3dd6f343ec06
27 #include "ldtypes.h" 27 #include "ldtypes.h"
28 #include "document.h" 28 #include "document.h"
29 29
30 // ============================================================================= 30 // =============================================================================
31 // ----------------------------------------------------------------------------- 31 // -----------------------------------------------------------------------------
32 str DoFormat (QList<StringFormatArg> args) 32 QString DoFormat (QList<StringFormatArg> args)
33 { 33 {
34 assert (args.size() >= 1); 34 assert (args.size() >= 1);
35 str text = args[0].value(); 35 QString text = args[0].value();
36 36
37 for (uchar i = 1; i < args.size(); ++i) 37 for (uchar i = 1; i < args.size(); ++i)
38 text = text.arg (args[i].value()); 38 text = text.arg (args[i].value());
39 39
40 return text; 40 return text;
79 return mid; 79 return mid;
80 } 80 }
81 81
82 // ============================================================================= 82 // =============================================================================
83 // ----------------------------------------------------------------------------- 83 // -----------------------------------------------------------------------------
84 str Vertex::stringRep (bool mangled) const 84 QString Vertex::stringRep (bool mangled) const
85 { 85 {
86 str fmtstr = "%1 %2 %3"; 86 QString fmtstr = "%1 %2 %3";
87 87
88 if (mangled) 88 if (mangled)
89 fmtstr = "(%1, %2, %3)"; 89 fmtstr = "(%1, %2, %3)";
90 90
91 return fmt (fmtstr, coord (X), coord (Y), coord (Z)); 91 return fmt (fmtstr, coord (X), coord (Y), coord (Z));
243 } 243 }
244 } 244 }
245 245
246 // ============================================================================= 246 // =============================================================================
247 // ----------------------------------------------------------------------------- 247 // -----------------------------------------------------------------------------
248 str Matrix::stringRep() const 248 QString Matrix::stringRep() const
249 { 249 {
250 str val; 250 QString val;
251 251
252 for (int i = 0; i < 9; ++i) 252 for (int i = 0; i < 9; ++i)
253 { 253 {
254 if (i > 0) 254 if (i > 0)
255 val += ' '; 255 val += ' ';
256 256
257 val += str::number (m_vals[i]); 257 val += QString::number (m_vals[i]);
258 } 258 }
259 259
260 return val; 260 return val;
261 } 261 }
262 262
313 return true; 313 return true;
314 } 314 }
315 315
316 // ============================================================================= 316 // =============================================================================
317 // ----------------------------------------------------------------------------- 317 // -----------------------------------------------------------------------------
318 StringFormatArg::StringFormatArg (const str& v) 318 StringFormatArg::StringFormatArg (const QString& v)
319 { 319 {
320 m_val = v; 320 m_val = v;
321 } 321 }
322 322
323 StringFormatArg::StringFormatArg (const char& v) 323 StringFormatArg::StringFormatArg (const char& v)
335 m_val = v; 335 m_val = v;
336 } 336 }
337 337
338 StringFormatArg::StringFormatArg (const float& v) 338 StringFormatArg::StringFormatArg (const float& v)
339 { 339 {
340 m_val = str::number (v); 340 m_val = QString::number (v);
341 } 341 }
342 342
343 StringFormatArg::StringFormatArg (const double& v) 343 StringFormatArg::StringFormatArg (const double& v)
344 { 344 {
345 m_val = str::number (v); 345 m_val = QString::number (v);
346 } 346 }
347 347
348 StringFormatArg::StringFormatArg (const Vertex& v) 348 StringFormatArg::StringFormatArg (const Vertex& v)
349 { 349 {
350 m_val = v.stringRep (false); 350 m_val = v.stringRep (false);
372 // Make a null file 372 // Make a null file
373 m_file = null; 373 m_file = null;
374 m_textstream = null; 374 m_textstream = null;
375 } 375 }
376 376
377 File::File (str path, OpenType rtype) 377 File::File (QString path, OpenType rtype)
378 { 378 {
379 m_file = null; 379 m_file = null;
380 m_path = path; 380 m_path = path;
381 open (path, rtype); 381 open (path, rtype);
382 } 382 }
406 bool File::open (FILE* fp, OpenType rtype) 406 bool File::open (FILE* fp, OpenType rtype)
407 { 407 {
408 return open ("", rtype, fp); 408 return open ("", rtype, fp);
409 } 409 }
410 410
411 bool File::open (str path, OpenType rtype, FILE* fp) 411 bool File::open (QString path, OpenType rtype, FILE* fp)
412 { 412 {
413 close(); 413 close();
414 414
415 if (!m_file) 415 if (!m_file)
416 m_file = new QFile; 416 m_file = new QFile;
452 return m_endIterator; 452 return m_endIterator;
453 } 453 }
454 454
455 // ============================================================================= 455 // =============================================================================
456 // ----------------------------------------------------------------------------- 456 // -----------------------------------------------------------------------------
457 void File::write (str msg) 457 void File::write (QString msg)
458 { 458 {
459 m_file->write (msg.toUtf8(), msg.length()); 459 m_file->write (msg.toUtf8(), msg.length());
460 } 460 }
461 461
462 // ============================================================================= 462 // =============================================================================
463 // ----------------------------------------------------------------------------- 463 // -----------------------------------------------------------------------------
464 bool File::readLine (str& line) 464 bool File::readLine (QString& line)
465 { 465 {
466 if (!m_textstream || m_textstream->atEnd()) 466 if (!m_textstream || m_textstream->atEnd())
467 return false; 467 return false;
468 468
469 line = m_textstream->readLine(); 469 line = m_textstream->readLine();
542 m_gotdata = m_file->readLine (m_text); 542 m_gotdata = m_file->readLine (m_text);
543 } 543 }
544 544
545 // ============================================================================= 545 // =============================================================================
546 // ----------------------------------------------------------------------------- 546 // -----------------------------------------------------------------------------
547 str File::iterator::operator*() 547 QString File::iterator::operator*()
548 { 548 {
549 return m_text; 549 return m_text;
550 } 550 }
551 551
552 // ============================================================================= 552 // =============================================================================

mercurial