Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/cpp/src/string.cpp

    rbc56f30 rc735afb  
    11/*
    2  * Copyright (c) 2019 Jaroslav Jindrak
     2 * Copyright (c) 2018 Jaroslav Jindrak
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 #include <cassert>
    3029#include <string>
    3130
     
    3534    {
    3635        // TODO: implement using stol once we have numeric limits
    37         __unimplemented();
    3836        return 0;
    3937    }
     
    4240    {
    4341        char* end;
    44         long result = ::strtol(str.c_str(), &end, base);
     42        long result = hel::strtol(str.c_str(), &end, base);
    4543
    4644        if (end != str.c_str())
     
    5856    {
    5957        char* end;
    60         unsigned long result = ::strtoul(str.c_str(), &end, base);
     58        unsigned long result = hel::strtoul(str.c_str(), &end, base);
    6159
    6260        if (end != str.c_str())
     
    7472    {
    7573        // TODO: implement using stol once we have numeric limits
    76         __unimplemented();
    7774        return 0;
    7875    }
     
    8178    {
    8279        // TODO: implement using stoul once we have numeric limits
    83         __unimplemented();
    8480        return 0;
    8581    }
     
    8884    {
    8985        // TODO: implement
    90         __unimplemented();
    9186        return 0.f;
    9287    }
     
    9590    {
    9691        // TODO: implement
    97         __unimplemented();
    9892        return 0.0;
    9993    }
     
    10296    {
    10397        // TODO: implement
    104         __unimplemented();
    10598        return 0.0l;
    10699    }
    107100
     101    namespace hel
     102    {
     103        extern "C" int asprintf(char**, const char*, ...);
     104    }
     105
    108106    string to_string(int val)
    109107    {
    110108        char* tmp;
    111         ::asprintf(&tmp, "%d", val);
     109        hel::asprintf(&tmp, "%d", val);
    112110
    113111        std::string res{tmp};
     
    120118    {
    121119        char* tmp;
    122         ::asprintf(&tmp, "%u", val);
     120        hel::asprintf(&tmp, "%u", val);
    123121
    124122        std::string res{tmp};
     
    131129    {
    132130        char* tmp;
    133         ::asprintf(&tmp, "%ld", val);
     131        hel::asprintf(&tmp, "%ld", val);
    134132
    135133        std::string res{tmp};
     
    142140    {
    143141        char* tmp;
    144         ::asprintf(&tmp, "%lu", val);
     142        hel::asprintf(&tmp, "%lu", val);
    145143
    146144        std::string res{tmp};
     
    153151    {
    154152        char* tmp;
    155         ::asprintf(&tmp, "%lld", val);
     153        hel::asprintf(&tmp, "%lld", val);
    156154
    157155        std::string res{tmp};
     
    164162    {
    165163        char* tmp;
    166         ::asprintf(&tmp, "%llu", val);
     164        hel::asprintf(&tmp, "%llu", val);
    167165
    168166        std::string res{tmp};
     
    175173    {
    176174        char* tmp;
    177         ::asprintf(&tmp, "%f", val);
     175        hel::asprintf(&tmp, "%f", val);
    178176
    179177        std::string res{tmp};
     
    186184    {
    187185        char* tmp;
    188         ::asprintf(&tmp, "%f", val);
     186        hel::asprintf(&tmp, "%f", val);
    189187
    190188        std::string res{tmp};
     
    197195    {
    198196        char* tmp;
    199         ::asprintf(&tmp, "%Lf", val);
     197        hel::asprintf(&tmp, "%Lf", val);
    200198
    201199        std::string res{tmp};
     
    208206    {
    209207        // TODO: implement
    210         __unimplemented();
    211208        return 0;
    212209    }
     
    215212    {
    216213        // TODO: implement
    217         __unimplemented();
    218214        return 0;
    219215    }
     
    222218    {
    223219        // TODO: implement
    224         __unimplemented();
    225220        return 0;
    226221    }
     
    229224    {
    230225        // TODO: implement
    231         __unimplemented();
    232226        return 0;
    233227    }
     
    236230    {
    237231        // TODO: implement
    238         __unimplemented();
    239232        return 0;
    240233    }
     
    243236    {
    244237        // TODO: implement
    245         __unimplemented();
    246238        return 0.f;
    247239    }
     
    250242    {
    251243        // TODO: implement
    252         __unimplemented();
    253244        return 0.0;
    254245    }
     
    257248    {
    258249        // TODO: implement
    259         __unimplemented();
    260250        return 0.0l;
    261251    }
     
    264254    {
    265255        // TODO: implement
    266         __unimplemented();
    267256        return wstring{};
    268257    }
     
    271260    {
    272261        // TODO: implement
    273         __unimplemented();
    274262        return wstring{};
    275263    }
     
    278266    {
    279267        // TODO: implement
    280         __unimplemented();
    281268        return wstring{};
    282269    }
     
    285272    {
    286273        // TODO: implement
    287         __unimplemented();
    288274        return wstring{};
    289275    }
     
    292278    {
    293279        // TODO: implement
    294         __unimplemented();
    295280        return wstring{};
    296281    }
     
    299284    {
    300285        // TODO: implement
    301         __unimplemented();
    302286        return wstring{};
    303287    }
     
    306290    {
    307291        // TODO: implement
    308         __unimplemented();
    309292        return wstring{};
    310293    }
     
    313296    {
    314297        // TODO: implement
    315         __unimplemented();
    316298        return wstring{};
    317299    }
     
    320302    {
    321303        // TODO: implement
    322         __unimplemented();
    323304        return wstring{};
    324305    }
Note: See TracChangeset for help on using the changeset viewer.