specmgr.h #1

  • //
  • guest/
  • perforce_software/
  • p4ruby/
  • main/
  • specmgr.h
  • View
  • Commits
  • Open Download .zip Download (2 KB)
/*******************************************************************************

Copyright (c) 1997-2004, Perforce Software, Inc.  All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1.  Redistributions of source code must retain the above copyright
    notice, this list of conditions and the following disclaimer.

2.  Redistributions in binary form must reproduce the above copyright
    notice, this list of conditions and the following disclaimer in the
    documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTR
IBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL PERFORCE SOFTWARE, INC. BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

*******************************************************************************/

/*******************************************************************************
 * Name		: specmgr.h
 *
 * Author	: Tony Smith <[email protected]> or <[email protected]>
 *
 * Description	: Ruby bindings for the Perforce API. Class for handling
 * 		  Perforce specs. This class provides other classes with
 * 		  generic support for parsing and formatting Perforce
 *		  specs.
 *
 ******************************************************************************/

class SpecMgr 
{
    public:
		SpecMgr()		{ debug = 0;	}
	void	SetDebug( int i )	{ debug = i; 	}

	int	HashToText( VALUE i, StrBuf *strbuf, StrPtr *specDef, Error *e);
	VALUE	DictToSpec( StrDict *dict, StrPtr *specDef );
	VALUE	DictToHash( StrDict *dict, VALUE hash = Qnil );
	VALUE	SpecFields( StrPtr *specDef );

    private:
	void	SplitKey( const StrPtr *key, StrBuf &base, StrBuf &index );
	void	InsertItem( VALUE hash, const StrPtr *var, const StrPtr *val );
	VALUE	NewSpec( StrPtr *specDef );

    private:
	int	debug;
};

# Change User Description Committed
#8 14682 Git Fusion Git Fusion branch management

Imported from Git
 ghost-of-change-num: 960958
 ghost-of-sha1: 005052ae424bd69f426f7209e741ca1c8c3253c7
 ghost-precedes-sha1: ad052c71a568ef12165e143a6866ad9ceffbb4a1
 parent-branch: None@960958
 push-state: incomplete
#7 14544 tony Enable P4Ruby to handle jobspec fields with names that end in
numbers. Previously these were mistaken for entries in list
fields (wlist, llist).

This change introduces SpecDataRuby, a subclass of SpecData that
reads from/writes to Ruby P4::Spec objects. That makes it a snap
to parse and format specs using the same code the server does,
and that fixes this bug very neatly, and probably makes it faster
too.

I've also replaced the manual parsing of the specdef strings with
an implementation that uses the Spec, and SpecElem classes. That's
also going to be more reliable in the long run.

This change will be ported to P4Perl, P4Python, and should probably
also go into the upcoming P4PHP.

User-visible bug fix documented in p4rubynotes.txt
#6 14541 tony Copyright notice housekeeping: update all notices to 2008, and
correct start date from 1997 to 2001 when P4Ruby was first released
from the public depot.

No functional change
#5 14521 tony Update copyright notices in all applicable P4Ruby files.
#4 14504 tony Disambiguate my specs: rename AddSpec() to AddSpecDef() and
HaveSpec() to HaveSpecDef() since those methods deal with
manipulating the specdef cache rather than producing specs
themselves.
#3 14503 tony Followon to previous change.
Remove overloaded SpecMgr::SpecToString()
as, now that ClientUserRuby knows which command we're running, we can
dispense with it.
#2 14502 tony Rework spec handling somewhat so that:

(a) P4Ruby knows about the default spec types for 2007.2 so it
    doesn't have to connect to the server to parse and format specs,
    and nor does it have to do the ugly hack of running a 'p4 xxx -o'
    and discarding the result just to get the specDef.

(b) If a user's got a custom spec then the spec cache will be updated
    if they fetch an object of that type. So basically, if the
    server's given us a specdef for a class of spec, we use it.
    Otherwise, we fall back on the builtin defaults

This reworks SpecMgr quite a bit - renaming methods so it's clearer
what they do, and making it own the spec cache. We also pass the
SpecMgr object created by P4ClientApi down to ClientUserRuby now,
so that whenever the server sends us a spec, we can update the cache.
#1 14480 tony Add P4Ruby 1.5944 to main as start-point for the first
productized release of P4Ruby