Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    getline not working

    Cinema 4D SDK
    2
    6
    1.4k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • R
      rui_mac
      last edited by

      I'm porting yet another plugin to R20.
      In this plugin, I have to parse lines that I read, line by line, from a file.
      I was using std functions, namely getline.
      But I'm getting "No matching function for call to 'getline'" errors.
      Is it a limitation of the new coding environment?
      How can I read a stream, line by line and then, parse the line element by element (elements are separated by ', ' (a comma and a space)?

      1 Reply Last reply Reply Quote 0
      • r_giganteR
        r_gigante
        last edited by

        Hi Rui, thanks for writing us.

        With regard to the issue reported, it's likely that, being getline defined in the std:: namespace you're invoking it without explicitly using the namespace being the std namespace not being used by default.

        Invoking std::getline() should then fix the issue on your side.

        Being said that, I warmly recommend to get rid of using methods outside of Cinema 4D API and instead to have a look at the InputStream Manual and to ParseHelper::ConvertTextToLines static method.

        Best, Riccardo

        1 Reply Last reply Reply Quote 2
        • R
          rui_mac
          last edited by

          I will try it, Riccardo.
          The "beauty" of getline is that I can parse value by value, and the line will get shorter automatically, as I read values from it.
          Since I use it to parse OBJ and FBX files, changing methods would require me to recode everything. But, sometimes, we just have to bite the bullet and re-write stuff, I know 😉

          1 Reply Last reply Reply Quote 0
          • R
            rui_mac
            last edited by

            I still get the "No matching function for call to 'getlin'" error, for example in this code, even after replacing getline with std::getline:

            void polypaint::read_line_indexes(string line, BaseContainer &bc)
            {
            std::stringstream ss(line);
            std::string field;
            Int32 index;

            while (std::getline(ss, field, ', '))
            {
            	index = atoi(field.c_str());
            
            	bc.SetInt32(store_index_count, index);
            	store_index_count++;
            }
            

            }

            1 Reply Last reply Reply Quote 0
            • r_giganteR
              r_gigante
              last edited by

              Hi rui_mac,

              std::getline() in its signature accepts std::basic_istream and not std::stringstream and this is the reason why you're provided back with such an error.

              Riccardo

              1 Reply Last reply Reply Quote 2
              • R
                rui_mac
                last edited by

                It is so weird that it worked in versions pre R20.
                Well, I will have to find a new solution, then.

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post