mirror of https://github.com/axmolengine/axmol.git
issue #2790: fileToValueDict —> getValueMapFromFile, fileToValueArray —> getValueVectorFromFile.
This commit is contained in:
parent
54289276de
commit
c9767b8ea0
|
@ -226,7 +226,7 @@ void AnimationCache::addAnimationsWithFile(const std::string& plist)
|
|||
CCASSERT( plist.size()>0, "Invalid texture file name");
|
||||
|
||||
std::string path = FileUtils::getInstance()->fullPathForFilename(plist);
|
||||
ValueMap dict = FileUtils::getInstance()->fileToValueMap(path);
|
||||
ValueMap dict = FileUtils::getInstance()->getValueMapFromFile(path);
|
||||
|
||||
CCASSERT( !dict.empty(), "CCAnimationCache: File could not be found");
|
||||
|
||||
|
|
|
@ -169,7 +169,7 @@ bool ParticleSystem::initWithFile(const std::string& plistFile)
|
|||
{
|
||||
bool bRet = false;
|
||||
_plistFile = FileUtils::getInstance()->fullPathForFilename(plistFile);
|
||||
ValueMap dict = FileUtils::getInstance()->fileToValueMap(_plistFile.c_str());
|
||||
ValueMap dict = FileUtils::getInstance()->getValueMapFromFile(_plistFile.c_str());
|
||||
|
||||
CCASSERT( !dict.empty(), "Particles: file not found");
|
||||
|
||||
|
|
|
@ -199,7 +199,7 @@ void SpriteFrameCache::addSpriteFramesWithDictionary(ValueMap& dictionary, Textu
|
|||
void SpriteFrameCache::addSpriteFramesWithFile(const std::string& pszPlist, Texture2D *pobTexture)
|
||||
{
|
||||
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszPlist);
|
||||
ValueMap dict = FileUtils::getInstance()->fileToValueMap(fullPath);
|
||||
ValueMap dict = FileUtils::getInstance()->getValueMapFromFile(fullPath);
|
||||
|
||||
addSpriteFramesWithDictionary(dict, pobTexture);
|
||||
}
|
||||
|
@ -226,7 +226,7 @@ void SpriteFrameCache::addSpriteFramesWithFile(const std::string& pszPlist)
|
|||
if (_loadedFileNames->find(pszPlist) == _loadedFileNames->end())
|
||||
{
|
||||
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(pszPlist);
|
||||
ValueMap dict = FileUtils::getInstance()->fileToValueMap(fullPath);
|
||||
ValueMap dict = FileUtils::getInstance()->getValueMapFromFile(fullPath);
|
||||
|
||||
string texturePath("");
|
||||
|
||||
|
@ -335,7 +335,7 @@ void SpriteFrameCache::removeSpriteFrameByName(const std::string& name)
|
|||
void SpriteFrameCache::removeSpriteFramesFromFile(const std::string& plist)
|
||||
{
|
||||
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(plist);
|
||||
ValueMap dict = FileUtils::getInstance()->fileToValueMap(fullPath);
|
||||
ValueMap dict = FileUtils::getInstance()->getValueMapFromFile(fullPath);
|
||||
if (dict.empty())
|
||||
{
|
||||
CCLOG("cocos2d:SpriteFrameCache:removeSpriteFramesFromFile: create dict by %s fail.",plist.c_str());
|
||||
|
|
|
@ -303,14 +303,14 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
ValueMap FileUtils::fileToValueMap(const std::string& filename)
|
||||
ValueMap FileUtils::getValueMapFromFile(const std::string& filename)
|
||||
{
|
||||
std::string fullPath = fullPathForFilename(filename.c_str());
|
||||
DictMaker tMaker;
|
||||
return std::move(tMaker.dictionaryWithContentsOfFile(fullPath.c_str()));
|
||||
}
|
||||
|
||||
ValueVector FileUtils::fileToValueVector(const std::string& filename)
|
||||
ValueVector FileUtils::getValueVectorFromFile(const std::string& filename)
|
||||
{
|
||||
std::string fullPath = fullPathForFilename(filename.c_str());
|
||||
DictMaker tMaker;
|
||||
|
@ -456,8 +456,8 @@ static tinyxml2::XMLElement* generateElementForArray(ValueVector& array, tinyxml
|
|||
NS_CC_BEGIN
|
||||
|
||||
/* The subclass FileUtilsApple should override these two method. */
|
||||
ValueMap FileUtils::fileToValueMap(const std::string& filename) {return ValueMap();}
|
||||
ValueVector FileUtils::fileToValueVector(const std::string& filename) {return ValueVector();}
|
||||
ValueMap FileUtils::getValueMapFromFile(const std::string& filename) {return ValueMap();}
|
||||
ValueVector FileUtils::getValueVectorFromFile(const std::string& filename) {return ValueVector();}
|
||||
bool FileUtils::writeToFile(ValueMap& dict, const std::string &fullPath) {return false;}
|
||||
|
||||
#endif /* (CC_TARGET_PLATFORM != CC_PLATFORM_IOS) && (CC_TARGET_PLATFORM != CC_PLATFORM_MAC) */
|
||||
|
@ -749,7 +749,7 @@ void FileUtils::loadFilenameLookupDictionaryFromFile(const std::string &filename
|
|||
std::string fullPath = fullPathForFilename(filename);
|
||||
if (fullPath.length() > 0)
|
||||
{
|
||||
ValueMap dict = FileUtils::getInstance()->fileToValueMap(fullPath);
|
||||
ValueMap dict = FileUtils::getInstance()->getValueMapFromFile(fullPath);
|
||||
if (!dict.empty())
|
||||
{
|
||||
ValueMap& metadata = dict["metadata"].asValueMap();
|
||||
|
|
|
@ -300,7 +300,7 @@ public:
|
|||
* Converts the contents of a file to a ValueMap.
|
||||
* @note This method is used internally.
|
||||
*/
|
||||
virtual ValueMap fileToValueMap(const std::string& filename);
|
||||
virtual ValueMap getValueMapFromFile(const std::string& filename);
|
||||
|
||||
/**
|
||||
* Write a ValueMap to a plist file.
|
||||
|
@ -312,7 +312,7 @@ public:
|
|||
* Converts the contents of a file to a ValueVector.
|
||||
* @note This method is used internally.
|
||||
*/
|
||||
virtual ValueVector fileToValueVector(const std::string& filename);
|
||||
virtual ValueVector getValueVectorFromFile(const std::string& filename);
|
||||
|
||||
protected:
|
||||
/**
|
||||
|
|
|
@ -46,10 +46,10 @@ public:
|
|||
virtual bool isFileExist(const std::string& strFilePath) const override;
|
||||
virtual std::string getFullPathForDirectoryAndFilename(const std::string& strDirectory, const std::string& strFilename) override;
|
||||
|
||||
virtual ValueMap fileToValueMap(const std::string& filename) override;
|
||||
virtual ValueMap getValueMapFromFile(const std::string& filename) override;
|
||||
virtual bool writeToFile(ValueMap& dict, const std::string& fullPath) override;
|
||||
|
||||
virtual ValueVector fileToValueVector(const std::string& filename) override;
|
||||
virtual ValueVector getValueVectorFromFile(const std::string& filename) override;
|
||||
};
|
||||
|
||||
// end of platform group
|
||||
|
|
|
@ -308,7 +308,7 @@ std::string FileUtilsApple::getFullPathForDirectoryAndFilename(const std::string
|
|||
return "";
|
||||
}
|
||||
|
||||
ValueMap FileUtilsApple::fileToValueMap(const std::string& filename)
|
||||
ValueMap FileUtilsApple::getValueMapFromFile(const std::string& filename)
|
||||
{
|
||||
std::string fullPath = fullPathForFilename(filename);
|
||||
NSString* path = [NSString stringWithUTF8String:fullPath.c_str()];
|
||||
|
@ -344,7 +344,7 @@ bool FileUtilsApple::writeToFile(ValueMap& dict, const std::string &fullPath)
|
|||
return true;
|
||||
}
|
||||
|
||||
ValueVector FileUtilsApple::fileToValueVector(const std::string& filename)
|
||||
ValueVector FileUtilsApple::getValueVectorFromFile(const std::string& filename)
|
||||
{
|
||||
// NSString* pPath = [NSString stringWithUTF8String:pFileName];
|
||||
// NSString* pathExtension= [pPath pathExtension];
|
||||
|
|
|
@ -478,7 +478,7 @@ Array* Array::createWithContentsOfFile(const char* fileName)
|
|||
|
||||
Array* Array::createWithContentsOfFileThreadSafe(const char* fileName)
|
||||
{
|
||||
ValueVector arr = FileUtils::getInstance()->fileToValueVector(fileName);
|
||||
ValueVector arr = FileUtils::getInstance()->getValueVectorFromFile(fileName);
|
||||
|
||||
Array* ret = Array::createWithCapacity(arr.size());
|
||||
|
||||
|
|
|
@ -444,7 +444,7 @@ static Array* visitArray(const ValueVector& array)
|
|||
|
||||
Dictionary* Dictionary::createWithContentsOfFileThreadSafe(const char *pFileName)
|
||||
{
|
||||
return visitDict(FileUtils::getInstance()->fileToValueMap(pFileName));
|
||||
return visitDict(FileUtils::getInstance()->getValueMapFromFile(pFileName));
|
||||
}
|
||||
|
||||
void Dictionary::acceptVisitor(DataVisitor &visitor)
|
||||
|
|
Loading…
Reference in New Issue