Is Variant.ToString() possible?

About Monkey 2 Forums Monkey 2 Development Is Variant.ToString() possible?

This topic contains 5 replies, has 3 voices, and was last updated by  Amon 1 year, 3 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #13756

    nerobot
    Participant

    I want to print a Map<String,Variant> type in such form:

    I wrote To:String() operator:

    But we can cast a variant to string if only(!) it contains a string.

    Maybe it’s possible to do in c++ side?

    #13758

    abakobo
    Participant

    I’m doing it this way. If you import reflection there should be a nicer way to do that but I’ve never used reflection so far. So that’s the way I could make it work…

    #13760

    nerobot
    Participant

    It’s good when you have a constatnt range of types. 🙂

    But you should extend this if-else block for any new type.

    #13763

    abakobo
    Participant

    Yes and it is not extending Variant so it’s not a Variant:To_String operator, which I have no clue how to get working. But it works fine for my use. As I said, using reflection could help here?
    But do you really need to print a lot of other types that these ones? It does not not represent a lot of code in a whole app code.

    #13764

    nerobot
    Participant

    I think I can use your realization, for my purposes printing of variant.type.name is enough. Thanks!

    #13766

    Amon
    Participant

    I totally got all of that.

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.