zoukankan      html  css  js  c++  java
  • js校验

    //待验证
    ////////////////////////////////////////////////////////////////////////////////////////////////////
    ////////////////////////////////////////////////////////////////////////////////////////////////////
    class TJS
    {
    public:
    	templete<typename T1>
    	static bool isValidFn(const Json::Value& m_js, T1 t1)
    	{
    		return isValid(m_js, t1);
    	}
    
    	templete<typename T1, typename T2>
    	static bool isValidFn(const Json::Value& m_js, T1 t1, T2 t2)
    	{
    		return isValid(m_js, t1) 
    			&& isValid(m_js[t1], t2) 
    	}
    
    	templete<typename T1, typename T2, typename T3>
    	static bool isValidFn(const Json::Value& m_js, T1 t1, T2 t2, T3 t3)
    	{
    		return isValid(m_js, t1) 
    			&& isValid(m_js[t1], t2) 
    			&& isValid(m_js[t1][t2], t3) 
    	}
    
    	templete<typename T1, typename T2, typename T3, typename T4>
    	static bool isValidFn(const Json::Value& m_js, T1 t1, T2 t2, T3 t3, T4 t4)
    	{
    		return isValid(m_js, t1) 
    			&& isValid(m_js[t1], t2) 
    			&& isValid(m_js[t1][t2], t3) 
    			&& isValid(m_js[t1][t2][t3], t4)
    	}
    
    	templete<typename T1, typename T2, typename T3, typename T4, typename T5>
    	static bool isValidFn(const Json::Value& m_js, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5)
    	{
    		return isValid(m_js, t1) 
    			&& isValid(m_js[t1], t2) 
    			&& isValid(m_js[t1][t2], t3) 
    			&& isValid(m_js[t1][t2][t3], t4)
    			&& isValid(m_js[t1][t2][t3][t4], t5)
    	}
    
    	templete<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
    	static bool isValidFn(const Json::Value& m_js, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6)
    	{
    		return isValid(m_js, t1) 
    			&& isValid(m_js[t1], t2) 
    			&& isValid(m_js[t1][t2], t3) 
    			&& isValid(m_js[t1][t2][t3], t4)
    			&& isValid(m_js[t1][t2][t3][t4], t5)
    			&& isValid(m_js[t1][t2][t3][t4][t5], t6)
    	}
    private:
    	templete<typename T>
    	static bool isValid(const Json::Value& js, T t)
    	{
    		js.isArray(js) ? (js.size() > t ? true : false) ? isMember(t) : ture ? false; 
    	} 
    }; 
    
    int main()
    {
    	Json::Value jstemp = Json::Value::null;
    	jstemp[1][2]["factory"]["name"][5]["lol"] = "test";
    	
    	tjs::isValidFn(jstemp, 1, 2, "factory");
    	return 0;
    }
    
  • 相关阅读:
    MySQL (一)(未完成)
    HTML 学习笔记 CSS3 (边框)
    HTML 学习笔记 JavaScript (函数)
    HTML 学习笔记 JavaScript (对象)
    HTML 学习笔记 JavaScript (变量)
    HTML 学习笔记 JavaScript (实现)
    HTML 学习笔记 JavaScript(简介)
    iOS RunTime运行时(1):类与对象
    iOS UITableView 分割线从零开始
    HTML 学习笔记 CSS(选择器4)
  • 原文地址:https://www.cnblogs.com/kuikuitage/p/10953053.html
Copyright © 2011-2022 走看看