Skip to content

Commit

Permalink
Correct floating point number parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
Luis Gerhorst committed Sep 3, 2015
1 parent 6cd9d16 commit 812dc0e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
type = "1"
version = "2.0">
</Bucket>
8 changes: 6 additions & 2 deletions LV Konverter/LGServiceDirectory.m
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ + (LGServiceDirectory *)serviceDirectoryWithCSVString:(NSString *)csvString erro

LGOrdinalNumber *ordinalNumber = [[LGOrdinalNumber alloc] initWithCSVString:line[0]]; // Returns nil if is no valid ordinal number.

// Use localized float scanning.
float quantity;
BOOL quantityValidFloat = [[NSScanner localizedScannerWithString:line[2]] scanFloat:&quantity];

// Service Group:
if (ordinalNumber &&
!isEmpty(line[1]) && // Has a title.
Expand Down Expand Up @@ -162,14 +166,14 @@ + (LGServiceDirectory *)serviceDirectoryWithCSVString:(NSString *)csvString erro
// Service:
} else if (ordinalNumber &&
!isEmpty(line[1]) && // Has title.
[line[2] floatValue] > 0 && // Quantity > 0
quantityValidFloat && quantity > 0 && // Quantity > 0
!isEmpty(line[3]) && [line[3] length] <= 4 && // Has unit with valid length.
(isEmpty(line[4]) || [@"BG" isEqualToString:removeSpaces(line[4])] || [@"BE" isEqualToString:removeSpaces(line[4])])) { // Has valid type.

if ([[stack objectOnTop] class] == [LGService class]) [[stack objectOnTop] trimText]; // Finish previous service.

LGService *service = [[LGService alloc] initWithTitle:line[1]
ofQuantity:[line[2] floatValue]
ofQuantity:quantity
inUnit:line[3]
withCSVTypeString:line[4]
errors:errors];
Expand Down
8 changes: 5 additions & 3 deletions LV Konverter/LV Konverter-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,21 @@
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>Luis-Gerhorst.${PRODUCT_NAME:rfc1034identifier}</string>
<string>Luis-Gerhorst.$(PRODUCT_NAME:rfc1034identifier)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0.1</string>
<string>1.0.2</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>2</string>
<string>5</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.productivity</string>
<key>LSMinimumSystemVersion</key>
<string>${MACOSX_DEPLOYMENT_TARGET}</string>
<key>NSHumanReadableCopyright</key>
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ Menge, Einheit und Art müssen leer sein.

Ordnungszahl | Text | Menge | Einheit | Art
--- | --- | --- | --- | ---
1.1 | Kurztext / Titel | 2.75 | m2 | BG
1.1 | Kurztext / Titel | 2,75 | m2 | BG
| Langtext / Beschreibung
| weitere Zeilen des Langtextes ...

* __Ordnungszahl:__ Muss belegt sein.
* __Text__ in Zeile mit Ordnungszahl: Kurztext bzw. Titel, max 70 Stellen.
* __Menge:__ Zahl, mit oder ohne Komma, muss größer `0` sein.
* __Menge:__ Zahl, mit oder ohne Komma, muss größer `0` sein. Verwenden Sie das auf ihrem System eingestellte Dezimaltrennzeichen (in Deutschland `,`).
* __Einheit:__ Max 4 Stellen, _Stundenlohnarbeiten_ die in `h` gemessen werden, werden automatisch als solche erkannt. `psch` für Pauschalleistungen (mit Menge 1).
* __Text__ alle Zeilen bis zum Beginn der nächsten Teilleistung/LV-Gruppe: Langtext der Teilleistung, eine Zeile sollte nicht mehr als 55 Stellen habe. Optional.
* __Art:__
Expand Down

0 comments on commit 812dc0e

Please sign in to comment.