MapApi::Join( MapApi *, MapDir, MapApi *, MapDir ) [static]

Joins two MapApis together to produce a combined mapping.

Virtual?

No

 

Class

MapApi

 

Arguments

MapApi *m1

the first mapping

 

MapDir d1

the orientation of the first mapping

 

MapApi *m2

the second mapping

 

MapDir d2

the orientation of the second mapping

Returns

MapApi *

a new MapApi representing the joined maps

Notes

This overload of Join() works exactly like the simpler two-argument overload, but allows the caller to reverse either or both mappings before they are joined together. Specifying MapLeftRight as the direction for both mappings will produce the same result as the two-argument Join().

If the two mappings do not have anything in common at the join point, the result is an empty mapping.

This function allocates a new MapApi object on the heap; the caller is responsible for deleting it.

Example

The following example demonstrates a join between a branch view and a client view, with both mappings reversed so that the client path is on the left side of the result and the branch source is on the right side.

MapApi branchmap;
branchmap.Insert( StrRef( "//depot/main/..." ), StrRef( "//depot/rel1/...") );

MapApi clientmap;
clientmap.Insert( StrRef( "//depot/..." ), StrRef( "//client/depot/..." ) );

MapApi *client_to_branch = MapApi::Join
    ( &clientmap, MapRightLeft, &branchmap, MapRightLeft );

StrBuf clientFile( "//client/depot/rel1/file.c" );
StrBuf branchFile;

client_to_branch->Translate( clientFile, branchFile );
printf( "%s -> %s\n", clientFile.Text(), branchFile.Text() );
delete client_to_branch;

Executing the preceding code produces the following output:

//client/depot/rel1/file.c -> //depot/main/file.c