public MessageParser(List <MessageToken> tokens, string outPath, string rosPackageName, string type, Dictionary <string, string> builtInTypeMapping, Dictionary <string, string> builtInTypesDefaultInitialValues, string className = "", string rosMsgName = "", MessageSubtopic subtopic = MessageSubtopic.Default)
        {
            this.tokens = tokens;

            this.inFilePath = tokens[0].content;
            this.inFileName = Path.GetFileNameWithoutExtension(inFilePath);

            this.rosPackageName      = rosPackageName;
            this.rosPackageNamespace = MsgAutoGenUtilities.ResolvePackageName(rosPackageName);

            this.subtopic = subtopic;

            if (className.Equals(""))
            {
                this.className = MsgAutoGenUtilities.CapitalizeFirstLetter(inFileName) + MsgAutoGenUtilities.MessageClassSuffix;
            }
            else
            {
                this.className = className;
            }

            if (rosMsgName.Equals(""))
            {
                if (Char.IsLower(inFileName[0]))
                {
                    Debug.LogWarningFormat("File {0} starts with a lowercase character. Message file names should be PascalCased (see : http://wiki.ros.org/ROS/Patterns/Conventions#line-38)", inFileName);
                }
                this.rosMsgName = inFileName;
            }
            else
            {
                this.rosMsgName = rosMsgName;
            }


            this.outPath     = outPath;
            this.outFilePath = Path.Combine(outPath, type);

            this.tokens.RemoveAt(0);

            this.builtInTypeMapping = builtInTypeMapping;
            this.builtInTypesDefaultInitialValues = builtInTypesDefaultInitialValues;
        }
Beispiel #2
0
 public Message DeserializeMessage(string rosMessageName, byte[] data, MessageSubtopic subtopic = MessageSubtopic.Default)
 {
     InitWithBuffer(data);
     return(MessageRegistry.GetDeserializeFunction(rosMessageName, subtopic)(this));
 }