Changeset 8f01cb04


Ignore:
Timestamp:
Aug 31, 2021, 1:49:09 AM (3 years ago)
Author:
Jacob Prud'homme <jafprudhomme@…>
Branches:
ADT, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, pthread-emulation, qualifiedEnum
Children:
4cc6c7d
Parents:
58ebd78
git-author:
Jacob Prud'homme <jafprudhomme@…> (07/16/21 15:10:41)
git-committer:
Jacob Prud'homme <jafprudhomme@…> (08/31/21 01:49:09)
Message:

Switched to importing default parsing functions from parseargs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/parseconfig.cfa

    r58ebd78 r8f01cb04  
    11#include <fstream.hfa>
    2 #include <heap.hfa>
     2#include <parseargs.hfa>
    33#include "parseconfig.hfa"
    44
     
    9191
    9292
    93 //-----------------------------------------------------------------------------
    94 // Typed argument parsing
    95 
    96 bool parse( const char * arg, const char * & value ) {
    97         value = arg;
    98         return true;
    99 }
    100 
    101 bool parse( const char * arg, int & value ) {
    102         char * end;
    103         int r = strtoll( arg, &end, 10 );
    104   if ( *end != '\0' ) return false;
    105 
    106         value = r;
    107         return true;
    108 }
    109 
    110 bool parse( const char * arg, unsigned & value ) {
    111         char * end;
    112         unsigned long long int r = strtoull( arg, &end, 10 );
    113   if ( *end != '\0' ) return false;
    114   if ( r > (unsigned)MAX ) return false;
    115 
    116         value = r;
    117         return true;
    118 }
    119 
    120 bool parse( const char * arg, unsigned long & value ) {
    121         char * end;
    122         unsigned long long int r = strtoull( arg, &end, 10 );
    123   if ( *end != '\0' ) return false;
    124   if ( r > (unsigned long)MAX ) return false;
    125 
    126         value = r;
    127         return true;
    128 }
    129 
    130 bool parse( const char * arg, unsigned long long & value ) {
    131         char * end;
    132         unsigned long long int r = strtoull( arg, &end, 10 );
    133   if ( *end != '\0' ) return false;
    134   if ( r > (unsigned long long)MAX ) return false;
    135 
    136         value = r;
    137         return true;
    138 }
    139 
    140 bool parse( const char * arg, float & value ) {
    141         char * end;
    142         float r = strtof( arg, &end );
    143   if ( *end != '\0' ) return false;
    144 
    145         value = r;
    146         return true;
    147 }
    148 
    149 bool parse( const char * arg, double & value ) {
    150         char * end;
    151         double r = strtod( arg, &end );
    152   if ( *end != '\0' ) return false;
    153 
    154         value = r;
    155         return true;
    156 }
    157 
    158 
    15993// Local Variables: //
    16094// tab-width: 4 //
Note: See TracChangeset for help on using the changeset viewer.