Question

while reading about actors on
http://msdn.microsoft.com/en-us/devlabs/hh975426.aspx I noticed the part on serialization:

Since serialization is critical to the correct function of a program and it is so easy to get wrong, the C++ Actors library includes a simple message definition generation tool, ‘msgtool,’ which given an XML document will create the necessary type and serialization definition.

I cant find msgtool in VS command prompt, or using Google search.

Was it helpful?

Solution

This is part of the Casablanca project, an incubation project at Microsoft and owned by the DevLabs group. It is a pretty fresh project, first I heard about it was about 3 months ago. It may well have been going on longer, not sure.

You are not going to find any of the Casablanca tools in the standard VS distribution, this project is a long way off from being a core shrink-wrapped Microsoft product. Incubation projects are a vehicle to explore promising technologies that some day may pay off. Microsoft has never been shy about exposing what they are working on, getting feedback from their customers to find out what works and what does not. No "don't put your finger on the antenna of the phone" surprises.

They are definitely bucking a major trend in cloud computing, they are using native C++. This has been in the domain of VM languages for a very long time. Reflection support is a pretty important asset. But clearly, to make any of this work it is rather important that serializing C++ objects reliably is a major requirement. Thus this "msgtool".

The landing page for the project is here. They offer installers for VS2010, VS2012 and the latest crop of Express editions. Click the buttons on the right to get it going. I didn't actually try it but you ought to end up with "msgtool.exe" after installing it. Make sure you can deal with a project going bust after committing to it, the most typical outcome for these kind of projects at Microsoft.


UPDATE: do note that the linked web page is no longer available at the DevLabs site. The true project home page mentions:

Our documentation is no longer available on the DevLabs web site, only in the downloaded files

You can find the copy of the linked page in Casablanca_Samples.zip\Documents\actors.html. Navigate to the "Serialization" section and compare the two. At the exact spot where "msgtool" is mentioned, you'll now see it talking about the msg_ptr<T> template class. So yes, it certainly looks like this tool is no longer supported or included with the current SDK, if it ever was.

OTHER TIPS

Here you go, in python - quick and dirty! And wrong, of course, but you get the idea I hope !

import xml.dom.minidom


s = ''' 
<Namespace name="test">
  <Message name="FooBar">
    <Type name="T"/>
    <Field name="a" type="std::string"/>
    <Field name="b" type="T"/>
    <Field name="d" type="std::string"/>
  </Message>
</Namespace>
'''

dom = xml.dom.minidom.parseString(s)

messages = []

def parseMessage(node):
    print 'class', node.attributes['name'].value, '{'
    for type in node.getElementsByTagName('Type'):
        print 'template<typename', type.attributes['name'].value, '>'
    for field in node.getElementsByTagName('Field'):
        print field.attributes['type'].value, field.attributes['name'].value, ';'
    print '}'
    messages.append(node)


def parseNamespace(node):
    print 'namespace', node.attributes['name'].value, '{'
    for child in node.childNodes:
        if child.nodeType == child.ELEMENT_NODE:
            if 'Message'==child.tagName:
                parseMessage(child)
    print '}'

for child in dom.childNodes:

    if 'Namespace'==child.tagName:
        parseNamespace(child)

for node in messages:
    message_name = node.attributes['name'].value
    type_name = None
    for type in node.getElementsByTagName('Type'):
        type_name = type.attributes['name'].value
    print 'template<typename %s>'%type_name
    print 'size_t calculate_size(const test::%s<%s> &data)'%(message_name, type_name)
    print '{ return'
    print '+'.join(['::calculate_size(data.%s)'%field.attributes['name'].value for field in node.getElementsByTagName('Field')])
    print ';}'
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top