Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware 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

    How to use String::Split

    Cinema 4D SDK
    c++
    2
    2
    312
    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.
    • E
      ECHekman
      last edited by

      I feel a bit silly asking this. But im trying to use the split function on maxon::string. And nothing seems to work.
      Like array is a value receiver? but im getting loads of strange template errors.

      				String cat = ninfo->mCategory;
      				maxon::Array<const String&> parts;
      				cat.Split(String("/"), true, parts);
      				if(parts.GetCount())
      					info(parts[0]);
      
      ferdinandF 1 Reply Last reply Reply Quote 0
      • ferdinandF
        ferdinand @ECHekman
        last edited by ferdinand

        Hello @ECHekman,

        Thank you for reaching out to us. When you run into compiler errors, you should always include them, because how should we otherwise help you? Sure, I could throw your code into our code base, guess some things, and then try to compile it, but the guessing and compiling is unnecessary and makes our answers more imprecise.

        But this should work:

        iferr_scope;
        
        maxon::String myString = "Hello/World"_s;
        maxon::BaseArray<maxon::String> parts; // could also be const
        myString.Split("/"_s, true, parts) iferr_return;
        if (MAXON_UNLIKELY(parts.GetCount() < 1))
          return maxon::IllegalStateError(MAXON_SOURCE_LOCATION, "Splitting path failed."_s);
        

        FYI: There is also UrlInterface::GetComponents.

        Cheers,
        Ferdinand

        MAXON SDK Specialist
        developers.maxon.net

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