String Problem



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 28/09/2011 at 09:55, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   R13 
    Platform:   Windows  ;   
    Language(s) :

    ---------
    Hey Guys,

    I got a strange problem.

    When I want use a String static, it doen´t work. MSVC++ compile but the plugin get not loaded. Why? LONG or LVector works...

    #include "c4d.h"  
      
    #define ID_TEST_TOOL 1234567  
      
    class TestTool : public ToolData  
    {  
    public:  
      static String* teststring;  
    };  
      
    String* TestTool::teststring;  
      
    Bool RegisterTestTool(void)  
    {  
      return RegisterToolPlugin(ID_TEST_TOOL, "TestTool", 0, NULL, "TestTool", gNew TestTool());  
    }  
    


  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 29/09/2011 at 01:01, xxxxxxxx wrote:

    A static class member exists as a 'singleton' (only one definition applies for the program) without the need for a class instance.  But (if you'll look closely at the last argument of the RegisterToolPlugin()), the class is instanced during registration.  Also, you are defining it globally (outside the class declaration) but you assign no value which means that it will never have a value.  Finally, since this is the Cinema 4D API String class, there may be underlying constructions that make using it like this illegal.  You must ask yourself, "Why do you need to do this?"  Because if there is no good reason, go the standard, working route.



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 29/09/2011 at 06:50, xxxxxxxx wrote:

    Hey Roboert,

    Thanks for your answer.
    It should not be in a ToolData, it was just an example.

    I want to create a Container-Class, to store much values/parameters for a very big plugin.
    The String should be an error log.

    BaseContainer works also as static, but why the hell not String?!?



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 29/09/2011 at 09:56, xxxxxxxx wrote:

    I would use a BaseContainer (as part of the plugin de facto) and save/load it with the Get/SetWorldPluginData().  This allows settings/preferences to be stored contiguously between uses and invocations of Cinema 4D.  I think that you will not need a static class member to achieve your ends.  You should be able to use a regular class member (or simply a BaseContainer resource/description) as long as you do your storing as part of some message or destructor action.  Not quite sure of your intentions so it is hard to advise.

    Remember that a plugin object (tag, tool, object, etc.) has a description container which you can set/get and store/load current values using the plugin data functionality of the SDK.  For instance, if you want to store an error log as a set of strings, you could do it by creating a subcontainer that has a range of values which reference a list of strings representing the list of log entries.  The subcontainer would have a unique ID in the basecontainer and the string subcontainer values could be linearly contiguous (0->n, for instance).  While the SDK BaseContainer approach is a bit strange and difficult, it does afford some level of flexibility and adherence so you do not need to track every bit of information (such as file reading/writing and tracking/insertion/deletion). In this case, as an appended list, it would work well with the BaseContainer ideology as long as you track counts (number of log entries).  You can even add that value as an entry in the container:

    LONG logentries
    entry 0
    ...
    entry logentries-1=


Log in to reply